Repository navigation
Prove the engine blocks what the platform generated - #187
Merged
Merged
Conversation
Link 3, and the half of the canary's claim this repository owns: the platform proves "this reviewed recipe plus this map produces these exact rule bytes", and this proves those exact bytes block the exploit and allow a benign control. Neither is worth anything alone — a rule generated correctly and never fired is the defining defect of this product, and it is invisible from the side that generated it. The artifact is VENDORED, not rebuilt. Nothing here parses a recipe, evaluates a detector or binds a coordinate: `rule_v2` and `when` go into the bundle verbatim, exactly as the guard receives them from the rules endpoint. A second implementation of the binding would recreate the duplicate-implementation seam the canary exists to catch, and both sides could then be wrong together. CVE-2017-5941, with the published exploit shape rather than a string lifted from the signature — `_$$ND_FUNC$$_function(){ require("child_process")... }()` is what this vulnerability is actually exploited with, and a payload copied out of the regex would only prove the regex matches itself. Four engine assertions, each load-bearing, confirmed by mutating the handover: exploit blocked wrong parameter → 3 fail; signature widened → still blocks benign request allowed signature widened to /./ → 1 fails another endpoint untouched scope removed → 2 fail; scope on another route → 3 fail dry-run detects without blocking the mode a site starts in; if it blocked, adopting protection would be a traffic change rather than an observation Three more check the handover itself, so a hand-edited artifact cannot pass: the checksum must match its own rule bytes, the recipe hash must be present, and the rule must be scoped and bound. ## Against the built engine, and against what shipped `dist/protect.js` is what an application loads. Testing `src/` would prove the source blocks the exploit and say nothing about the bundle, and the bundler is a real failure surface — an export dropped, a branch shaken out, an edge build diverging. So the PR check runs after the build, and the publish workflow runs the same suite twice: once on the build about to ship, and once on the engine unpacked from the PUBLISHED tarball, via `PS_CANARY_ENGINE`. The second is the only proof that covers packaging: a file left out of `files`, a wrong `exports` map or a bad entry point produces an artifact that passes every local check and cannot protect an application. After the publish rather than before, because the tarball does not exist until then — a failure there cannot unpublish the version, but not knowing is worse. Verified against the real registry: the published 0.3.31 engine blocks the exploit and allows the control. `PS_REQUIRE_CANARY` turns a skip into a failure, following the packaged-bin check. A plain checkout has no `dist/`, so skipping is honest there — but in CI a skipped canary reads exactly like a passing one, and this is the check that proves a generated rule blocks a real exploit. Verified both ways: it refuses to skip with the flag set, and without it the three artifact-integrity tests still run. The fixture ships nowhere: `npm pack --dry-run` finds no match for it. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
|
Comprehensive canary tests ensure the built and published engine block the exploit. 🎯 Quality: 100% Elite · 📦 Size: Medium 📈 This month: Your 146th PR — above team average · Averaging Excellent |
Contributor
Author
|
/review |
daniloradovic
approved these changes
Aug 27, 2026
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.
Link 3 of 3. The chain is now closed end to end.
The platform proves "this reviewed recipe plus this map produces these exact rule bytes". This proves those exact bytes block the exploit and allow a benign control. Neither is worth anything alone — a rule generated correctly and never fired is the defining defect of this product, and it is invisible from the side that generated it.
The artifact is vendored, not rebuilt
Nothing here parses a recipe, evaluates a detector, or binds a coordinate.
rule_v2andwhengo into the bundle verbatim, exactly as the guard receives them from the rules endpoint. A second implementation of the binding would recreate the duplicate-implementation seam the canary exists to catch, and both sides could then be wrong together.The exploit is the published shape —
_$$ND_FUNC$$_function(){ require("child_process")... }()— not a string lifted from the signature. A payload copied out of the regex would only prove the regex matches itself.Every assertion is load-bearing
Confirmed by mutating the handover:
/./Four engine assertions: exploit blocked, benign allowed, another endpoint untouched (the scope is real, not decoration), and dry-run detects without blocking — the mode a site starts in; if it blocked, adopting protection would be a traffic change rather than an observation.
Three more check the handover itself so a hand-edited artifact cannot pass: the checksum must match its own rule bytes, the recipe hash must be present, and the rule must be scoped and bound.
Against the built engine, and against what shipped
dist/protect.jsis what an application loads. Testingsrc/would prove the source blocks the exploit and say nothing about the bundle — and the bundler is a real failure surface: an export dropped, a branch shaken out, an edge build diverging.So, per your ruling:
dist/protect.jsfrom this checkout.PS_CANARY_ENGINE.The second is the only proof that covers packaging: a file left out of
files, a wrongexportsmap or a bad entry point produces an artifact that passes every local check and cannot protect an application. It runs after the publish because the tarball does not exist until then — a failure there cannot unpublish the version, but not knowing is worse. It retries the registry fetch and reports an install failure as unverified, never as a pass.Verified against the real registry: the published 0.3.31 engine blocks the exploit and allows the control.
PS_REQUIRE_CANARYturns a skip into a failure, followingbin-invocation. Verified both ways: it refuses to skip with the flag set, and without it the three artifact-integrity tests still run. The fixture ships nowhere —npm pack --dry-runfinds no match.Full suite: 1683 passed, 7 skipped; typecheck and template typecheck clean.
🤖 Generated with Claude Code