Skip to content

fix(lint): report the scan window on the WASM XOR lints - #369

Open
DeryFerd wants to merge 1 commit into
qybaihe:mainfrom
DeryFerd:fix/wasm-xor-scan-window
Open

DeryFerd wants to merge 1 commit into
qybaihe:mainfrom
DeryFerd:fix/wasm-xor-scan-window

Conversation

@DeryFerd

@DeryFerd DeryFerd commented Dec 3, 2026

Copy link
Copy Markdown
Contributor

Summary

The two WASM XOR lints stop at 32 MiB. When a module was larger, they returned an empty report with shouldRefuseBankrupt: false and a single advice line, so a caller could not tell a clean module from one that was never examined. The report had no truncated field at all, while the other four lints that cap their input already carry one after the same fix. These two were the remaining pair.

What changed

  • src/engine/wasm-xor-mask-sidecar-lint.ts and src/engine/wasm-seal-xor-known-plaintext-lint.ts: an oversized buffer is now linted over the first 32 MiB instead of skipped, and the report gains an optional truncated: true.
  • The one-line advice names the limit and says the rest of the module was not linted, using the same wording as the other scan-window reports.
  • Refusal is unchanged. A cut window is an incomplete scan, not a finding, so shouldRefuseBankrupt stays false and a project that passes today keeps passing.
  • tests/lint-scan-window-honesty.test.ts: two new cases build a valid module just over the cap (the module header plus one oversized custom section) and assert truncated, the advice text, and that the verdict did not move.

Why it matters

Both lints exist to catch an entitlement pack that can be unmasked with no key: a masked blob stored beside its plaintext XOR mask, or a pack that puts seal.revision under a repeating mask as known plaintext. If the pack sits past the 32 MiB window, the old code returned the same object a clean module produces, down to findings: [] and looksExposed: false. A caller that checks shouldRefuseBankrupt or findings.length would ship it. The window is still a limit, and the honest thing is to say the scan was cut rather than let silence read as a pass.

Validation

npx vitest run tests/lint-scan-window-honesty.test.ts tests/wasm-xor-mask-sidecar-lint.test.ts tests/wasm-seal-xor-known-plaintext-lint.test.ts tests/wasm-xor-mask-harden-gate.test.ts tests/wasm-seal-xor-known-plaintext-harden-gate.test.ts tests/packaging-gates.test.ts tests/packaging-gate-exhaustiveness.test.ts tests/mcp-lint-wasm-xor-mask-sidecar.test.ts tests/mcp-lint-wasm-seal-xor-known-plaintext.test.ts tests/wasm-seal-walk-safety.test.ts
npx tsc --noEmit

Both new cases fail on the old reports because truncated is undefined. After the change, 33 tests pass across those files and the type check is clean.

Compatibility

Modules at or below 32 MiB produce exactly the same findings and advice as before. A larger module now carries truncated: true and an advice line that names the window; the refusal verdict is untouched, so no existing build starts failing. The report types only gain an optional field, which leaves JSON consumers and the unified gate output working without changes.

Both WASM XOR lints returned an empty, non-refusing report when the module was larger than their 32 MiB window, so a caller could not tell a clean scan from one that never ran. Scan the window and set truncated with the same wording as the other scan-window fixes (qybaihe#283, qybaihe#310, qybaihe#332); the refusal verdict is unchanged because the window, not the finding, was cut.
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