VNX-1275: Sensitive Cookie with Improper SameSite Attribute
A cookie is configured with SameSite=None, or with the SameSite attribute switched off.
| 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.