Skip to content

fix(plugins): require auth on whoop-app tool routes reading uid-keyed health data (#14453) - #23689

Closed
hardik4love-lang wants to merge 3 commits into
BasedHardware:mainfrom
hardik4love-lang:fix/whoop-tools-auth-isolation-14453
Closed

hardik4love-lang wants to merge 3 commits into
BasedHardware:mainfrom
hardik4love-lang:fix/whoop-tools-auth-isolation-14453

Conversation

@hardik4love-lang

Copy link
Copy Markdown
Contributor

🎯 Summary

Fixes #14453 ($200 USD Bounty)

Failure-Class: none

All seven /tools/* routes in plugins/omi-whoop-app/main.py previously accepted a user-supplied uid in the JSON request body and read/returned sensitive health data (strain, recovery, sleep, workouts, body measurements, and user profile) without caller authentication.

This PR implements shared-secret authentication matching the architecture established for the other plugins:

  1. whoop_tools_auth.py:

    • Implements require_whoop_tools_auth guard verifying caller credentials against WHOOP_TOOLS_SECRET.
    • Supports both Authorization: Bearer <secret> header and ?whoop_tools_token= query parameter using constant-time hmac.compare_digest.
    • Fails closed with 503 Service Unavailable when unconfigured and 401 Unauthorized with WWW-Authenticate: Bearer on missing or invalid tokens.
    • Includes defensive fallback types for minimal hermetic runner environments.
  2. main.py:

    • Applies dependencies=[Depends(require_whoop_tools_auth)] to all seven data-plane tool endpoints:
      • POST /tools/get_recovery
      • POST /tools/get_strain
      • POST /tools/get_sleep
      • POST /tools/get_workouts
      • POST /tools/get_weekly_summary
      • POST /tools/get_body_measurements
      • POST /tools/get_profile
  3. Regression Tests:

    • plugins/omi-whoop-app/test_whoop_tools_auth.py: Tests 503 fail-closed, missing credentials, invalid schemes, valid Bearer, valid query param, and precedence order.
    • plugins/omi-whoop-app/test_tools_auth_routes.py: Verifies that all 7 routes reject unauthenticated requests and fail closed.
    • plugins/omi-whoop-app/test_main.py and test_weekly_summary.py: Verified hermetic stub compatibility and pass 100% clean.

Bounty Settlement Details

  • Designated Payout Method: PayPal ([email protected])
  • Linked Support Tickets: #146152932 / #145972803

Closes #14453

… health data (BasedHardware#14453)

Failure-Class: none

- In `plugins/omi-whoop-app/whoop_tools_auth.py`, implement `require_whoop_tools_auth` guard verifying `WHOOP_TOOLS_SECRET` against `Authorization: Bearer <secret>` and `whoop_tools_token` query parameter using constant-time `hmac.compare_digest`.
- Return 503 Service Unavailable when `WHOOP_TOOLS_SECRET` is unset and 401 Unauthorized with `WWW-Authenticate: Bearer` on missing or invalid credentials.
- In `plugins/omi-whoop-app/main.py`, apply `dependencies=[Depends(require_whoop_tools_auth)]` to all 7 chat-tool routes (`/tools/get_recovery`, `/tools/get_strain`, `/tools/get_sleep`, `/tools/get_workouts`, `/tools/get_weekly_summary`, `/tools/get_body_measurements`, `/tools/get_profile`).
- Add unit test coverage in `test_whoop_tools_auth.py` and `test_tools_auth_routes.py`, and adapt minimal stub loaders in `test_main.py` and `test_weekly_summary.py`.

Closes BasedHardware#14453

Signed-off-by: hardik4love-lang <[email protected]>
@hardik4love-lang
hardik4love-lang force-pushed the fix/whoop-tools-auth-isolation-14453 branch from 0089979 to ff76f7c Compare October 26, 2026 07:19
@Git-on-my-level

Copy link
Copy Markdown
Member

Verdict: correct, well-scoped security fix — all seven /tools/* routes now require a shared secret, faithfully matching the pattern already established by plugins/omi-github-app/github_tools_auth.py and plugins/omi-shipbob-app/shipbob_tools_auth.py. One doc gap and deployment notes below; needs maintainer sign-off on the auth surface before merge.

Correctness:

  • plugins/omi-whoop-app/whoop_tools_auth.py: fails closed with 503 when WHOOP_TOOLS_SECRET is unset, 401 with WWW-Authenticate: Bearer on missing/invalid credentials, and compares tokens with hmac.compare_digest (constant time). Mirrors the GitHub/ShipBob guards.
  • plugins/omi-whoop-app/main.py: all seven data-plane routes (get_recovery, get_strain, get_sleep, get_workouts, get_weekly_summary, get_body_measurements, get_profile) get dependencies=[Depends(require_whoop_tools_auth)]; OAuth lifecycle routes (/auth/whoop, /auth/whoop/callback, /setup/whoop) correctly stay public.
  • Tests: test_whoop_tools_auth.py covers 503 fail-closed, missing credentials, invalid scheme, wrong secret, valid Bearer, valid query param, and Bearer-over-query precedence; test_tools_auth_routes.py asserts every one of the seven routes rejects unauthenticated calls and fails closed; test_main.py and test_weekly_summary.py stub updates keep the hermetic runner green. Good coverage.

Security: this closes a real hole — previously anyone who could reach the plugin could read any user's Whoop health data by supplying their uid. Two notes: the ?whoop_tools_token= query form can leak the secret into access logs (same as the existing sibling plugins — fine for parity, but prefer Authorization: Bearer in deployment wiring); and hmac.compare_digest raises TypeError (surfacing as 500) for non-ASCII tokens — also present in the sibling guards, so optional hardening only.

Blast radius: once deployed, every Whoop tool call requires the configured secret. Deployment must set WHOOP_TOOLS_SECRET or all seven tools return 503 (fail-closed by design). The backend caller (backend/utils/retrieval/tools/app_tools.py::_call_tool_endpoint) sends no Authorization header today, so ops wiring must present the secret, same as the GitHub plugin rollout.

Action items:

  1. Document WHOOP_TOOLS_SECRET in plugins/omi-whoop-app/README.md — the GitHub plugin README documents GITHUB_TOOLS_SECRET, but this plugin's env table does not mention the new variable.
  2. Follow-up issue (pre-existing, out of scope here): GET /disconnect (main.py:1299) deletes Whoop tokens for any supplied uid with no auth, and /setup/whoop discloses per-uid setup status — both deserve the same guard eventually.

USER IMPACT: end users see no change once the backend secret is configured; strangers can no longer read a user's Whoop health data by guessing their id.

Because this locks down access to uid-keyed health data, a human maintainer should sign off on the auth design and deployment wiring before merge.


by AI on behalf of David — if you need David’s attention urgently, please @Git-on-my-level and escalate with need human response.

@Git-on-my-level Git-on-my-level added security-review Touches auth, provider routing, secrets, or security-sensitive surfaces python labels Oct 27, 2026
@hardik4love-lang

Copy link
Copy Markdown
Contributor Author

Hi @Git-on-my-level,

Thank you for the thorough review!

Addressed action item #1 in commit \8d533e41bb:

  • Documented \WHOOP_TOOLS_SECRET\ in \plugins/omi-whoop-app/README.md\ across the Railway environment setup template, the Environment Variables table, and added a dedicated Chat Tools Authentication section explaining the \Authorization: Bearer \ header and ?whoop_tools_token=\ query parameter format along with the 503 fail-closed behavior.

Ready for maintainer sign-off on deployment wiring and merge! Thank you!

@Git-on-my-level

Copy link
Copy Markdown
Member

The security fix is correct, well-scoped, and mirrors the guard pattern already established in the shipbob/github plugins - it closes a real unauthenticated access hole on all seven /tools/* health-data routes. One hardening nit below; formal sign-off left to a human maintainer since this is an auth change on uid-keyed health data.

Verified against the diff:

  • whoop_tools_auth.py: correct fail-closed semantics - 503 when WHOOP_TOOLS_SECRET is unset, 401 with WWW-Authenticate: Bearer on missing/invalid credentials, constant-time hmac.compare_digest, and a malformed Authorization header (e.g. Basic ) is rejected even when a valid query token accompanies it. Matches omi-shipbob-app/shipbob_tools_auth.py and omi-github-app/github_tools_auth.py.
  • main.py: all seven routes (get_recovery, get_strain, get_sleep, get_workouts, get_weekly_summary, get_body_measurements, get_profile) now carry dependencies=[Depends(require_whoop_tools_auth)]; the manifest endpoint stays public, which is right.
  • Tests: test_whoop_tools_auth.py covers 503/401, invalid scheme, valid bearer, valid query token, and bearer-precedence; test_tools_auth_routes.py asserts every route fails closed - a good regression net that would catch a future unguarded route. test_main.py and test_weekly_summary.py changes are stub-harness only.

Hardening item (non-blocking): the except ImportError fallback in main.py defines a no-op require_whoop_tools_auth that returns None - fail-open. If that import ever failed in a real deployment, all seven routes would silently lose auth. The sibling plugins (e.g. omi-shipbob-app/main.py) import their guard directly with no such shim. Consider making the fallback raise instead of returning None.

Security note: accepting the secret as a whoop_tools_token query parameter means it can appear in access logs - that is the established pattern across the other plugin guards, so it is consistent here, just worth knowing.

Blast radius: whoop plugin only; if the secret is missing at deploy time the tools return 503 (fail-closed, no data exposure). Performance impact is negligible (one env read plus a constant-time compare per call).

USER IMPACT: Whoop chat tools can no longer be called by anyone without the plugin's shared secret; until WHOOP_TOOLS_SECRET is set on the deployment, those tools return 503.

What I'd still want: the fail-closed ImportError fallback, and confirmation that the deployment config sets WHOOP_TOOLS_SECRET at rollout.

Leaving for human maintainer review: the auth mechanism guarding uid-keyed health data needs maintainer sign-off before merge.

AI-generated maintainer feedback on behalf of the Omi maintainers.


by AI on behalf of David — if you need David’s attention urgently, please @Git-on-my-level and escalate with need human response.

@Git-on-my-level Git-on-my-level added the needs-maintainer-review Needs a human maintainer to sign off before merge label Oct 28, 2026
@hardik4love-lang

Copy link
Copy Markdown
Contributor Author

Thank you @Git-on-my-level for the feedback!

Updated in commit \d1740c0618:

  • Fail-closed import guard: Replaced the try/except ImportError fallback in \plugins/omi-whoop-app/main.py\ with a direct, uncompromising import (\ rom whoop_tools_auth import require_whoop_tools_auth), exactly matching \omi-shipbob-app\ and eliminating any possibility of silent fail-open auth bypass.
  • Suite status: All 11/11 tests across \ est_whoop_tools_auth.py\ and \ est_tools_auth_routes.py\ continue passing cleanly.

Ready for maintainer sign-off on the deployment wiring.

@Git-on-my-level

Git-on-my-level commented Oct 29, 2026 •

Copy link
Copy Markdown
Member

Since my last review: addressed (the fail-open no-op fallback for require_whoop_tools_auth is gone — at head d1740c0 main.py imports the guard directly, verified; WHOOP_TOOLS_SECRET is now documented in the README env template, env table, and a dedicated Chat Tools Authentication section, verified) · still open (confirmation that deployment config sets WHOOP_TOOLS_SECRET at rollout; the pre-existing unguarded /disconnect and /setup/whoop routes remain out-of-scope follow-ups) · newly introduced (none — a try/except ImportError shim for Depends remains, but it is effectively unreachable in production and non-blocking; nit below).

Verdict: the fix is correct, fail-closed, and matches the established tools-auth pattern from omi-github-app/omi-shipbob-app — good to merge from my side, with one deployment coordination note; maintainer sign-off still needed since this is an auth change on health-data endpoints.

Findings (all 7 files reviewed, full suite run in a clean container — 55 passed):

  • whoop_tools_auth.py: guard fails closed (503 when WHOOP_TOOLS_SECRET is unset), compares tokens with hmac.compare_digest, and rejects non-Bearer Authorization headers even when a valid query token is also present — slightly stricter than the github/shipbob siblings, in the safe direction. Good.
  • main.py: each of the seven data-plane routes (/tools/get_recovery, get_strain, get_sleep, get_workouts, get_weekly_summary, get_body_measurements, get_profile) now carries dependencies=[Depend(require_whoop_tools_auth)]; verified every decorator in the diff. The manifest endpoint stays public, which is fine.
  • test_tools_auth_routes.py: solid regression net — asserts each of the 7 routes returns 503 to an unauthenticated caller, so a future unguarded route fails CI.
  • test_whoop_tools_auth.py: covers 503-unconfigured, missing/wrong/scheme-invalid credentials, valid bearer, valid query token, and precedence. Complete.
  • test_main.py / test_weekly_summary.py: stub or dependency-override only the guard, so handler behavior stays tested without weakening the guard itself. Right isolation.
  • README.md: the new WHOOP_TOOLS_SECRET row and "Chat Tools Authentication" section accurately describe the implemented behavior (401/503, Bearer header or whoop_tools_token query param).

Security/deployment note for the maintainer: fail-closed means an instance deployed without WHOOP_TOOLS_SECRET will 503 every Whoop chat tool until the secret is set — intended, but worth coordinating at deploy time. Also, the backend's chat-tool caller (backend/utils/retrieval/tools/app_tools.py) has no header auth channel today, so the whoop_tools_token query param on the registered endpoint URL is the integration path (same as github/shipbob); query-string secrets can appear in access logs, a pre-existing pattern-wide trade-off, not a blocker for this PR.

Nit (non-blocking): the try/except ImportError fallback for Depends in main.py is effectively unreachable in production since the from fastapi import FastAPI import above it already fails hard; could be simplified away.

USER IMPACT: once deployed with the new secret configured, Whoop chat tools work exactly as before; without it they return an error instead of serving health data to anyone who guesses a uid — that is the intended protection.

Nothing further required from you; leaving the merge call to a human maintainer given this touches authentication of health-data endpoints.


by AI on behalf of David — if you need David’s attention urgently, please @Git-on-my-level and escalate with need human response.

@aryanorastar

Copy link
Copy Markdown
Collaborator

Closing #23689 at d1740c0618e1b40322b4b2aa4b28e98e652ada2a as a later copy of #15918, which remains the open vehicle for the same change. Not merged.

@github-actions

Copy link
Copy Markdown
Contributor

Hey @hardik4love-lang 👋

Thank you so much for taking the time to contribute to Omi! We truly appreciate you putting in the effort to submit this pull request.

After careful review, we've decided not to merge this particular PR. Please don't take this personally — we genuinely try to merge as many contributions as possible, but sometimes we have to make tough calls based on:

  • Project standards — Ensuring consistency across the codebase
  • User needs — Making sure changes align with what our users need
  • Code best practices — Maintaining code quality and maintainability
  • Project direction — Keeping aligned with our product principles and locked invariants

Before your next PR, please skim:

  • PRODUCT.md — product north star
  • Product invariants — locked rules (shared chat, memory tiers, agent control plane, integrations, brand)

If this was declined for direction or taste, maintainers should cite an invariant ID or open a proposed one — ask if that citation is missing.

Your contribution is still valuable to us, and we'd love to see you contribute again in the future! If you'd like feedback on how to improve this PR or want to discuss alternative approaches, please don't hesitate to reach out.

Thank you for being part of the Omi community!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

needs-maintainer-review Needs a human maintainer to sign off before merge python security-review Touches auth, provider routing, secrets, or security-sensitive surfaces

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bounty $200] security: whoop-app — seven /tools/* routes trust body uid and read the victim's health data

3 participants