Repository navigation
Closed
Labels
appsecAgentic guardrails, prompt injection, and RCE sensorspriority: mediumscope:frontierMapped, not yet built: eras/commands/regions the burned estates don't use (Gap Atlas)supply-chainDependency firewall, manifest parsing, and CycloneDXthreat: false-negativeAccuracy tuning: Engine missed a bypass or vulnerability
Description
Part of epic #1171.
π Problem Statement
self_propagation (#1150/PR #1169) is intentionally strict: it only matches when the
self-reference token is the literal, immediate first argument to a copy/write call β nothing
between the opening parenthesis and the token but optional whitespace. That precision was the
right call to ship the first version with zero false positives, but it also means two extremely
common, equally worm-like real-world shapes slip through untouched:
- Wrapped in a path-normalization call first:
shutil.copy(os.path.abspath(__file__), dest)
orfs.copyFileSync(path.resolve(__filename), dest)β still obviously self-copying, just with
one extra normalization step the current pattern doesn't look through. - Read-then-write instead of one copy call:
fs.writeFileSync(dest, fs.readFileSync(__filename))
β reads its own bytes, writes them somewhere else. Same behavior, different call shape than a
singlecopyFileSync.
π― Objective
Extend self_propagation to catch both shapes above, without loosening the core precision rule
("self-reference token has to visibly, directly feed into a copy/write, not just appear nearby").
π οΈ Proposed Implementation
- Allow the self-reference token to appear wrapped in a small, explicit, bounded set of
normalization calls (os\.path\.(?:abspath|realpath|normpath)\(,path\.resolve\() between the
outer call's opening paren and the token β bounded alternation, not an open-ended nested-call
matcher (keep Rule 11's nested-delimiter ReDoS guidance in mind from
how_to_add_a_language.mdif the wrapper needs to tolerate its own closing paren). - Add a second alternative to the pattern for the read-then-write shape: a read call
(readFileSync/open/File.read) taking the self-reference token as its argument, appearing
as an argument to an outer write call, within the same statement. - Explicitly not in scope here: chasing the self-reference token through an intermediate
variable assignment (const me = __filename; ...; fs.copyFileSync(me, dest);). That requires
real short-range taint tracking rather than a single-statement pattern match β a bigger, fuzzier
change with real false-positive risk (the variable name could be reused/reassigned), and belongs
in its own follow-on issue if pursued.
β Acceptance Criteria
- Synthetic tests prove detection of both the wrapped-token and read-then-write shapes, across
the languages already covered by Extend self_propagation language coverage: fix dead PHP/Ruby token, add PowerShell + ShellΒ #1172 (JS/Python at minimum, plus whichever of
PHP/Ruby/PowerShell/Shell land first) - False-positive guard tests: ordinary use of
os.path.abspath/path.resolveon values that
are not the self-reference token must not fire - Verified against the full
language-cruciblecorpus: zero unintended hits before the
golden-master rebless - ReDoS timing sweep on the updated pattern, specifically probing the wrapper-tolerance
alternative for the adjacent-quantifier shape called out in Rule 14
Metadata
Metadata
Assignees
Labels
appsecAgentic guardrails, prompt injection, and RCE sensorspriority: mediumscope:frontierMapped, not yet built: eras/commands/regions the burned estates don't use (Gap Atlas)supply-chainDependency firewall, manifest parsing, and CycloneDXthreat: false-negativeAccuracy tuning: Engine missed a bypass or vulnerability
Activity
fix(security): self_propagation covers PHP/Ruby/PowerShell/Shell and β¦
squid-protocol commentedon Oct 3, 2026
Implemented by PR #2695 (merged 2026-09-03):
self_propagationin security_lens.py now accepts one bounded path-normalization wrapper (abspath/realpath/normpath/path.resolve) and the read-then-write shape. The PR said 'Closes #1174' but the issue didn't auto-close, so closing manually.