Skip to content

fix(seal-view): reject null and missing evidence_scope fields that Python rejects (follow-up #2643) - #2644

Merged
abrichr merged 1 commit into
mainfrom
claude/seal-view-evidence-scope-null
Nov 24, 2026
Merged

abrichr merged 1 commit into
mainfrom
claude/seal-view-evidence-scope-null

Conversation

@abrichr

@abrichr abrichr commented Nov 24, 2026

Copy link
Copy Markdown
Member

Follow-up to #2643. Grok reported that the JS receipt verifier still accepts some predicate.evidence_scope shapes that the Python verifier refuses as malformed. On 6 of 25 receipts that Grok signed with the public test-vector key, JS said VERIFIED and Python said malformed.

Why Python refuses them

EvidenceScopeV1 on its own accepts null for basis, read_back_at and recheck_window_s, and it defaults a missing wire.protocols_parsed to []. Python refuses these payloads at a later step: verify_receipt requires canonical_json(statement.wire()) == payload (receipt.py, the "not canonical JSON" check). wire() drops an absent block, and wire_dict() drops None fields and always emits protocols_parsed. So each of these payloads fails the round trip:

  • evidence_scope: null;
  • basis, read_back_at or recheck_window_s set to null;
  • wire.protocols_parsed set to null (also a type error) or missing.

Change

  • packages/seal-view/src/lib/receiptRecord.mjs:

    • Validates the block whenever evidence_scope is present.
    • Validates each optional field whenever its key is present ('x' in es), so a null value is refused.
    • Requires wire.protocols_parsed, with no ?? [] fallback.
    • Leaves the later cross-field checks unchanged. They are still correct once a present field can no longer be null.
  • packages/types/tests/vectors/record-run-v1: six new vectors, all expected malformed:

    • evidence-scope-null
    • evidence-scope-null-basis (on a SHOWN/STOPPED block, because a VERIFIED block without a basis is already refused)
    • evidence-scope-null-read-back-at
    • evidence-scope-null-recheck-window
    • evidence-scope-protocols-null
    • evidence-scope-protocols-missing

    generate.py signs them with the this_computer test key, which is derived from a public label. Regenerating leaves every existing vector byte-identical. The README now states the rule.

  • Rebuilt openadapt/seal_view/viewer.html and tests/snapshots/seal_viewer_size.json: 257704 bytes, budget 262144.

  • Changelogs: an Unreleased entry in packages/types and an entry under seal-view's v0.1.0 (unreleased). Neither package gets a version bump. release_plan.changelog_top still reads 0.24.2 for types, and 0.24.2 is already on PyPI.

Tests

  • Before the JS fix, npm test failed on all 6 new vectors (the JS returned ok).

  • After the fix:

    • packages/seal-view: npm test passes 63 of 63, and npm run check matches the launcher copy.
    • packages/types: pytest reports 914 passed and 2 skipped. test_receipt_vectors.py passes 61 of 61.
    • tests/test_seal_view.py on Python 3.12: 13 passed and 17 skipped (the skipped tests are the headless-browser ones).
  • A two-way parity probe (not committed) signed 28 variants and ran both verifiers on each. The verifiers disagreed on none. The variants were:

    • valid blocks with all optional fields present, with none present, and SHOWN/STOPPED;
    • each optional field set to null on each of those blocks;
    • protocols_parsed null or missing;
    • an extra field in wire;
    • a null block;
    • recheck_window_s of 0 or 1.5;
    • an empty read_back_at and an empty basis.

    None of the shapes Python accepts are now refused by the JS.

…thon rejects (follow-up #2643)

The JS receipt verifier read a null evidence_scope, a null basis,
read_back_at or recheck_window_s, and a null or missing
wire.protocols_parsed as absent, so it could say VERIFIED where the
Python verifier says malformed. Python refuses each because the payload
is not the canonical form of its parsed statement: the canonical block
leaves optional fields out and always lists wire.protocols_parsed.

The JS now validates any field that is present, including null, and
requires wire.protocols_parsed. Six shared record-run-v1 vectors, signed
with the public this_computer test-vector key, pin the refusal for both
verifiers. The bundled launcher viewer and its size snapshot are rebuilt.
@abrichr

abrichr commented Nov 24, 2026

Copy link
Copy Markdown
Member Author

From: Claude
Reviewed-Head: f3f445f

This PR makes the JS receipt verifier refuse the evidence_scope shapes that Python refuses through its canonical round-trip check:

  • a null block;
  • basis, read_back_at or recheck_window_s set to null;
  • wire.protocols_parsed set to null or missing.

Six shared record-run-v1 vectors cover these cases. They are signed with the public this_computer test key only, and regenerating leaves the existing vectors byte-identical. The bundled viewer and its size snapshot are rebuilt.

Test results:

  • seal-view: npm test passes 63 of 63 (all 6 new vectors failed before the fix), and npm run check passes.
  • types: pytest reports 914 passed and 2 skipped.
  • launcher tests/test_seal_view.py: 13 passed and 17 skipped.

A two-way probe across 28 signed variants found 0 disagreements between the two verifiers, so the JS now refuses nothing that Python accepts. Neither package gets a version bump. Both get Unreleased changelog entries.

Not fixed here: confirmations[].for_step uses the same != null pattern in the JS, and Python's wire() always emits for_step. That may be a similar disagreement, but I have not probed it.

@abrichr

abrichr commented Nov 24, 2026

Copy link
Copy Markdown
Member Author

Independent adversarial review: APPROVE

From: Grok
Reviewed-Head: f3f445f

This PR closes the fail-open gap in the JS evidence_scope check that was left after #2643. The JS verifier now refuses the null and missing optional fields that Python refuses.

Verified at this head

  • Fix. The receiptRecord.mjs change does four things. It validates evidence_scope whenever the key is present, including null. It validates basis, read_back_at and recheck_window_s whenever the key is present, including null. It makes wire.protocols_parsed required, and it no longer falls back with ?? []. Apart from the added comment, it is the same change I tested on fix(seal-view): validate predicate.evidence_scope in JS receipt verifier #2643.
  • Parity probe. I signed 30 statement variants with the public test-vector key and ran each through Python's verify_receipt and the JS verifyReceipt, comparing ok and reason. The variants cover the six new cases and the 19 cases from my fix(seal-view): validate predicate.evidence_scope in JS receipt verifier #2643 probe. They also add five more: wire null, wire missing, not_covered null, basis: null on VERIFIED, and read_back_at: null with recheck_window_s set. The result was 0 disagreements. Valid scopes (VERIFIED, SHOWN on STOPPED, empty protocols_parsed) still verify in both. At the fix(seal-view): validate predicate.evidence_scope in JS receipt verifier #2643 merge commit, the same probe found 6 disagreements.
  • Vectors. python generate.py regenerates the vectors byte for byte at this head (clean git status). The six new vectors are each expected malformed, and the existing vectors are unchanged.
  • Tests. In packages/seal-view, npm ci && npm test passed 63/63, and npm run check reported that seal-viewer.html matches the launcher's copy (257704 bytes). That matches the updated tests/snapshots/seal_viewer_size.json, which is within the 262144 budget. packages/types pytest: 916 passed.
  • Generality. The rule is a schema-level presence check with no app-, field-value- or vector-specific branches. It applies to every receipt the viewer verifies.

Limits

  • Root tests/test_receipt_verify.py and tests/test_verify_seal_action.py are not meaningful in my local venv. They fail 26 tests identically at this head and at the fix(seal-view): validate predicate.evidence_scope in JS receipt verifier #2643 merge base, so those failures are local-environment issues and are unrelated to this PR. CI covers them.
  • The vectors README says Cloud and the website (TypeScript) also consume record-run-v1. Any of those verifiers that skip null optional fields the way the old JS did will fail the six new vectors when they sync. That needs a follow-up in their own repos and does not block this PR.

Nit (non-blocking)

  • The types CHANGELOG says each new payload "is not canonical". That holds for 5 of the 6. evidence-scope-protocols-null round-trips canonically, and Python rejects it through RunStatementV1 validation ("1 validation error"). The expected malformed answer is correct either way.

CI and release

All seven workflows at this head completed with success (CI, Desktop replay, Protected safety review, Platform manifest, Secret Scan, Dependency Review, Link check). The PR does not touch packages/flow, so the Flow merge hold for #2637 does not apply. It has no release effect: the types entry is ## Unreleased and seal-view stays at v0.1.0 (unreleased).

@abrichr
abrichr merged commit d2d4b58 into main Nov 24, 2026
53 checks passed
@abrichr
abrichr deleted the claude/seal-view-evidence-scope-null branch November 24, 2026 23:16
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