Skip to content

fix(protocol): validate JWS protected header and payload as I-JSON#881

Merged
jithinraj merged 1 commit into
mainfrom
fix/ijson-raw-input-gate
Jun 28, 2026
Merged

fix(protocol): validate JWS protected header and payload as I-JSON#881
jithinraj merged 1 commit into
mainfrom
fix/ijson-raw-input-gate

Conversation

@jithinraj

Copy link
Copy Markdown
Member

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

  • Adds an internal TypeScript raw-byte I-JSON gate for JWS protected header and payload bytes.
  • Adds an internal Go raw-byte I-JSON gate for the same boundary, run before any JSON parsing.
  • Adds shared raw-input parity vectors exercised by both TypeScript and Go.
  • Adds canonical E_IJSON_* validation errors and maps internal crypto errors to protocol-level verification errors.
  • Keeps the raw-input corpus standalone; parity_families remains unchanged.

Compatibility

  • No wire-format change.
  • No schema shape change.
  • No CLI behavior change.
  • No signing-output change.
  • No package version or release metadata change.
  • No new public TypeScript package export.
  • No new public Go SDK API.
  • Adds three validation error codes:
    • E_IJSON_DUPLICATE_MEMBER_NAME
    • E_IJSON_NUMBER_OUT_OF_RANGE
    • E_IJSON_INVALID_STRING

Policy-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' test
  • pnpm --filter '@peac/protocol' test
  • pnpm test:conformance
  • cd sdks/go && go test ./... -count=1 && go test -race ./... -count=1
  • pnpm verify:codegen-drift
  • pnpm verify:no-widening
  • pnpm exec tsx scripts/extract-api-contract.ts --check
  • pnpm verify:registries-schema
  • bash scripts/ci/forbid-strings.sh
  • full monorepo build and test suite

Comment thread packages/crypto/src/ijson.ts Fixed
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.
@jithinraj jithinraj force-pushed the fix/ijson-raw-input-gate branch from 200e061 to b23f702 Compare June 28, 2026 07:42
@jithinraj jithinraj changed the title fix(protocol): reject non-I-JSON JWS header and payload bytes fix(protocol): validate JWS protected header and payload as I-JSON Jun 28, 2026
@jithinraj jithinraj merged commit e630e52 into main Jun 28, 2026
33 checks passed
@jithinraj jithinraj deleted the fix/ijson-raw-input-gate branch June 28, 2026 07:57
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