ASP.NET 5 -> Security -> Anti-Request Forgery
https://developer.mozilla.org/en-US/docs/Web/Guide/HTML/Forms/Sending_and_retrieving_form_data
Should reference https://github.com/aspnet/Docs/issues/134
Hi there,
Will the URL at https://docs.asp.net/en/latest/security/anti-request-forgery.html stay stable once the docs drop?
As the project lead of OWASP Top 10 2007, OWASP Developer Guide 2.0, and OWASP Application Security Verification Standard 3.0, would love to give as much of the security documentation you've got ready a review before it goes final. I'm easily reachable by the usual means, but best through my owasp address.
I've been developing some unit tests around high functioning CSRF implementations, happy to share code if you don't have a lot of tests for the CSRF functionality in ASP.NET core at the moment.
@rynowak @blowdart @Tratcher see offer of tests for the CSRF functionality in ASP.NET core
@danroth27 please respond to URL stability.
@vanderaj There may still be some URL churn before we go final.
@vanderaj Feel free to submit a PR to https://github.com/aspnet/antiforgery with additional tests.
@blowdart @rynowak please review this request antiforgery doc plan:
We should include in this article documenting the new automatic anti-request forgery support in MVC
@spboyer take a look
@blowdart @rynowak please review this request antiforgery doc plan:
Yes, that's a doc plan :D
I'd like to see getting the form token part in javascript, rather than having to write a form
Document outline update after discussion with @rynowak
There are load-balancing scenarios to consider. If there are multiple servers, they all need to share a data protection keyring. Refer to data protection docs for more info. https://docs.microsoft.com/en-us/aspnet/core/security/data-protection/configuration/overview
JavaScript (Ajax) / SPA
@danroth27 @spboyer I might work on this with @fiyazbinhasan - see his reventing XSRF in AngularJS Apps with ASP.NET CORE Anti-Forgery Middleware
@Rick-Anderson ok got it.
@danroth27 @spboyer - @fiyazbinhasan is going to start working on this. The outline after meeting with @rynowak doesn't mention
But we'll want to combine these two articles - but at the same time follow the outline. @rynowak is that OK with you?
@danroth27 @spboyer - @fiyazbinhasan is going to start working on this. The outline after meeting with @rynowak doesn't mention
•- Combine Web API and MVC XSRF/CSRF Prevention into one asp.net core article
@Rick-Anderson
It would be totally fantastic, if you could include some information on how to customise when the Anti Forgery token expires - instead of just at the end of the browser session.
CSRF tokens shouldn't expire, unless the underlying identity changes.
You can see the start of this at https://www.dropbox.com/sh/jfmncpp0z79m9mt/AAAAB98zC4J7f9g_l6egU8nta?dl=0
@Rick-Anderson
If you can spare the time, please include:
I also really like this article:
http://resources.infosecinstitute.com/securing-cookies-httponly-secure-flags/
For reference: #1945
This sample is easily found: https://github.com/aspnet/Antiforgery/tree/dev/samples/AntiforgerySample
But we should update to the Entropy sample: https://github.com/aspnet/Entropy/tree/dev/samples/Mvc.AjaxAntiforgeryAuth.Web
The Angular way of passing the token is very angular-specific. A more generic approach would be more widely applicable.
@fiyazbinhasan can you write a more generic sample? @danroth27 do we want both an angular and a generic sample? I was thinking angular is very popular and would justify a specific example.
Yes we just discussed and we want both an Angular and a generic example (or more than one: web vs. native clients for instance)
@ardalis you can find a ajax(javascript) example on the bottom of this doc @Rick-Anderson provided earlier. I used Jquery for making the task of cookie parsing easier. I can write a raw one if you want :)
var csrfToken = $.cookie("CSRF-TOKEN");
$.ajax({
url: "/api/transaction",
contentType: "application/json",
data: JSON.stringify({"transactionAmount": 100, "transactionType": "DEBIT"}),
type: "POST",
headers: {"X-CSRF-TOKEN": csrfToken }});
aspnet/antiforgery#119
@fiyazbinhasan thanks for the assistance; please review #1945
Most helpful comment
@Rick-Anderson
If you can spare the time, please include:
I also really like this article:
http://resources.infosecinstitute.com/securing-cookies-httponly-secure-flags/