Repository navigation
Conversation
… with 400, not 500 verifyProof and verifyAttestationChain need no account, but malformed JSON reached the verifiers and threw: a null attestation payload, a numeric version.contentHash, null reviews, or a signed payload of "null" all came back as INTERNAL_SERVER_ERROR. verifyAudit already had a shape check, caps and a catch; these two now match it. - proofPackageProblem checks every field verifyProofPackage reads (shared with the audit check as proofShapeProblem) and caps reviews at 200, the per-version cap the audit package already applied. - verifyReview treats a non-object signed payload, or a non-string signed contentHash, as an invalid review instead of throwing. - verifyAttestationChain requires object payloads (checked, not parsed, so an extra field still breaks the signature) and caps the chain at AUDIT_LIMITS.chain (500); key ids are looked up as own properties only. - Both mutations catch what the shape check cannot see and return 400, logging the cause. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_011icbSAD1vGxmDnJQ4fByEk
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
This branch was successfully deployed
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.
What and why
document.verifyProofanddocument.verifyAttestationChainare public tRPC mutations (no account, no DB). Malformed JSON reached the verifiers and threw, so callers gotINTERNAL_SERVER_ERROR.verifyAudit(hardened in #413) already had a shape check, caps and a catch. This brings the other two up to the same standard.Reproduced on
preprod(758f737) viacreateCaller, all 8 → 500:verifyAttestationChain, payloadnull/ missing / 2nd recordnullCannot read properties of nullverifyProof,version: "x"/reviews: null/contentHash: 5value.trim is not a function"null"payload is not a JSON objectpublicKeyId: "constructor"Changes
proof.ts:proofPackageProblemnow checks every fieldverifyProofPackagereads. The check is factored out asproofShapeProblem, andaudit.ts's per-version check now delegates to it, so audit error messages and limits are unchanged. Reviews are capped atPROOF_LIMITS.reviews = 200, the same per-version cap the audit package already used.verifyReview: a signed payload that isn't an object, or whosecontentHashisn't a string, is now an invalid review instead of an exception.verifyAttestationChain: the input now requires object payloads. They are checked withz.custom, not parsed, so a payload carrying an extra field still fails its signature rather than being stripped back into one that verifies (there's a test for this). The chain is capped atAUDIT_LIMITS.chain = 500, and key ids are looked up as own properties only.console.warnthe cause so a real verifier bug stays visible.Signing and spending logic is untouched. The verifiers only gained early-outs that make a result invalid. No previously failing input can now verify.
Tests
src/__tests__/trpc/documentVerifyEndpoints.test.ts(11): an honest chain verifies; an extra payload field breaks the signature; null/string/array/missing payload → 400; a 501-record chain → 400; three malformed proofs → 400; the catch branch → 400 and logs. The 400 cases fail onpreprod.documentSignoff.test.ts(+20) anddocumentAttestation.test.ts(+1): field-type matrix, review cap, user-facing message, non-object signed payloads, non-string signed hash, inherited key ids. All but the well-formed-package case fail onpreprod.npx tsc --noEmit: clean.node scripts/run-tests.mjs: 1676 + 97 passed, 2 skipped (pre-existing).-c jest.trpc.config.mjs --runInBand): 15 suites, 122 passed.partyId/comment, sentence-style message for/verify, log in the catch, test the catch branch) are all in this PR.Not verified / behaviour notes
/verifypaste box rejects such a proof up front). These limits come fromAUDIT_LIMITS; no real wallet gets near them.proof.ts(used by/verify, 328.6 KB against a 450 KB budget onpreprod) and adds a few hundred bytes. CI'sbudgetjob will confirm.🤖 Generated with Claude Code
https://claude.ai/code/session_011icbSAD1vGxmDnJQ4fByEk