omi icon indicating copy to clipboard operation
omi copied to clipboard

[Bounty proposal] security(whoop-app): unescaped error reflection in OAuth callback and raw uid parameter injection ($75 proposed)

Open kaleidoscopeAI opened this issue 2 months ago • 3 comments

Summary

plugins/omi-whoop-app/main.py contains raw HTML and URL parameter interpolations leading to reflected cross-site scripting (XSS) and injection:

  1. Unauthenticated Reflected XSS in OAuth Callback:

    • In /auth/whoop/callback: when error query parameter is provided, it is rendered directly into the HTML response:
      if error:
          return HTMLResponse(content=f"""
          ...
              <p>{error}</p>
          """)
      
      Any attacker can craft a link like https://.../auth/whoop/callback?error=<script>alert(document.cookie)</script> that executes arbitrary JavaScript in the victim's session.
  2. Unescaped Exception Message in Callback Failure:

    • except Exception as e: return HTMLResponse(content=f"Authentication error: {str(e)}", status_code=500) exposes unescaped exception strings directly in the HTML response.
  3. Unquoted and Unescaped uid URL Parameter Injection:

    • In root connect page: <a href="{auth_url}"> where auth_url = f"/auth/whoop?uid={uid}" lacks quote(uid, safe='') and attribute escaping.
    • In root connected page: <a href="/disconnect?uid={uid}"> lacks quote(uid, safe='') and attribute escaping.
    • In callback success page: <a href="/?uid={uid}"> lacks quote(uid, safe='') and attribute escaping.
    • In /disconnect: RedirectResponse(url=f"/?uid={uid}") lacks URL parameter encoding.

Fix

  1. Use html.escape for safe_error in both the OAuth error branch and exception fallback.
  2. Guard callback query parameter types against Query object defaults when invoked in tests.
  3. Use quote(uid, safe='') and attribute escaping for all href targets and redirect URLs (safe_auth_url, safe_disconnect_url, safe_continue_url).
  4. Add hermetic test suite in plugins/omi-whoop-app/test_settings_page_encoding.py covering connect URL quoting, disconnect link escaping, reflected callback error escaping, callback success URL quoting, exception message escaping, and redirect quoting (6 tests).
  5. Register whoop-app-settings-encoding-tests and whoop-app-hardening-tests in .github/checks-manifest.yaml.

Verification

All 6 new encoding tests, all 24 test_whoop_hardening.py tests, 4 test_get_workouts.py tests, 3 test_weekly_summary.py tests, and all 53 checks-manifest validation tests pass locally (100% green).

@kodjima33 @josancamon19, following the published bounty proposal process, would you approve $75 after review/merge?

PR is ready to link.

kaleidoscopeAI avatar Sep 19 '26 12:09 kaleidoscopeAI

Opened PR https://github.com/BasedHardware/omi/pull/14891 with complete fix and regression test suite. Ready for review!

kaleidoscopeAI avatar Sep 19 '26 12:09 kaleidoscopeAI

Fresh PR rebased onto current main — the original branch could no longer compute mergeability, so its checks never ran: #20399 (CI green, Hygiene success, mergeable).

Fix: escape the OAuth callback error parameter and exception string (reflected XSS), and quote(uid, safe='') across the connect/disconnect/continue links and the /disconnect redirect, with href attribute targets escaped. Tests: 6 hermetic tests, registered as whoop-app-settings-encoding-tests in .github/checks-manifest.yaml. Failure-Class: FC-oauth-error-params-reflected-into-html

@kodjima33 @josancamon19, following the published bounty proposal process, would you approve $75 after review/merge?

kaleidoscopeAI avatar Oct 03 '26 02:10 kaleidoscopeAI

Thanks for putting this together. We aren't doing bounties at the moment, so we're closing the bounty proposal issues for now — thanks for the fix! 🙏

undivisible avatar Oct 22 '26 11:10 undivisible