Skip to content

Instantly share code, notes, and snippets.

@zbigniewTomczak
Last active December 14, 2015 11:58
Show Gist options
  • Save zbigniewTomczak/5082546 to your computer and use it in GitHub Desktop.
Save zbigniewTomczak/5082546 to your computer and use it in GitHub Desktop.
nonce

nonce

nonce - number user once

prevents replay attacks, semantic URL attacks

nonce = md5(actionName + itemId + userid + timestamp + salt);

<a href="/items/delete?item=7243&nonce=$nonce&timestamp=$timestamp">delete item</a>
  • On request recreate nonce.
  • Before action check for expiration (timestamp).
  • Used nonce insert into databse(nonce, timestamp). Before action check that nonce is NOT in the database.
  • CLear expired nonces from the database.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment