4

The AntiForgeryToken is used to prevent CSRF attacks, however the links on MSDN don't give me much insight to what exactly the AntiForgeryToken does, or how it works, or why things are done the way they are.

From what I gather, it creates a hash inside a web page and a cookie. One or both of them use the hashed IPrincipal.Name, and use symmetric encryption.

Can anyone shed light as to:

  1. How the AntiForgeryToken works internally
  2. What should it be used to protect
  3. What should it NOT be used to protect
  4. What is the reasoning behind the implementation choices for #1 above?
AviD
  • 72,138
  • 22
  • 136
  • 218
makerofthings7
  • 50,090
  • 54
  • 250
  • 536

1 Answers1

1

All CSRF is prevented by the use of cryptographic nonce which cannot be obtained by the attacker due to Same-Origin Policy. This is not a problem that Symmetric Cryptography can solve.

Check out the CSRF Prevention Cheat Sheet.

rook
  • 46,916
  • 10
  • 92
  • 181