Repository navigation
fix(whoop-app): escape OAuth error parameter in callback failure page (#14603) - #14604
Conversation
`GET /auth/whoop/callback?error=...` is unauthenticated. The current
`main` branch interpolates the `error` OAuth parameter directly into
`<p>{error}</p>` without `html.escape`, so an attacker can craft a URL
that injects arbitrary HTML/JS into the callback page (reflected XSS,
no preconditions).
Fix: add `import html` (stdlib, no new dependency) and replace
`<p>{error}</p>` with `<p>{html.escape(error or "", quote=True)}</p>`.
Deconfliction:
- PR BasedHardware#13658 encodes uid in redirect URLs (different sink, different lines)
- PR BasedHardware#14504 escapes str(e) in except block (different sink, different lines)
- This sink ({error} in <p>) is not covered by either open PR
Six stdlib-only tests confirm that the `error` OAuth parameter is now HTML-escaped before insertion into <p>, and that benign error codes still render correctly.
|
Verified the fix and the diff shape on this head.
The deconfliction notes in the description check out: #13658 covers This is a correct, minimal fix for a real reflected XSS on an unauthenticated route, with a clean write-up and a regression test — thank you. Since it modifies a security-sensitive OAuth callback, it needs maintainer sign-off before merge rather than automated approval. by AI on behalf of David — if you need David’s attention urgently, please @Git-on-my-level and escalate with |
|
Normalized line endings to LF — plugins/omi-whoop-app/main.py diff is now strictly +2/-1 lines. Thank you for the review! |
kodjima33
left a comment
There was a problem hiding this comment.
Two-line reflected-XSS fix (unauthenticated route), well-tested, no CI gate. 5/5.
|
Thanks for the review and merge @kodjima33! /claim #14603 Payout options for the $25 bounty:
Much appreciated! |
What changed and why
GET /auth/whoop/callback?error=...is an unauthenticated route. The currentmainbranch interpolates theerrorOAuth parameter directly into<p>{error}</p>without
html.escape, so an attacker can craft a URL that injects arbitraryHTML/JS into the callback page (reflected XSS, no preconditions required).
Closes #14603
Fix
Two-line minimal change (stdlib only, zero new dependencies):
Deconfliction
uidin redirect URLs viaquote()str(e)inexcept ExceptionblockThe sink (
{error}in<p>) is not covered by either open PR.Tests
New hermetic suite
test_callback_error_escaped.py(stdlib only, no network, no FastAPI runtime):test_breakout_payload_is_not_reflected_raw<p>test_script_tag_is_not_in_outputtest_escaped_representation_is_presenttest_benign_error_still_rendersaccess_deniedetc. pass through unchangedtest_empty_string_does_not_crasherror or ""guard handles None/emptytest_double_quote_is_entity_encoded"becomes"(attribute-safe)