Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8731091
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T09:09:08+00:00 2026-06-13T09:09:08+00:00

First some context. I’ve been using nonce tokens to sign my form data in

  • 0

First some context.
I’ve been using nonce tokens to sign my form data in the same way wordpress allows to attach an action to a nonce:

// editing post id:10
$post_id = 10;
$nonce = create_nonce( 'edit-post-'.$post_id );
echo '<input type="hidden" name="post_id" value="'.$post_id.'">';
echo '<input type="hidden" name="nonce" value="'.$nonce.'">';

This allows me later to check if user is editing the post I gave him permissions to, because I reconstruct the nonce and check if the nonce that I recieve is the same I constructed:

$server_nonce = create_nonce( 'edit-post-'.$_POST['post_id'] );
if( $server_nonce != $_POST['nonce'] )
{
    echo 'bad guy...';
}

Up until now I misinterpreted this method as an anti-CSRF token that gave me CSRF protection.
As I deep in the CSRF issue I’ve found that this solution does not protect me 100% from CSRF because:

  1. The nonce can be reconstructed in server with the data received. CSRF must be not reconstructed.
  2. The nonce token will be the same for a form for a window time. CSRF must be unique at each request.

So, here’s my question:

Is it ok to use two tokens in a form to protect from CSRF and data signature? Is there any way to combine these two tokens?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T09:09:09+00:00Added an answer on June 13, 2026 at 9:09 am

    Generally, the nonce needs to be saved somewhere server-side. If you’re regenerating the nonce when validating it, it means the nonce is a predictable value based on input. That is pretty useless, since that’s a static value. It’s not a nonce.

    The way the nonce is supposed to work is:

    1. Construct the form
    2. Generate a random value, the nonce
    3. Save the nonce in the session and put it in a hidden field in the form
    4. Upon form submission, check that the submitted nonce corresponds to the one in the session

    Anything else is just a checksum of the action+post-id, which is pretty useless.

    You can easily extend this proper nonce procedure with a checksum of the to-be-submitted fields, by taking the name of all expected fields and other expected static values and adding a hash of them to the session as well. E.g.:

    sha1(join(',', array('first_name', 'last_name', $nonce)))
    

    Upon form submission, get all received field names and generate the same hash again and check if it’s identical to the one in the session. If not, somebody tampered with the form.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

First, some context: I'm a Python developer who has written a medium-sized application using
first some context for the problem: we are using SAP NetWeaver Developer Studio to
First some background..I am using the Telerik MVC Grid to display data. The grid
First of all some context : I have a form, where I post back
OK, so first some things that might be relevant: I'm using the Clang 3.1
First some context: I have an MVC3 .net project which, for the sake of
First some brief background: I have an existing ASP.NET MVC 1 application using Entity
To provide some context, I'm interested in the creation of an app which allows
I've got some soapUI tests, that use groovy scripts to first insert some data
First, some context: I'm currently working on a project in which I use the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.