fix: drop evidence entries whose evidence_data serializes away#17
Merged
Conversation
External-review blocking finding. safeJsonSnapshot used
JSON.parse(JSON.stringify(entry)); when an extracted evidence_data value is a
function or symbol, JSON.stringify silently OMITS that property (it does not
throw), so the snapshot succeeded with the required evidence_data gone — a
malformed { evidence_key }-only entry that was then sent on /audit.
extractByPath already rejects undefined, and BigInt/circular refs throw (already
dropped), so the function/symbol drop was the one path that slipped through. The
malformed entry would 400 the audit; since audit failures are best-effort and
swallowed, a legitimately-executed call would degrade into a missing
finalization (server-side evaluation_expired — a false tamper signal).
Fix: after snapshotting, also drop any entry whose evidence_data did not survive
the round-trip (=== undefined). A legitimate null value survives.
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.
Resolves the external review's single blocking finding.
The bug
safeJsonSnapshotusesJSON.parse(JSON.stringify(entry)). When an extractedevidence_datavalue is a function or symbol,JSON.stringifysilently omits that property from the object (it does not throw). The snapshot therefore returnsok: truewithevidence_datagone — a structurally malformed entry{ evidence_key }missing its required field, which was then sent on/audit.This was reachable:
extractByPathreturnsfound: truefor a function/symbol value (it only rejectsundefined). The malformed entry would 400 the audit; because audit failures are best-effort and swallowed, a legitimately-executed call would degrade into a missing finalization — surfacing server-side asevaluation_expired, a false tamper/bypass signal.The fix
After snapshotting, also drop any entry whose
evidence_datadid not survive the round-trip (=== undefined). Precise, no false drops:extractByPathalready excludesundefinedinputs, and BigInt/circular refs throw (already dropped via the existingcatch), so the function/symbol drop was the only path that slipped through.nullvalue survives the round-trip and is kept.Verification
pnpm verifygreen: 198 tests (was 196), 0 type errors, build ✓. New test asserts a function-valued evidence path drops only its own entry while the serializable sibling survives — complementing the existing BigInt (throws) per-entry test.