Skip to content

fix(security): self_propagation covers PHP/Ruby/PowerShell/Shell and two evasive shapes (#1172, #1174) - #2695

Merged
squid-protocol merged 1 commit into
mainfrom
fix/1171-self-propagation-coverage
Sep 3, 2026
Merged

fix(security): self_propagation covers PHP/Ruby/PowerShell/Shell and two evasive shapes (#1172, #1174)#2695
squid-protocol merged 1 commit into
mainfrom
fix/1171-self-propagation-coverage

Conversation

@squid-protocol

Copy link
Copy Markdown
Owner

Closes #1172 and #1174 (epic #1171). Both are security_lens.py's self_propagation signature — one layer, one file.

#1172 — the __FILE__ branch was dead code

The token was already accepted, but no PHP or Ruby copy/write function was ever paired with it, and __FILE__ appears only in PHP/Ruby source — which never calls shutil.copy. That half of the alternation could not match anything.

Added: PHP (copy, rename, file_put_contents/file_get_contents), Ruby (FileUtils.cp, File.write/File.read), PowerShell (Copy-Item with $PSCommandPath / $MyInvocation.MyCommand.Path), Shell (cp/install with $0) — the last two because self-copy into a startup folder or cron directory is the classic dropper persistence step.

#1174 — two evasive shapes

  • one bounded path-normalization wrapper: shutil.copy(os.path.abspath(__file__), dest)
  • read-then-write: fs.writeFileSync(dest, fs.readFileSync(__filename)) — a self-copy spelled as two calls

The precision rule is unchanged: the self-reference token must visibly, directly feed a copy/write call, never merely appear nearby. Only the routes to that call widen.

Precision

$0 is ubiquitous in usage banners and logging, so it is accepted only as a literal argument to cp/install. 11 false-positive guards cover those idioms — including cp -m 755 /src/a /dst/b, a cp whose flag takes a value, which the first draft of the flag repeat let through and a negative test caught.

Verification

  • Whole language-crucible corpus, 3366 files: zero hits before, zero hits after. The signal fires nowhere in real corpus code, so there is no golden-master movement and no bless — which is exactly the acceptance criterion Extend self_propagation language coverage: fix dead PHP/Ruby token, add PowerShell + Shell #1172 specified.
  • 9 detection cases across six ecosystems, 4 hardened-shape cases, 11 FP guards; the two detection tests fail on origin/main.
  • ReDoS detonation per new branch; every quantifier bounded.
  • Suite 7483 passed; audit_check clear (ruff baseline regenerated, pure line-shifts).

🤖 Generated with Claude Code

…two evasive shapes (#1172, #1174)

#1172 -- the `__FILE__` half of the alternation was dead code. The token was
accepted, but no PHP or Ruby copy/write function was ever paired with it, and
`__FILE__` appears only in PHP/Ruby source, which never calls `shutil.copy`.
Adds PHP (`copy`, `rename`, `file_put_contents`/`file_get_contents`), Ruby
(`FileUtils.cp`, `File.write`/`File.read`), PowerShell (`Copy-Item` with
`$PSCommandPath` / `$MyInvocation.MyCommand.Path`) and Shell (`cp`/`install`
with `$0`) -- the last two because self-copy into a startup folder or cron
directory is the classic dropper persistence step.

#1174 -- two equally worm-like shapes slipped through the
literal-first-argument rule: one bounded path-normalization wrapper
(`shutil.copy(os.path.abspath(__file__), dest)`) and read-then-write
(`fs.writeFileSync(dest, fs.readFileSync(__filename))`), a self-copy spelled
as two calls.

The precision rule from #1150/#1169 is unchanged: the self-reference token
must visibly, directly feed a copy/write call, never merely appear nearby.
Only the routes to that call widen. `$0` is accepted solely as a literal
argument to `cp`/`install`, since it is otherwise ubiquitous in usage banners
and logging -- 11 false-positive guards cover exactly those idioms, including
a `cp` whose flag takes a value (`cp -m 755 /src/a /dst/b`), which the first
draft of the flag repeat let through.

Verified over the whole language-crucible corpus (3366 files): zero hits
before, zero hits after. The signal fires nowhere in real corpus code, so
there is no golden-master movement and no bless -- which is also the
acceptance criterion #1172 asked for.

Every quantifier bounded (Engine Rule 14), with a detonation test per new
branch. Suite 7483 passed.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@github-actions

github-actions Bot commented Sep 3, 2026

Copy link
Copy Markdown
Contributor

🐦‍⬛ Muninn Security Scan

✅ No security issues found.

🐦‍⬛ Powered by Muninn · Skald Lab

@squid-protocol
squid-protocol merged commit 5748183 into main Sep 3, 2026
29 checks passed
@squid-protocol
squid-protocol deleted the fix/1171-self-propagation-coverage branch September 3, 2026 18:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Extend self_propagation language coverage: fix dead PHP/Ruby token, add PowerShell + Shell

1 participant