How to fix: No CSRF Token Cookie Detected
The application uses session cookies but no CSRF token cookie was observed. Without CSRF protection, state-changing requests (POST, PUT, DELETE) may be triggered by cross-site requests from malicious pages.
Why it matters
Cross-Site Request Forgery (CSRF) attacks allow a malicious site to trigger state-changing actions (password change, fund transfer, account deletion) using the victim's authenticated session. SameSite=Lax mitigates most CSRF but does not cover all scenarios.
CSRF tokens provide defense-in-depth alongside SameSite cookies. A CSRF token is a per-session or per-form random value that the server verifies on every state-changing request. The token is inaccessible to attacker-controlled pages (different origin) because it is tied to the specific user's session.
How to fix it
- 1Set a CSRF token in a non-HttpOnly cookie so JavaScript can read and include it in request headers.
- 2Or use the Double Submit Cookie pattern with a signed token.
- 3Alternatively, rely on SameSite=Strict for high-privilege operations and validate the Origin header.
Code examples
CSRF token cookie (double-submit pattern)
Set-Cookie: csrf-token=<random-secure-token>; Secure; SameSite=Strict; Path=/Read and send CSRF token in requests
// Client reads CSRF token from cookie (not HttpOnly)
const csrfToken = document.cookie.match(/csrf-token=([^;]+)/)?.[1];
fetch('/api/transfer', {
method: 'POST',
headers: { 'X-CSRF-Token': csrfToken },
body: JSON.stringify({ amount: 100 }),
});References
Detected automatically by VulnRadar. The check id is cookie-no-csrf-token, stable across every scan so you can filter or diff on it.
More cookies checks
- LowCookie Domain Attribute Is Too Broad
- LowCookie Missing Secure Attribute
- InfoThird-Party Cookie Missing Partitioned Attribute
- High__Host- Prefix Cookie Missing Secure Attribute
- High__Host- Prefix Cookie with Non-Root Path
- High__Secure- Prefix Cookie Missing Secure Attribute
- LowCookie Expires/Max-Age Exceeds 1 Year
- InfoCookie Name Leaks Framework or Language
Questions
- How severe is No CSRF Token Cookie Detected?
- VulnRadar rates this medium severity in the cookies category. The severity is fixed per check, not scored per site, so the same finding is the same severity on every scan.
- Does VulnRadar check for this automatically?
- Yes. It runs as part of every scan under the check id cookie-no-csrf-token, which stays the same between runs so you can filter, diff, or gate CI on it.
- Which standards does No CSRF Token Cookie Detected map to?
- It maps to CWE-352. In the OWASP Top 10 it falls under A01:2021.
Missing a check?
The detection set is open. If you know a misconfiguration this does not catch, propose it: the issue template asks for the threat model, how to detect it, the false-positive risk, and a test fixture, which is the same thing a maintainer would have to work out anyway.