Free CSRF Protection Checker
Checks for anti-CSRF tokens and SameSite cookie posture on state-changing endpoints, so attackers can't forge requests from another site.
- Anti-CSRF tokens
- SameSite strategy
- Safe methods

How to fix common failures
- Require tokens on POST/PUT/PATCH/DELETE and verify them server-side
- Use per-request tokens or double-submit with robust secrets
- Prefer SameSite=Lax by default, and use None+Secure only when needed
What this checker validates
- Presence of anti-CSRF tokens on state-changing endpoints
- SameSite cookie posture aligned with cross-site needs
Implementation examples
Once you've identified the gap, applying the fix is straightforward. Here are the three configurations developers reach for most often.
Nginx
# Harden cookies passing through the proxy so the browser
# refuses to send them on cross-site POSTs (nginx 1.19.3+).
proxy_cookie_flags ~ secure httponly samesite=lax;
# Token validation itself belongs in the application, not the proxy.Apache
# Force SameSite + Secure on session cookies.
Header edit Set-Cookie ^(.*)$ "$1; SameSite=Lax; Secure; HttpOnly"
# Reject state-changing requests whose Origin is not ours.
RewriteEngine On
RewriteCond %{REQUEST_METHOD} ^(POST|PUT|PATCH|DELETE)$
RewriteCond %{HTTP:Origin} !^$
RewriteCond %{HTTP:Origin} !^https://example\.com$ [NC]
RewriteRule .* - [F]Node.js (Express)
import express from "express"
import session from "express-session"
const app = express()
// Fail fast if the session secret is not configured.
const sessionSecret = process.env.SESSION_SECRET
if (!sessionSecret) throw new Error("SESSION_SECRET must be set")
// Without this, secure cookies are dropped when TLS terminates
// at a reverse proxy or load balancer in front of the app.
app.set("trust proxy", 1)
app.use(
session({
secret: sessionSecret,
resave: false,
saveUninitialized: false,
cookie: { sameSite: "lax", secure: true, httpOnly: true },
})
)
// Reject state-changing requests unless we can confirm a same-origin
// source. Fail closed: a missing Origin/Referer is treated as untrusted.
const ALLOWED_ORIGIN = "https://example.com"
function isSameOrigin(req) {
// Origin is exact; compare it directly (no prefix matching, so
// https://example.com.evil.com cannot slip through).
if (req.headers.origin) return req.headers.origin === ALLOWED_ORIGIN
// Fall back to Referer, comparing only its origin part.
if (req.headers.referer) {
try {
return new URL(req.headers.referer).origin === ALLOWED_ORIGIN
} catch {
return false
}
}
return false
}
app.use((req, res, next) => {
if (["POST", "PUT", "PATCH", "DELETE"].includes(req.method) && !isSameOrigin(req)) {
return res.sendStatus(403)
}
next()
})
// For per-request tokens on top of this, use a maintained library
// such as csrf-csrf. Avoid csurf - it is deprecated.Tool-specific questions
Do I still need tokens with SameSite?
Should APIs use cookies or Authorization headers?
Built for the engineers who already have enough to fix.
Real-time results
Comprehensive checks
Step-by-step fixes
More free checks, for the rest of your surface.
Complete Security Scan
Pre-Pentest Security Scan
Security Compliance Checker
WAF Checker
Security Headers Test
TLS/SSL Security Checker
Frequently asked.
What is Barrion and how does it enhance website security?
How safe is Barrion to use for security testing?
What types of security issues does Barrion identify?
What specific security checks does Barrion perform?
What is Barrion's smart crawling?
How often does Barrion perform security scans?
Is Barrion suitable for security testing of all business sizes?
How does Barrion handle data security and privacy during security testing?
What if I'm not satisfied with Barrion's security testing service?
How does Barrion help with SOC 2, ISO 27001, NIS2, and other compliance frameworks?
Anything else? Email contact@barrion.io.
Fix it once, then watch it stay fixed.
A pentest proves what is exploitable today. Continuous monitoring re-checks this tool's results on a schedule and alerts you the moment a deploy undoes the fix.
What you get for free
18 core security checks via this tool, passive scans, step-by-step remediation, security score on every result.
What Essential adds at $39/mo
+17 advanced checks, continuous monitoring, daily security score history, email alerts, GitHub SAST, board-ready PDFs, SOC 2 / ISO 27001 / PCI reports.