replay: fail closed when the pack carries no usable binding - #2
Open
inventor1975 wants to merge 1 commit into
Open
inventor1975 wants to merge 1 commit into
inventor1975 wants to merge 1 commit into
Conversation
`veip-verify replay pack.json` could report PASS on a tampered pack.
execution.outcome.result_ref is typed in the schema as
{"type": "string", "minLength": 1}, so any string validates.
_extract_binding_from_pack() returns None for a string that is not
sha256:<64 hex>, verify_integrity_binding() defaulted to
require_binding=False, and the CLI only set it True with --require-binding.
So overwriting the carrier — the very field that protects the pack —
turned tamper detection off:
before: $ veip-verify replay pack.json
exit=0 PASS replay: no binding present (not required)
after: $ veip-verify replay pack.json
exit=2 FAIL replay: binding carrier is not a sha256 digest:
execution.outcome.result_ref = 'ref://opaque-store/result-1'
after: $ veip-verify replay pack.json --allow-missing-binding
exit=0 PASS replay: NOT VERIFIED: binding carrier is not a
sha256 digest: ...
The pack in all three runs is schema-valid, has one field changed
(policy.policy_version) and its result_ref rewritten to a plausible opaque
reference.
Changes, all inside the verifier — the schema and the protocol are untouched:
* CLI defaults to requiring the binding; --allow-missing-binding is the
explicit opt-out. --require-binding is still accepted as a no-op so
existing scripts keep working.
* An absent carrier and a malformed one are now reported differently.
Reporting a rewritten carrier as "no binding present" hid the difference
between a pack that never claimed a binding and one whose binding was
overwritten.
* When the check is skipped, the reason starts with NOT VERIFIED, because
that string is what a reader sees next to PASS.
* README documents the default and the opt-out.
This makes the code match what the README already states the tool does:
"Integrity binding verification (hash verification / tamper detection)".
tests/test_binding_carrier.py fails on the unpatched code (3 of its 5 cases)
and passes with this change; the existing suite passes unchanged.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
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.
This is the finding reported to Arkadiy on 2026-09-19, with the fix and a regression test.
The problem
veip-verify replay pack.json— the default invocation — could report PASS on a tampered pack.execution.outcome.result_refis typed in the schema as{"type": "string", "minLength": 1}, so any string validates._extract_binding_from_pack()returnsNonefor a string that is notsha256:<64 hex>;verify_integrity_binding()defaulted torequire_binding=False; and the CLI set itTrueonly with--require-binding. So overwriting the carrier — the field that protects the pack — turned tamper detection off, and the result read as an ordinary pass.Reproduction: take
tests/fixture_pack.json, change one schema-valid field (policy.policy_version), rewriteresult_reftoref://opaque-store/result-1. The pack still validates.The integrity check itself is sound — with a genuine binding in place the same tampered pack already fails with
binding mismatch. What was missing was that the check could be opted out of by editing one field, silently.What this changes
Everything is inside the verifier. The schema and the protocol are untouched —
result_refmay still legitimately be an opaque pointer rather than a digest, so this does not constrain it.--allow-missing-bindingis the explicit opt-out.--require-bindingis still accepted as a no-op so existing scripts keep working.NOT VERIFIED— that string is what a reader sees next to PASS.This makes the behaviour match what the README already states the tool does: "Integrity binding verification (hash verification / tamper detection)".
Tests
tests/test_binding_carrier.py— 5 cases. Three of them fail on the unpatched code and pass with this change; the other two guard against over-tightening (the intact fixture still passes,--require-bindingstill accepted). The existing suite passes unchanged: 11 passed.Alternative you may prefer
Constraining the schema instead —
"pattern": "^sha256:[0-9a-f]{64}$"onresult_ref— would also close it, in one line. I did not take that route because it decides a protocol question that is yours: whetherresult_refis always a binding digest or may be a general result reference. Happy to switch if that is the intended semantics.Prepared with Claude (Opus 5); reviewed and submitted by Vitaly Reznik.