Skip to content

Reject CR/LF/NUL in header values in the pycurl HTTP client - #1971

Open
jar-stripe wants to merge 1 commit into
masterfrom
jar/fix-pycurl-header-injection
Open

jar-stripe wants to merge 1 commit into
masterfrom
jar/fix-pycurl-header-injection

Conversation

@jar-stripe

Copy link
Copy Markdown
Contributor

Why?

RUN_DEVSDK-3683: PycurlClient builds its HTTPHEADER list by string-interpolating header names and values with no validation. A header value containing CR or LF can inject an additional header line — concretely reachable via Stripe-Request-Trigger, which is built from an unverified webhook event id. Every other HTTP client backend in this file already rejects this via its own underlying library (stdlib http.client, h11, aiohttp); pycurl has no such check built in.

What?

  • adds a check rejecting CR, LF or NUL in any header name or value before PycurlClient builds its HTTPHEADER list
  • adds a regression test covering hostile header names/values, modeled on the equivalent stripe-php test

See Also

RUN_DEVSDK-3697 tracks adding equivalent hardening tests across the rest of this file's HTTP client backends and the other 6 SDK languages.

Configuration

  • skip-changefile: This PR is not a user-facing change, so there's no changefile.

PycurlClient built the HTTPHEADER list via raw "%s: %s" string
interpolation with no validation, so a header value containing CR or
LF could inject an additional header line (e.g. via Stripe-Request-
Trigger, built from an unverified webhook event id). Other HTTP client
backends in this file are already protected by their own underlying
library (stdlib http.client, h11, aiohttp); pycurl has no such check
built in, so it needs one here.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Committed-By-Agent: claude
@jar-stripe
jar-stripe marked this pull request as ready for review November 7, 2026 05:15
@jar-stripe
jar-stripe requested a review from a team as a code owner November 7, 2026 05:15
@jar-stripe
jar-stripe requested review from xavdid and removed request for a team November 7, 2026 05:15
@jar-stripe
jar-stripe enabled auto-merge (squash) November 7, 2026 05:43

This branch has not been deployed

No deployments
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