Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

KB2418241, KB2416473, and KB2416451 all reference http://www.microsoft.com/technet/security/bulletin/MS10-070.mspx

After installing this patches on our Windows Server 2003 machines last Friday, we have been getting a significantly increased rate of errors of the sort:

System.Web.Mvc.HttpAntiForgeryException: A required anti-forgery token was not 
supplied or was invalid. ---> System.Web.HttpException: Validation of viewstate MAC
failed. If this application is hosted by a Web Farm or cluster, ensure that <machineKey> 
configuration specifies the same validationKey and validation algorithm. AutoGenerate
cannot be used in a cluster. ---> System.Web.UI.ViewStateException: Invalid viewstate. 

The setup is as follows:

  • The web applications are running in a web cluster, with the NLB settings to Client Affinity: Single.
  • There are redirects between two separate web applications, and both of their machineKey elements are identical using explicit validationKey and decryptionKey elements.
  • The validation method is set to "SHA1" and the decryption method is set to "AES"

    (Furthermore, no redeployments of the applications have taken since well before the microsoft updates were installed).

These errors could of course be caused by actual CSRF attacks, but I find it unlikely given the volume and the spike corresponding with installation of the updates.

Are there any known issues with this update that could be causing this? (and even better, any known workarounds?)

share|improve this question

1 Answer 1

up vote 0 down vote accepted

This problem was indeed caused by the security update. The update changed the way things are validated by additionally signing the encrypted data. This included the AntiForgeryToken cookie.

If the user restarts their browser or otherwise clears all session cookies, the problem goes away.

This was also noted in a comment at http://weblogs.asp.net/scottgu/archive/2010/09/27/asp-net-security-update-shipping-tuesday-sept-28th.aspx

After installing the patch, I was quite freaked out to find requests to my site
failing  - 500s.  But only in one browser.  To sum up: If you have an MVC site, 
and are using Html.AntiForgeryToken() - any existing browser sessions will need 
to be closed and reopened so that the session cookie that was generated before 
the patch was applied, for that antiforgery token, can be killed.   Your existing 
users may need to be informed of this - I can't see anyway to change the name of that 
cookie.

You can also run into this problem when upgrading from MVC 1 to MVC 2:

http://weblogs.asp.net/james_crowley/archive/2010/03/18/beware-upgrade-to-asp-net-mvc-2-0-with-care-if-you-use-antiforgerytoken.aspx

In both cases, a workaround if you can't force your users to restart their browser requires editing the application code and redeploying. You can edit the application so that when the exception occurs, you clear the AntiForgeryToken cookie from the incoming request, and then reissue the token cookie by calling Html.AntiForgeryToken(). However, in doing so, you must take care that you only do it in the appropriate places (e.g. the error page or other page that does not modify data) - otherwise, you lose all the protection from CSRF attacks, which is the whole reason of using the antiforgery token in the first place.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.