Skip to content

Only the last csrfToken generated will be valid #11

Description

@chr15m

If any token other than the last call to req.csrfToken() is passed it fails. In a situation where multiple clients are loading the page and each getting a token this means most form submissions will fail, because only the client last loading the page will have a valid csrf token.

To replicate:

  1. Run your example server.
  2. Verify you can submit correctly.
  3. Reload the page (so csrfToken is set again).
  4. Without submitting, open a new tab (so a new csrfToken is generated).
  5. Now go back to the first tab and submit.
  6. Observe the error as the csrf check things the first token generated is now invalid.

Maybe I'm missing something obvious but it seems to me this renders the library as not fit for purpose.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions