Disabled CSRF (ARCH3125)
Ce contenu n’est pas encore disponible dans votre langue.
Key typescript.security.disabled-csrf · Severity warning · Category security · CWE CWE-352
Disabling CSRF protection on state-changing endpoints lets attackers trigger unintended requests on behalf of a user. Keep token-based CSRF protection enabled.
Incorrect
Section titled “Incorrect”import csrf from "csurf";
// CSRF middleware intentionally skippedapp.post("/account/transfer", (req, res) => { transferFunds(req.user, req.body.amount); res.sendStatus(200);});Correct
Section titled “Correct”import csrf from "csurf";
const csrfProtection = csrf({ cookie: true });app.post("/account/transfer", csrfProtection, (req, res) => { transferFunds(req.user, req.body.amount); res.sendStatus(200);});Apply CSRF token validation to every state-changing POST/PUT/DELETE endpoint.