Finding

2FA form lacks a CSRF token

warningWebsite security2fa-bypass/2fa_form_no_csrfGenerated from the catalogue

This page is generated from the scanner's own catalogue. A fuller explanation — how to check it yourself, and fixes for common platforms — is being written.

In short

The scanner found a form containing a one-time-password / 2FA field but no hidden anti-CSRF token (no input named like csrf, _token, xsrf, authenticity, or nonce). Without one, the 2FA submission can be forged from an attacker-controlled page, letting a victim's browser unknowingly submit a 2FA verification request. This undermines the protection 2FA is meant to provide.

How to fix it

Add a hidden, server-validated CSRF token to the 2FA form and set SameSite cookies on the session.

Fix it with your coding agent

Prompt for Claude Code, Cursor or Codex

An Ingati scan of my website reported “2FA form lacks a CSRF token” (finding 2fa-bypass/2fa_form_no_csrf, severity warning). Find where this comes from in this codebase or the server configuration, fix it, and explain what you changed. The scanner's guidance: Add a hidden, server-validated CSRF token to the 2FA form and set `SameSite` cookies on the session. Then tell me how to confirm the fix, so the next scan shows it as fixed.

How Ingati finds it

This is one of the Website security checks, and it runs on every scan. When Ingati finds the problem, your report lists it as warning, with where it was found and what the scanner saw. Later scans show it as fixed once it is gone.

Ingati checks this and thousands of other things on every scan.

Start scanning