Uh oh!
There was an error while loading. Please reload this page.
fix(stripe): reject idempotent-replayed PaymentIntents in charge verification - #21
Open
ygd58 wants to merge 1 commit into
Open
fix(stripe): reject idempotent-replayed PaymentIntents in charge verification#21ygd58 wants to merge 1 commit into
ygd58 wants to merge 1 commit into
Conversation
…fication StripeApi.createAndConfirm discarded the response entirely except for the PaymentIntent's id and status. Stripe signals a replayed idempotent request via the `Idempotent-Replayed` response header, but that header was never inspected, so StripeChargeIntent.verify() treated a replayed PaymentIntent exactly like a fresh one: any `succeeded` status was accepted and a new success Receipt was issued. A credential (challenge + spt) reused against a different challenge therefore triggered a second successful verification and a second resource grant, even though Stripe only charged the customer once. The canonical TypeScript implementation already guards against this (see wevm/mppx GHSA-8mhj-rffc-rcvw, fixed in mppx 0.4.11) by checking this exact header; this port never carried that check over. Read pi.getLastResponse().headers().firstValue("Idempotent-Replayed") after the create call, thread it through StripeApi.Result as a new idempotentReplayed field (existing 2-arg Result(id, status) constructor kept for source compatibility with existing tests), and reject the credential with VerificationFailedException in StripeChargeIntent.verify() before the status check when it's true. Adds a regression test reproducing the issue: a stubbed Result with status=succeeded and idempotentReplayed=true must throw VerificationFailedException rather than return a success Receipt. I could not compile/run this against the real com.stripe:stripe-java dependency in my environment (no Maven Central access), so I verified the getLastResponse()/headers()/firstValue() call chain directly against the stripe-java v25.3.0 source on GitHub (the version pinned in build.gradle) instead of a live build. Flagging this explicitly — please double-check compilation before merge. Fixestempoxyz/mpp-tools#111 (AGR-2026-035)
|
This was referenced Aug 13, 2026
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 freeto 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
StripeApi.createAndConfirmdiscarded the create response entirely except for the PaymentIntent's id and status. Stripe signals a replayed idempotent request via theIdempotent-Replayedresponse header, but that header was never inspected, soStripeChargeIntent.verify()treated a replayed PaymentIntent exactly like a fresh one: anysucceededstatus was accepted and a new successReceiptwas issued.Impact: a credential (challenge + spt) reused against a different challenge triggers a second successful verification and a second resource grant, even though Stripe only charged the customer once.
The canonical TypeScript implementation already guards against this — see wevm/mppx GHSA-8mhj-rffc-rcvw, fixed in mppx 0.4.11 — by checking this exact header. This port never carried that check over. Flagged by the cross-SDK audit as AGR-2026-035;
/ag fixisn't available for this repo since it's outside Agricola's write scope, so opening this directly.Fix
pi.getLastResponse().headers().firstValue("Idempotent-Replayed")after the create call.StripeApi.Resultas a newidempotentReplayedfield — kept the existing 2-argResult(id, status)constructor (defaulting tofalse) for source compatibility with existing tests.StripeChargeIntent.verify()now rejects the credential withVerificationFailedExceptionwhenidempotentReplayed()is true, before the status check.Testing
Added
idempotentReplayedSucceededChargeIsRejected: a stubbedResultwithstatus=succeeded, idempotentReplayed=truemust throwVerificationFailedExceptionrather than return a successReceipt. Matches the reproduction shape suggested in the linked finding.I could not compile or run this against the real
com.stripe:stripe-javadependency — my sandbox doesn't have Maven Central access. Instead I verified thegetLastResponse()/headers()/firstValue()call chain directly against the stripe-java v25.3.0 source on GitHub (the version pinned inbuild.gradle), which is the same accessor pattern the SDK itself uses internally (idempotencyKey(),requestId()useheaders().firstValue(...)the same way). But I want to be upfront that this hasn't been through an actual./gradlew test— please compile-check before merging, and let me know if anything doesn't match and I'll fix it.Fixes #(the corresponding issue in this repo, if one exists) / tempoxyz/mpp-tools#111