Deserializer should not throw when given bad input #6
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.