fix(stripe): bind idempotency key to challenge id, not SPT#155
Open
MattewGraham wants to merge 2 commits into
Open
fix(stripe): bind idempotency key to challenge id, not SPT#155MattewGraham wants to merge 2 commits into
MattewGraham wants to merge 2 commits into
Conversation
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.
Security advisory: duplicate Stripe charges via SPT in idempotency key
Severity: High · Class: Financial correctness / idempotency bypass · Affected:
mpp.methods.stripeImpact
A buyer can be charged twice for a single payment. Any retry of a 402 flow that
re-mints the Stripe Shared Payment Token (SPT) — the normal case, since SPTs are
short-lived and single-use — produces a different idempotency key, so Stripe
happily creates a second
PaymentIntentfor the same logical charge.Where it comes from
Both PaymentIntent creation paths derived the idempotency key from the SPT:
Idempotency is supposed to collapse retries of the same charge into one
settlement. The
challenge_idalready is that identity: it is an HMAC bound toamount, currency, recipient, realm and intent. The SPT carries no additional
identity — it is an ephemeral credential — so mixing it in only serves to make
otherwise-identical retries look distinct to Stripe.
Resolution
Key idempotency on
challenge_idalone:Now a re-tried charge with a freshly minted SPT resolves to the same Stripe
PaymentIntent, and the double-charge window is closed. Both the SDK-client and
raw-HTTP code paths were updated identically so behaviour no longer depends on
which transport is configured.
Verification
tests/test_stripe.pycarried two assertions that encoded the vulnerablebehaviour (they asserted the SPT was present in the key). Those assertions were
corrected to assert challenge-only keys, and a docstring now records why the SPT
must stay out. Full
test_stripe.pysuite: 50 passed.