DarthFubuMVC/FubuMVC.AntiForgery — pull request #6 by KevM (2014-02-19 16:17:15+00:00)
Title: Deserializer should not throw when given bad input

When a person tampers with the AntiForgeryData value being deserialized it usually results in an exception being thrown. I would have expected that the deserialize failure get logged and an empty AntiForgeryData object gets returned.

Currently when the cookie or form data are tampered with the anti-forgery behavior will throw an exception causing the chain to return 404 (not sure why this is a 404).

In our case this means the user is still logged as we'd like to cancel the user's session when we detect tampering. If a blank object was returned the validation would fail and the normal chain failure behavior would commence.

A blank result object will fail validation nicely. An alternative to this would be to have any usages of the Deserialize method check for an exception. IMHO that is not as nice.