Skip to content

Harden API requestor code against malicious URLs - #1896

Merged
xavdid merged 3 commits into
masterfrom
RUN_DEVSDK-2808
Aug 31, 2026
Merged

Harden API requestor code against malicious URLs#1896
xavdid merged 3 commits into
masterfrom
RUN_DEVSDK-2808

Conversation

@xavdid

@xavdid xavdid commented Aug 28, 2026

Copy link
Copy Markdown
Member

Why?

If an attacker got access to a user's webhook secret (or the user wasn't validating incoming webhook signatures) and a user was calling the built-in event_notification.fetch_related_object() method, a malicious webhook payload could cause a user integration to make an authenticated request to an attacker-controlled domain (leaking the secret key)

To solve, we're being more careful during url construction to ensure user input can't be used to send requests to non-stripe.com domains (on a per-request basis).

What?

  • add path validation method and call it before the final URL is built
  • Encode the event.id path param in fetch_event() to match the sanitation in the rest of the generated endpoints
  • protect against treating malicious payloads as v2 iterables
  • add tests

See Also

@xavdid
xavdid marked this pull request as ready for review August 28, 2026 21:24
@xavdid
xavdid requested a review from a team as a code owner August 28, 2026 21:24
@xavdid
xavdid requested review from zacchua-stripe and removed request for a team August 28, 2026 21:24
@xavdid
xavdid enabled auto-merge (squash) August 28, 2026 21:24
Comment thread stripe/v2/core/_event.py
Comment thread stripe/_util.py
Comment thread stripe/_util.py
@xavdid
xavdid merged commit a9e3979 into master Aug 31, 2026
18 checks passed
@xavdid
xavdid deleted the RUN_DEVSDK-2808 branch August 31, 2026 21:31
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.

2 participants