VNX-1275: Sensitive Cookie with Improper SameSite Attribute
A cookie is configured with SameSite=None, or with the SameSite attribute switched off, so the browser attaches it to cross-site requests and a session cookie becomes usable for cross-site request forgery. Reported in JavaScript/TypeScript: a sameSite: 'none' (any case, any quote, quoted or bare key) or sameSite: false property in cookie options (res.cookie, express-session, cookie-session, cookie.serialize and similar option objects, on the call line or on its own line), an assignment such as req.session.cookie.sameSite = 'none', and a Set-Cookie header or document.cookie string containing SameSite=None. Python: SESSION_COOKIE_SAMESITE, CSRF_COOKIE_SAMESITE, LANGUAGE_COOKIE_SAMESITE or REMEMBER_COOKIE_SAMESITE set to None, False or "None" in any case (Django settings, Flask app.config[...] or config.update(...)), and set_cookie()/set_signed_cookie() calls with samesite=None or samesite="none" (on the call line or a continuation line of it), and Starlette/FastAPI SessionMiddleware with same_site="none". Not reported: Lax, Strict or true, a value computed at run time, a TypeScript type that lists 'none' among the allowed values, a set_cookie method signature whose parameter defaults to None, comparisons, the text inside comments and string literals, and test files. SameSite=None is sometimes required for a cookie used in a cross-site embed; such a cookie must not carry a session or credential.
| Field | Value |
|---|---|
| Rule ID | VNX-1275 |
| Severity | Medium |
| SARIF level | warning |
| Kind | sast |
| Languages | JavaScript / TypeScript, Python |
| CWE | CWE-1275 |
| CAPEC | CAPEC-66 |
| ATT&CK | T1190 |
| CWSS vector | CWSS:1.0/TI:M/AP:A/AL:A/IC:N/FC:LT/RP:N/RL:A/AV:I/AS:N/IN:A/SC:A/BI:M/DI:H/EX:M/EC:N/P:C |
| Tags | samesite cookie csrf cwe-1275 |
| Source | internal/sast/rules/vnx-1275.rego |
Overview
VNX-1275 maps to CWE-1275: Sensitive Cookie with Improper SameSite Attribute.
Why This Matters
With SameSite=None, or with the attribute switched off, the browser attaches the cookie to requests that other sites start. A session cookie sent this way lets a malicious page make authenticated requests on the user’s behalf (cross-site request forgery).
What Gets Flagged
res.cookie('session', token, { httpOnly: true, secure: true, sameSite: 'none' });
app.use(session({ cookie: { sameSite: false } }));
res.setHeader('Set-Cookie', 'sid=' + sid + '; HttpOnly; SameSite=None');
SESSION_COOKIE_SAMESITE = None
resp.set_cookie("userid", user.id, samesite=None, secure=True)
Not flagged: 'lax', 'strict', true, a value read from configuration at run time, test files.
Remediation
- Use
SameSite=Lax(orStrict) for session and credential cookies. - Keep
SameSite=None; Securefor cookies that must work in a cross-site embed and that carry no credential.
References
Suppressing this rule
Put a nosec comment on the line, or on line 1 to cover the whole file. Use the comment marker of the file’s language (#, //, -- or ;):
# nosec vnx-1275
// nosec vnx-1275
Or record an ignore rule: vulnetix ignore add --rule vnx-1275 --reason "...". See Suppressing findings.