MCPSafe.io
RegistryThreatsMethodologyDocsPricingScanSign in
MCPSafe.io

Security checks for MCP servers — public packages and private repos, fast or deep.

Legal

Privacy PolicyCookie PolicyTerms of ServiceSecurity disclosure

Resources

State of MCP SecuritySupportSystem statusMade in Germany 🇩🇪

© 2026 MCPSafe. All rights reserved.

GDPR — Privacy Policy
← Threat Catalog

Configuration & Environment

CSRF protection missing on state-changing routes

MEDIUMCWE: CWE-352Rule: MCP-235

MCP server exposes POST/PUT/DELETE/PATCH routes without CSRF middleware — a malicious site can trigger state changes through the user's authenticated browser session.

What it is

CSRF (Cross-Site Request Forgery) lets a third-party page trick the user's browser into sending a state-changing request to a domain where the user is logged in. Browsers send cookies automatically, so the request looks authentic from the server's perspective. The defense is to require an unguessable token (CSRF token, double-submit cookie, or `SameSite=Strict` cookies) that a cross-site request can't forge.

Why it matters for MCP

Hosted MCP servers with web admin surfaces are the natural target. A user logs in, goes about their day, then visits an unrelated page that issues a `POST /admin/destroy_all_keys` to the MCP server's domain. Cookies ride along, the server processes the request, the user has no idea.

Vulnerable example

example.js
1
import express from "express";
2
const app = express();
3
4
app.post("/admin/delete_user", (req, res) => {
5
  // No CSRF token check — accepts cross-site POSTs.
6
  deleteUser(req.body.userId);
7
  res.sendStatus(204);
8
});

Secure example

example.js
1
import express from "express";
2
import csrf from "csurf";
3
4
const app = express();
5
const csrfProtection = csrf({ cookie: { httpOnly: true, secure: true, sameSite: "strict" } });
6
7
app.post("/admin/delete_user", csrfProtection, (req, res) => {
8
  deleteUser(req.body.userId);
9
  res.sendStatus(204);
10
});

How MCPSafe detects this

MCPSafe flags state-changing route handlers (POST/PUT/PATCH/DELETE) when no CSRF middleware is detected file-wide (`csurf`, `csrf-csrf`, `lusca.csrf()`, `flask_wtf.csrf.CSRFProtect`, `fastapi-csrf-protect`, etc.) and no `X-CSRF-Token` / `SameSite=Strict` cookie pattern is present.

See the full threat catalog for every documented detection.

Further reading

  • CWE-352: Cross-Site Request Forgery
  • OWASP CSRF Prevention Cheat Sheet

Scan an MCP server for this issue

MCPSafe runs this check — and every other rule in the catalog — on any MCP server you paste in.

Scan now