Skip to content

fix(js-shield): keep forbidden anti-deblinding markers out of emitted identifiers - #365

Open
DeryFerd wants to merge 1 commit into
qybaihe:mainfrom
DeryFerd:fix/js-shield-forbidden-markers
Open

DeryFerd wants to merge 1 commit into
qybaihe:mainfrom
DeryFerd:fix/js-shield-forbidden-markers

Conversation

@DeryFerd

@DeryFerd DeryFerd commented Dec 2, 2026

Copy link
Copy Markdown
Contributor

The identifier generator documented a guarantee it could not always keep. realisticIdentifier builds camel, private-camel and pascal names from a hint, and callers derive that hint from customer identifiers such as $1, _0x1f or _blaFoo. The hint sanitiser stripped non-word characters but deliberately kept underscores, so a customer name starting with _bla could come back as a __bla… decoy (and $00_AAAThing as a $...AAA name) — precisely the greppable substrings the anti-deblinding catalog keys on. assertNoForbiddenMarkers already existed for this, was even imported by the AST shield, and was never actually called.

What changed

  • realisticIdentifier in src/core/identifiers.ts now strips the forbidden markers (_bla, $00_AAA) out of a customer-derived hint before it is composed into a name, so the emitted identifier can no longer carry one in from a customer variable.
  • Every name the generator returns passes through assertNoForbiddenMarkers before it leaves, so the documented guarantee is enforced and a future vocabulary change that reintroduces a marker fails closed instead of shipping.
  • The now-unused import in src/shields/javascript/ast-shield.ts is removed.
  • tests/core-domain.test.ts gains a case that feeds _blaSecret, __blaHidden, $00_AAAThing and _bla_snake hints and asserts none of the emitted names leak a marker.

Why this matters

The whole point of the realistic-identifier pass is that a hardened artifact carries no stable string a static de-blinding tool can key on. A customer identifier is attacker-adjacent input to that pass, so the guarantee has to hold for it too, not just for the built-in vocabulary.

Tests

  • npx vitest run tests/core-domain.test.ts tests/prng-derive.test.ts tests/class-rename-opaque-seed.test.ts tests/anti-deblind-decoy-scrub.test.ts tests/js-shield-cjs-named-exports.test.ts passes, 35 tests.
  • The new assertion fails against the previous generator under a _bla hint, which is how the leak was reproduced.

Compatibility

Names built from the built-in vocabulary are unchanged, since those hints never contained a marker to strip. Only a hint that carried a marker changes, and it changes for the better.

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.

1 participant