csrf

ASP.NET MVC HTML.AntiForgeryToken() with multiple AJAX requests from one page

↘锁芯ラ 提交于 2019-12-04 05:26:36
I'm creating a page that makes multiple AJAX form posts without a page refresh. I would like to use the ASP.NET MVC HTML.AntiForgeryToken() helper to secure the form against CSRF attacks. I think that each form on the page can share the same token, but will it allow multiple requests with the same token? If not is there a way to get a new token or some other way to secure the forms? Ofer Zelig You can share the same token. Of course, as a general rule, it's highly recommended to wrap your Ajax calls in a unified method that concatenates the CSRF token to the request (be it GET or POST although

CSRF safe Custom button linked to Apex method

て烟熏妆下的殇ゞ 提交于 2019-12-04 04:44:32
I'm looking for a technique to execute Apex code from a custom button added to the Opportunity object in a way that protects the user against CSRF. The current approach being used comes from the question - Custom Button or Link to a Visualforce page with a custom controller . Essentially: There is an Opportunity Custom Button with the Content Source set to "Visualforce Page". The Content for this button is set to a Visualforce page that uses Opportunity for the standardController, has an extension apex class entered and an action for a method in that class The action method returns a

源码看微软验证Token【CSRF】MVC5

给你一囗甜甜゛ 提交于 2019-12-04 02:14:49
都知道在MVC5中,在action方法前加入 [ValidateAntiForgeryToken] ,会验证是否来自于自己表单的用户,验证其 cook 的 token 和来自表单中的 token ,是否一致 为方便更好的调试,直接调用其验证方法 AntiForgery.Validate(); // [AcceptVerbs(HttpVerbs.Post)] netCore没有这个 [HttpPost] // [ValidateAntiForgeryToken] public JsonResult Index(int a=1/*IFormCollection collection*/) { HttpCookie antiForgeryCookie = Request.Cookies[AntiForgeryConfig.CookieName]; string cookieValue = antiForgeryCookie != null ? antiForgeryCookie.Value : null; AntiForgery.Validate(cookieValue, Request["__RequestVerificationToken"]);//Validate,就是框架源码验证的核心 ModelState.AddModelError("", "1111111111111");

Renaming Spring csrf token variable

随声附和 提交于 2019-12-04 02:00:14
问题 My application runs under another portal application. Both are implemented in spring and both use csrf security. My need is basically change how the csrf token is named in the session, so both the tokens can work without conflicts. What I tried so far is creating another token repository and trying to change the parameter name and the session attribute name in the security config class. final HttpSessionCsrfTokenRepository tokenRepository = new HttpSessionCsrfTokenRepository();

Should I use HTTP referrer validation or token verification to prevent CSRF attacks?

只谈情不闲聊 提交于 2019-12-04 01:54:12
I read about how to protect my web site from CSRF attacks in an ASP.NET MVC web application. They mentioned two ways to do so, either by: using Token Verification by using <@Html.AntiForgeryToken()> and [ValidateAntiforgeryToken] using HTTP referrer validation such as: public class IsPostedFromThisSiteAttribute : AuthorizeAttribute { public override void OnAuthorize(AuthorizationContext filterContext) { if (filterContext.HttpContext != null) { if (filterContext.HttpContext.Request.UrlReferrer == null) throw new System.Web.HttpException("Invalid submission"); if (filterContext.HttpContext

Are JAXRS restful services prone to CSRF attack when content type negotiation is enabled?

浪子不回头ぞ 提交于 2019-12-04 01:40:29
问题 I have a RESTful API which has annotations like @Consumes(MediaType.JSON) - in that case, would the CSRF attack still be possible on such a service? I've been tinkering with securing my services with CSRFGuard on server side or having a double submit from client side. However when I tried to POST requests using FORM with enctype="text/plain", it didn't work. The technique is explained here This works if I have MediaType.APPLICATION_FORM_URLENCODED in my consumes annotation. The content

CSRF tokens - how to implement properly?

左心房为你撑大大i 提交于 2019-12-04 00:45:13
I've just setup a simple CSRF protection in my application. It creates a unique crumb which are validated against a session value upon submitting a form. Unfortunately this means now that I can't keep multiple instances (tabs in the browser) of my application open simultaneously as the CSRF crumbs collide with each other. Should I create an individual token for each actual form or use a mutual, shared crumb for all my forms? What are common sense here? Jason Dean You can do either. It depends on the level of security you want. The OWASP Enterprise Security API (ESAPI) uses the single token per

PHP further security on anti-CSRF token

风格不统一 提交于 2019-12-03 22:42:06
I am learning about how to prevent CSRF using anti-CSRF tokens. Essentially, the idea is to:- 1) generate a token eg Md5 or Sha1 then store this value in a session variable:- $token = md5(uniqid(rand(), TRUE)); $_SESSION['token'] = $token; 2) All forms include this token value in a POST hidden field <input type='hidden' name='token' value='$nonce_token' /> Eg what it would look like to user in source code:- <input type='hidden' name='token' value='9ee66e4e63a06ee4b83a3edde4ecd587' /> 3) Once form sent check POST hidden field token value matches token stored in session value if($_POST['token']=

flask处理csrf攻击

空扰寡人 提交于 2019-12-03 22:41:18
CSRF攻击原理 csrf攻击流程 具体流程 - 文字描述 通常情况下,该请求发送到网站后,服务器会先验证该请求是否来自一个合法的 session,并且该 session 的用户 Bob 已经成功登陆。 黑客 Mallory 自己在该银行也有账户,他知道上文中的 URL 可以把钱进行转帐操作。 Mallory 可以自己发送一个请求给银行:http://bank.example/withdraw?account=bob&amount=1000000&for=Mallory。但是这个请求来自 Mallory 而非 Bob,他不能通过安全认证,因此该请求不会起作用。 这时,Mallory 想到使用 CSRF 的攻击方式,他先自己做一个网站,在网站中放入如下代码: src=”http://bank.example/withdraw?account=bob&amount=1000000&for=Mallory ”,并且通过广告等诱使 Bob 来访问他的网站。 当 Bob 访问该网站时,上述 url 就会从 Bob 的浏览器发向银行,而这个请求会附带 Bob 浏览器中的 cookie 一起发向银行服务器。大多数情况下,该请求会失败,因为他要求 Bob 的认证信息。 但是,如果 Bob 当时恰巧刚访问他的银行后不久,他的浏览器与银行网站之间的 session 尚未过期,浏览器的 cookie