Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deserializer should not throw when given bad input #6

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

KevM
Copy link

@KevM KevM commented Feb 19, 2014

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.

@jeremydmiller
Copy link
Contributor

Kevin, can you just call ILogger.Info w/ a new "CorruptedAntiForgeryToken : LogTopic" type message? Other than that it looks good.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants