Skip to content

SEC-768: Send card details to Stripe in the request body, not the URL - #395

Draft
msuitcase wants to merge 1 commit into
masterfrom
security/SEC-768-stripe-card-details-in-body
Draft

msuitcase wants to merge 1 commit into
masterfrom
security/SEC-768-stripe-card-details-in-body

Conversation

@msuitcase

@msuitcase msuitcase commented Sep 18, 2026

Copy link
Copy Markdown

Description

ReferralCustomerService._create_stripe_token passes card[number], card[exp_month], card[exp_year] and card[cvc] to requests.post through params=, which places them in the URL query string of the POST https://api.stripe.com/v1/tokens request. Query strings are routinely captured by access logs, outbound proxies, APM/tracing tools and Referer headers, so cardholder data could be retained outside the payment path (PCI DSS requirement 3 / 4).

This change switches to data=, so requests sends the same flattened card[...] fields as an application/x-www-form-urlencoded body, which is what Stripe expects on this endpoint (and what easypost-ruby, easypost-go and easypost-csharp already do). The existing Content-type header already declares that encoding.

Also adds a Next Release CHANGELOG entry.

Tracking: SEC-768 (internal).

Testing

  • python -m py_compile passes locally; the change is a one-keyword swap.
  • test_referral_customer_add_credit_card is currently @pytest.mark.skipped ("flow is deprecated, cannot easily be tested due to Stripe changes"), so no cassette needs re-recording for this PR to pass. test_referral_add_credit_card_error mocks _create_stripe_token and is unaffected. If that test is ever re-enabled, its match_on list can drop "query" since the request no longer has one.

Pull Request Type

Please select the option(s) that are relevant to this PR.

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Improvement (fixing a typo, updating readme, renaming a variable name, etc)

🤖 Generated with Claude Code

`referral_customer.add_credit_card` passed the card number, expiry and CVC
to `requests.post` via `params=`, which puts them in the URL query string of
the `POST /v1/tokens` request. Use `data=` so the same form-encoded fields
go in the request body, keeping cardholder data out of access logs, proxy
logs, tracing tools and Referer headers.

SEC-768

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
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