antiforgerytoken

Why does @Html.AntiForgeryToken() generate different tokens in same response?

这一生的挚爱 提交于 2019-11-27 16:48:04
问题 A single Razor view contains several forms, each with its own call to @Html.AntiForgeryToken() <form id="f1"> @Html.AntiForgeryToken() </form> <form id="f2"> @Html.AntiForgeryToken() </form> As I understand it, both of these anti forgery tokens should be the same. <form id="f1"> <input name="__RequestVerificationToken" type="hidden" value="duVT4VtiYybun-61lnSY1ol__qBwawnELooyqT5OSrCJrvcHvDs_Nr9GLxNxwvBaI4hUcKZVkm6mDEmH2UqNorHD1FnJbKJQLWe8Su_dhy_nnGGl5GhqqC3yRGzcxbBM0" /> </form> <form id="f2"

Any reason not to trust ASP.NET AntiForgeryToken?

▼魔方 西西 提交于 2019-11-27 13:51:10
问题 I know that Stack Exchange sites do not use the ASP.NET MVC built-in @Html.AntiForgeryToken() for the prevention of XSRF/CSRF attacks. Instead of creating a hidden input named __RequestVerificationToken with a really long value based on the machineKey section of the web.config, the Stack Exchange method creates an input named fkey with a MUCH more succinct value. This is apparently a Guid, and based on evidence from the Stack Exchange Data Explorer project on Google Code, this value is tied

Anti forgery token on login page

£可爱£侵袭症+ 提交于 2019-11-27 12:19:17
问题 I have implemented antiforgery token on my login page. Now I had one user pressing back key on the keyboard, and when they click on login button again after filling their credentials, they get error page. Is there some better way of handeling this case like redirect them to fresh login page? Page that is login page is : /account/logon If login details are sucessfull the user is redirected to :Home/Index page on which the user pressed button back. 回答1: Don't implement the ASP.NET

Problems implementing ValidatingAntiForgeryToken attribute for Web API with MVC 4 RC

隐身守侯 提交于 2019-11-27 11:03:33
I'm making JSON-based AJAX requests and, with MVC controllers have been very grateful to Phil Haack for his Preventing CSRF with AJAX and, Johan Driessen's Updated Anti-XSRF for MVC 4 RC . But, as I transition API-centric controllers to Web API, I'm hitting issues where the functionality between the two approaches is markedly different and I'm unable to transition the CSRF code. ScottS raised a similar question recently which was answered by Darin Dimitrov. Darin's solution involves implementing an authorization filter which calls AntiForgery.Validate. Unfortunately, this code does not work

When the use of a AntiForgeryToken is not required /needed?

二次信任 提交于 2019-11-27 05:39:39
问题 UPD: Same question asked on security.stackexchange.com and the answer I got is different. Please follow there, to get the correct answer! I'm running a rather large site with thousands of visits every day, and a rather large userbase. Since I started migrating to MVC 3, I've been putting the AntiForgeryToken in a number of forms, that modify protected data etc. Some other forms, like the login / registration also use the AntiForgeryToken now, but I'm becoming dubious about their need there in

Web API and ValidateAntiForgeryToken

血红的双手。 提交于 2019-11-26 19:32:08
We have some existing MVC web services that are called AJAX style from web pages. These services make use of the ValidateAntiForgeryToken attribute to help prevent request forgeries. We are looking to migrate these services to Web API, but there appears to be no equivalent anti-forgery functionality. Am I missing something? Is there a different approach to addressing request forgeries with Web API? You could implement such authorization attribute: [AttributeUsage(AttributeTargets.Method | AttributeTargets.Class, AllowMultiple = false, Inherited = true)] public sealed class

anti-CSRF token and Javascript

强颜欢笑 提交于 2019-11-26 19:19:14
问题 I'm trying to protect an application (php and lots of JS) from CSRF. I want to use tokens. A lot of operations are done with AJAX, so I have to pass the token in Javascript. If I want to generate 1 token per session or per page load it's simple - I generate new token, put it somewhere in a DOM and then find it with Javascript and send to the processing side. But what if I want to use new token for every operation? I was thinking about doing an ajax call to regenerate token and then pass the

Troubleshooting anti-forgery token problems

ぃ、小莉子 提交于 2019-11-26 18:45:53
I have a form post that consistently gives me an anti-forgery token error. Here is my form: @using (Html.BeginForm()) { @Html.AntiForgeryToken() @Html.EditorFor(m => m.Email) @Html.EditorFor(m => m.Birthday) <p> <input type="submit" id="Go" value="Go" /> </p> } Here is my action method: [HttpPost] [ValidateAntiForgeryToken] public ActionResult Join(JoinViewModel model) { //a bunch of stuff here but it doesn't matter because it's not making it here } Here is the machineKey in web.config: <system.web> <machineKey validationKey="mykey" decryptionKey="myotherkey" validation="SHA1" decryption="AES"

Problems implementing ValidatingAntiForgeryToken attribute for Web API with MVC 4 RC

心不动则不痛 提交于 2019-11-26 17:58:57
问题 I'm making JSON-based AJAX requests and, with MVC controllers have been very grateful to Phil Haack for his Preventing CSRF with AJAX and, Johan Driessen's Updated Anti-XSRF for MVC 4 RC. But, as I transition API-centric controllers to Web API, I'm hitting issues where the functionality between the two approaches is markedly different and I'm unable to transition the CSRF code. ScottS raised a similar question recently which was answered by Darin Dimitrov. Darin's solution involves

deploying AntiforgeryToken Error

浪尽此生 提交于 2019-11-26 16:50:00
问题 I am working on an ASP.NET MVC application on my local machine using the Visual Studio 2012 built in IISExpress. After a significant progress I decided to make it available across the Local network, I created a virtual directory from visual studio. I can log in but when I try to register a new user. I get the error below. The anti-forgery token could not be decrypted. If this application is hosted by a Web Farm or cluster, ensure that all machines are running the same version of ASP.NET Web