Skip to content

fix(verify): reject null required signed fields (closes #54)#10

Open
akuraposo wants to merge 1 commit into
permission-protocol:mainfrom
akuraposo:fix/null-signed-fields
Open

fix(verify): reject null required signed fields (closes #54)#10
akuraposo wants to merge 1 commit into
permission-protocol:mainfrom
akuraposo:fix/null-signed-fields

Conversation

@akuraposo
Copy link
Copy Markdown

Summary

Fixes #54: the pp-cli reference verifier only checked required-field
presence with field in receipt, while the canonicalizer omits any
signed field whose value is undefined or null.

A receipt with requestJson: null would satisfy the required-field
check, then canonicalize the rest of the body without requestJson,
and produce a verified: true result against a forged authorization
scope that has no operation payload. The same shape applies to any
other required signed field.

Fix

Added an isNonEmptySignedField helper in src/verify.ts and
replaced the field in receipt check in the required-field loop
with isNonEmptySignedField(receipt, field). Any required signed
field whose value is null or undefined now produces
MALFORMED_RECEIPT and exit code 3 instead of bypassing the
missing-field gate.

Validation

  • npm test -- --run — all 6 tests pass (5 pre-existing + 1 new
    regression test that forges requestJson: null on a valid
    receipt and expects MALFORMED_RECEIPT)
  • npm run build — clean
  • git diff --check — clean

Bounty

Submitted for assessment under #36 as a distinct Ed25519
verification-flow flaw. Payout details can be provided privately
after validation.

The reference verifier only checked required-field presence with
`field in receipt`, while the canonicalizer omits any signed field
whose value is `undefined` or `null`.

A receipt with `requestJson: null` would satisfy the required-field
check, then canonicalize the rest of the body without `requestJson`,
and produce a `verified: true` result against a forged authorization
scope that has no operation payload.

This patch adds an explicit non-null check before the required-field
loop, so any required signed field whose value is `null` or
`undefined` produces `MALFORMED_RECEIPT` and exit code 3 instead
of bypassing the missing-field gate.

- Added `isNonEmptySignedField` helper in `src/verify.ts`
- Required-field loop now uses the helper instead of `in`
- Added regression test that forges `requestJson: null` on a valid
  receipt and expects `MALFORMED_RECEIPT`
- All 6 tests pass
- `npm run build` clean

Closes #54
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