fix(ack-pay): bind payment request token subject to its id - #181
fix(ack-pay): bind payment request token subject to its id#181crazywriter1 wants to merge 2 commits into
Conversation
createPaymentRequestToken always sets sub to the payment request id, but verifyPaymentRequestToken never checked that binding, so a validly signed token could carry a different sub and still verify. Reject tokens whose JWT sub does not match the parsed payment request id, matching the contract the create path already enforces.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Team Run ID: 📒 Files selected for processing (2)
💤 Files with no reviewable changes (1)
Included review availability: Your plan provides up to 2 included reviews per hour; 1 remains after this review. WalkthroughChangesPayment request token binding
Estimated code review effort: 2 (Simple) | ~10 minutes Merge Risk: ⚪ Minimal · up to The change rejects payment request tokens whose subject does not match the payment request ID and documents that requirement; no actionable merge-blocking risk remains beyond normal checks and review. Suggested reviewers: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
Full details: Docstring CoverageExplanation Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 1 functions across 2 files. (1 skipped: 1 unsupported.) ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
venables
left a comment
There was a problem hiding this comment.
With this change, now the paymentRequestToken row in docs/ack-pay/payment-request-payload.mdx:73 does not say the JWT sub claim must equal paymentRequest.id; a third-party issuer that follows the docs now fails verification.
Can you please add one sentence to that row that states the sub contract.
|
Thanks for the review sir. Good catch on both. Removed the redundant |
Problem
createPaymentRequestTokenalways setssubto the payment request id, and the create-side tests assert that.verifyPaymentRequestTokennever checked the binding, so a validly signed token could carry a differentsuband still verify.That is the same class of gap #88 closed for receipts: the create path establishes a contract and the verify path did not enforce it.
Fix
After parsing the payload with
paymentRequestSchema, reject the token when the JWTsubis missing or does not equal the parsed payment requestid.Tests
Added a regression test that signs a payment request with
subset to a different value and expectsInvalidPaymentRequestTokenErrorwith nocause, same pattern as the existing invalid-payload test.Patch changeset included for
@agentcommercekit/ack-pay.AI usage
Per AI_POLICY.md, Cursor did the work: it found the create/verify asymmetry during a rescan of main, wrote the check and the test, and added the changeset. I read the diff before opening this.
Summary by CodeRabbit
Bug Fixes
Documentation
Tests
Chores