Repository navigation
feat(security): build a narrow GlassWorm-style detector for obfuscation_flag - #1169
Merged
Merged
Conversation
…on_flag (#1150) Resolves #1150's deferred design decision (#369): rather than formally deprecating the always-0 obfuscation_flag column, adds two deliberately narrow lexical proxies to security_lens.py's THREAT_SIGNATURES, scoped to keep both false positives and false negatives low: - unicode_steganography: a RUN of 3+ consecutive Unicode Variation Selector/Tag codepoints -- the actual invisible-payload-encoding technique GlassWorm used. A single codepoint (common emoji presentation, e.g. "heart"+VS16) is explicitly excluded; only a run has no legitimate source-code use. - self_propagation: a self-file-reference token (__filename/__file__/ import.meta.url/etc.) passed as the literal first argument to a copy/write/rename call -- the mechanical signature of a worm duplicating or overwriting itself. Excludes bare self-reads and loose same-file proximity matches, both common benign idioms. Both signals verified at zero hits across the full 1118-file language-crucible corpus (44+ languages) before blessing the golden master baselines, so the corpus-wide diff is purely the two new zero-value schema columns, not behavior drift. Does not attempt the multi-file/manifest-correlation angle (install-script + registry-publish sequences) from the issue -- that needs execution/temporal semantics this AST-free engine doesn't have, and forcing it would be the overreach the issue itself warns against. Co-Authored-By: Claude Sonnet 5 <[email protected]>
Contributor
This was referenced Aug 9, 2026
Closed
squid-protocol
added a commit
that referenced
this pull request
Sep 3, 2026
…two evasive shapes (#1172, #1174) (#2695) #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: Joe Esquibel <[email protected]> Co-authored-by: Claude Opus 5 (1M context) <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Resolves #1150's deferred design decision (originally deferred in #369): rather than formally
deprecating the always-
0obfuscation_flagcolumn, this builds a real (deliberately narrow)detector so the acceptance criteria's "build" path is satisfied without overreaching what a
regex-based, AST-free engine can credibly claim.
Two independent lexical proxies added to
security_lens.py'sTHREAT_SIGNATURES, eithersufficient to set
obfuscation_flag = 1:unicode_steganography— a run of 3+ consecutive codepoints from the Unicode VariationSelector / Variation Selector Supplement / Tags blocks. This is the actual invisible-payload
encoding technique the real GlassWorm npm campaign used. A single codepoint (ordinary emoji
presentation, e.g. the VS16 in "❤️") is deliberately excluded from matching — only a run has
no legitimate source-code use, since a useful hidden payload necessarily needs many consecutive
invisible codepoints to encode anything.
self_propagation— a self-file-reference token (__filename/__dirname/import.meta.urlin JS,__file__in Python,__FILE__in PHP/Ruby) passed as the literalfirst argument to a copy/write/rename call (
fs.copyFileSync,shutil.copy,os.rename,etc.) — the mechanical signature of a worm duplicating or overwriting itself. Deliberately
excludes bare self-reads (
open(__file__), common for version banners) and loose "self-refanywhere near a write" proximity windows (too FP-prone against ordinary path-resolution idioms
like
path.dirname(__filename)) — only the unambiguous "self-path handed straight into amutating call" shape qualifies.
Explicitly not attempted: the multi-file/manifest-correlation angle from the issue
(install-script + registry-publish sequences spanning files). That needs execution/temporal
semantics this AST-free engine doesn't have — forcing it would be the overreach the issue itself
warned against.
Why the golden master changed
Both signals are new
SIGNAL_SCHEMAentries (appended at the end, not inserted mid-list, toavoid reindexing the K-Means archetype classifier's positional feature vector), so every scanned
file gains two new schema columns. I verified actual hit counts are zero across the full
1118-file
language-cruciblecorpus (44+ languages) before blessing the baseline viaupdate_golden_master.py— the corpus-wide diff (1873 differences) is purely the two newzero-value columns appearing everywhere, not behavior drift.
crucible_check.pypasses clean onboth full-precision and zero-dependency modes after the rebless.
Test plan
security_lens.pytests: both signals fire on synthetic malicious code (self-copy,self-overwrite, JS/Python variants, a hidden Unicode payload run) and do not fire on
realistic benign code (ordinary emoji text,
path.dirname(__filename),open(__file__)self-reads, unrelated
os.renamecalls)test_record_keeper.pyupdated:obfuscation_flagnow reads1whensec_self_propagation/sec_unicode_steganographyfire, replacing the old hardcoded-0assertion
audit_check.py: ruff/mypy/dead-key all clear (baseline regenerated for pure line-shifts)crucible_check.py: PASS on both full-precision and zero-dependency modes🤖 Generated with Claude Code