fix(protocol): validate JWS protected header and payload as I-JSON#881
Merged
Conversation
Add a raw-input I-JSON (RFC 7493) gate that runs on the JWS protected header and payload bytes before JSON parsing, so duplicate object member names, non-interoperable numbers, and invalid string content (lone surrogates, Unicode noncharacters, invalid escapes, invalid UTF-8) are rejected before the parser can collapse, round, or substitute them. - TypeScript and Go raw-byte gates at the verify boundary (protected header and payload only); policy/JCS input is out of scope. - New E_IJSON_DUPLICATE_MEMBER_NAME, E_IJSON_NUMBER_OUT_OF_RANGE, and E_IJSON_INVALID_STRING validation codes; internal crypto codes map to protocol-level verification errors. - Shared standalone ijson-raw-input parity corpus exercised by both implementations; not enrolled in the schema-validated parity families. No wire-format, schema, CLI, or signing-output change.
200e061 to
b23f702
Compare
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.
Summary
This PR adds a raw-input I-JSON (RFC 7493) gate for JWS protected header and payload bytes before JSON parsing.
The gate rejects duplicate object member names, non-interoperable numeric values, invalid string content (lone surrogates, Unicode noncharacters, invalid escapes, unterminated strings), and invalid UTF-8 string bytes before ordinary JSON parsing can collapse, round, substitute, or otherwise lose the original bytes.
Scope
E_IJSON_*validation errors and maps internal crypto errors to protocol-level verification errors.parity_familiesremains unchanged.Compatibility
E_IJSON_DUPLICATE_MEMBER_NAMEE_IJSON_NUMBER_OUT_OF_RANGEE_IJSON_INVALID_STRINGPolicy-document/JCS raw-byte gating is out of scope for this PR because the current policy-binding path receives an already-parsed value.
Verification
pnpm --filter '@peac/crypto' testpnpm --filter '@peac/protocol' testpnpm test:conformancecd sdks/go && go test ./... -count=1 && go test -race ./... -count=1pnpm verify:codegen-driftpnpm verify:no-wideningpnpm exec tsx scripts/extract-api-contract.ts --checkpnpm verify:registries-schemabash scripts/ci/forbid-strings.sh