Repository navigation
Add the redirect taint kind, and connect session stores to their reads - #14158
Conversation
|
Plugin API changelog: psalm/psalm-plugin-api#10 |
f9a7e29 to
c813fa0
Compare
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.
Comment @cursor review or bugbot run to trigger another review on this PR
Reviewed by Cursor Bugbot for commit c813fa0. Configure here.
| // what is stored in the session is trusted by the requests that read it back | ||
| if ($expr->var instanceof Variable | ||
| && $expr->var->name === '_SESSION' | ||
| && ($taint_flow_graph = $statements_analyzer->taint_flow_graph) |
There was a problem hiding this comment.
Session taint ignores suppression
Medium Severity
New $_SESSION assignment logic wires sinks through taint_flow_graph instead of getTaintFlowGraphWithSuppressed(). When TaintedInput is suppressed, sibling GLOBALS taint is skipped but session sinks and paths are still recorded, so TaintedSession can appear despite the intended suppression.
Reviewed by Cursor Bugbot for commit c813fa0. Configure here.
There was a problem hiding this comment.
Fixed: the session sink now uses getTaintFlowGraphWithSuppressed(), with a test where a tainted argument reaches $_SESSION inside a function suppressing TaintedInput.
✅ Performance: unchanged · Types: unchanged · Taint: +1 −1
How to read this table
✅ symfony: issues +1 −1Memory 3 605 → 3 605 MB (<0.1 %) · Wall 262.1 → 260.8 s (−0.5 %) Taint 1 491 → 1 491 (+1 −1)
Added (1)
Removed (1)
composer.json changed in this PR, so head dependencies were re-resolved; memory and time deltas are informational. head 6346a0d · base 805b192 (merge-base) · workflow run |
5ca0931 to
bb824c0
Compare
A Location header given to header() is a redirect sink (TaintedRedirect, CWE-601) rather than a header one, unless what follows Location: fixes the server. What is stored in $_SESSION is a session sink (TaintedSession, CWE-501).
bb824c0 to
2b1b56b
Compare
…eader A Location header sinks url_component and url_path besides redirect, and a start fixing the server removes redirect as it removes ssrf, so a value after it is reported as TaintedUrlComponent or TaintedUrlPath instead of nothing. A path from the root followed by a query or fragment also removes url_path.
# Conflicts: # tests/TaintTest.php
…reporting every store The session taint kind and TaintedSession are removed: a value stored under a key flows into the reads of that key, wherever they are, and is reported by the sink that consumes it, which decides the escaping it needs.
…es, MatchesPattern (#10) * 0.4.8: CodeIssue::CWE_IDS and the redirect and session taint kinds (vimeo/psalm#14156, vimeo/psalm#14158) * Add the new security issues and MatchesPattern
The commits of this branch, applied again on top of redirect-session-taint-kinds, which replaced the session sink by a store of the session and reports URL syntax after the fixed server of a Location header.
The commits of this branch, applied again on top of url-host-allowlist and redirect-session-taint-kinds. A restricting pattern no longer validates a value for the session: what is read back from it is checked against what reads it.
…yntax a redirect to a fixed server takes Under the session store of vimeo/psalm#14158, SessionInterface::set() stores into the attributes that get(), all() and remove() read back, so a stored value is reported where it is used, not where it is stored. Redirect sinks also take url_component and url_path.
…he session to its reads Session reads are already sources, so what is stored in the session is reported where it is read and used: the session sinks are dropped, as vimeo/psalm#14158 dropped the session taint. Redirect sinks also take url_component and url_path.
Under vimeo/psalm#14158 a value stored in the session is reported where it is read back, not where it is stored.
…t the secure flag RedirectResponse and AbstractController::redirect() take redirect sinks (TaintedRedirect), the values SessionInterface::set() stores session sinks (TaintedSession), and Cookie::create(), new Cookie() and withSecure() with secure: false are reported as InsecureCookie. Needs the Psalm release with vimeo/psalm#14158 and #14160.


Open redirects
Psalm reports a user-chosen
Locationheader as a header injection, even when the server of the URL is fixed.Before
After
Session
Psalm doesn't connect what is stored in
$_SESSIONto what reads it back.Before
After
@psalm-taint-sink redirectlets plugins mark the redirects of frameworks.