No, they are not the same.
Nonce prevents re-attacks (prevents the interception of the subscriber and re-submission of it later, for example, if Alice sends "Pay Bob $ 100", you do not want anyone to forward this 100 times).
CSRF aliases fix an HTML-specific vulnerability when authenticating user actions where a third-party website can submit forms with the credentials of the user viewing the site (for example, JavaScript on the evil.example.com page that submits the form to facebook.com using your browser authenticated as you).
CSRF characters must be secret, otherwise the attacker will have the missing piece necessary to fake the request.
Nonces should not be secret if they are signed with a secret request (if an attacker cannot replace one nonce with another).
You can allow requests to be repeated using CSRF tokens and still be protected from CSRF (you are interested in whether this was a deliberate action by the user, but it may not necessarily stop the user from performing it many times).
In fact, this is a very often useful property, for example. allows users to use the back button and resubmit forms with corrected values. If you implement CSRF protection using the Nonce-like mechanism, you will receive false alarms when users update the submitted pages.
An easy way to prevent CSRF without Nonces is to set the session identifier in a hidden field (not the value stored in the session, but the identifier of the session itself, the same as you save in the cookie [ session_id() in PHP]). When the form is submitted, verify that the form ID matches the cookie ID. This is sufficient for CSRF, since the attacker cannot know the value of the cookie (CSRF allows attackers to blindly send cookies).
Kornel
source share