Skip to content

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

Open
hridaya423 wants to merge 2 commits into
BasedHardware:mainfrom
hridaya423:fix/whoop-tools-auth
Open

hridaya423 wants to merge 2 commits into
BasedHardware:mainfrom
hridaya423:fix/whoop-tools-auth

Conversation

@hridaya423

@hridaya423 hridaya423 commented Sep 18, 2026 •

Copy link
Copy Markdown
Contributor

Summary

All seven chat-tool routes in omi-whoop-app take uid from the JSON body and read that user's data via their stored Whoop OAuth token (get_valid_access_token(uid) / whoop_api_request(uid, ...)) with no caller authentication:

  • get_recovery, get_strain, get_sleep, get_workouts, get_weekly_summary, get_body_measurements, get_profile

Anyone who knows a uid can read the victim's health data: recovery scores, HRV, strain, sleep, body measurements. Same defect class as zapier (#14428/#14429), the paid mentor fix (#13685), the webhook fixes (#14446/#14447), and twitter-chat-tools (#14451/#14452); whoop was missed by all of them and is not in #13463's file list.

Fix

whoop_tools_auth.py, a shared-secret guard (Authorization: Bearer or whoop_tools_token query param → WHOOP_TOOLS_SECRET env, hmac.compare_digest), applied via Depends(require_whoop_tools_auth) to all seven routes. Caller authentication only; uid stays the body-level data-plane key. Fail-closed 503 unconfigured, 401 bad token.

test_weekly_summary.py uses FastAPI's dependency_overrides to bypass the guard, keeping the real-TestClient pagination coverage intact.

Tests

test_tools_auth.py: 503 unconfigured, 401 missing/wrong, bearer + query token accepted. test_get_workouts.py stub gained a Depends attribute for the hermetic path.

pytest plugins/omi-whoop-app → 36 tests pass (5 new).

Refs #14453

All seven chat-tool routes took uid from the JSON body and read that
user's Whoop data — recovery, strain, sleep, workouts, body
measurements, profile — via their stored OAuth token, with no caller
authentication. Sensitive health data readable by anyone with a uid.
Same defect class as zapier (BasedHardware#14428), the paid mentor fix, and
twitter-chat-tools (BasedHardware#14451); whoop was missed by all and by BasedHardware#13463.

Adds whoop_tools_auth.py (shared-secret bearer/query-token guard,
WHOOP_TOOLS_SECRET env, hmac.compare_digest) applied via Depends() to
every tool route. Fails closed 503 unconfigured, 401 bad token.
test_weekly_summary.py uses dependency_overrides to bypass the guard.

Verified: 36 plugin tests pass including 5 new guard tests.

Refs BasedHardware#14453
@Git-on-my-level

Copy link
Copy Markdown
Member

Thanks @hridaya423 — verified against #14453: this closes a real unauthenticated-read hole. All seven /tools/* routes took uid from the JSON body and read that user's health data via their stored Whoop OAuth token. I checked route coverage exhaustively (these seven are the only tool routes in the app) and ran the suite: 36/36 pass in a clean venv at this head, including the 5 new auth tests.

File by file:

  • plugins/omi-whoop-app/main.py — Depends(require_whoop_tools_auth) on all seven routes (get_recovery, get_strain, get_sleep, get_workouts, get_weekly_summary, get_body_measurements, get_profile). No handler logic touched; guard is purely additive. Correct and complete — no /tools/* route was missed.
  • plugins/omi-whoop-app/whoop_tools_auth.py — sound guard: fail-closed 503 ordered before the token check, hmac.compare_digest, no secret material in error details. Faithful to the merged mentor precedent (fix(plugins): bind mentor transcript buffer to authenticated uid #13685).
  • plugins/omi-whoop-app/test_tools_auth.py — real boundary coverage (503 unconfigured, 401 missing/wrong, bearer + query accepted) with correct env save/restore; the _FakeRequest + importlib load keeps it hermetic.
  • plugins/omi-whoop-app/test_weekly_summary.py — dependency_overrides is the idiomatic bypass; keeps the pagination regression coverage exercising the real TestClient stack.
  • plugins/omi-whoop-app/test_get_workouts.py — stub gaining Depends is exactly the minimal change needed to keep the hermetic path importing.

Non-blocking nits (guard fails closed in every case, so none of these block):

  • startswith("Bearer ") is case-sensitive; RFC 6750 treats the scheme as case-insensitive (the mentor guard has the same behavior).
  • The configured secret isn't .strip()ed/blank-checked — mentor's _configured_secret maps whitespace-only to 503; here it would 401 instead. Both deny.
  • A non-ASCII bearer token raises TypeError in hmac.compare_digest → 500 instead of 401.

One thing needs maintainer coordination before deploy (not a code change here): the backend caller (backend/utils/retrieval/tools/app_tools.py _call_tool_endpoint) sends only Content-Type + the uid payload — its auth_required branch is a no-op pass. Once WHOOP_TOOLS_SECRET is set, every whoop chat-tool call from the app will 401 until the backend presents the token, so the secret rollout and a backend-side companion change need to land together. Same sequencing class as the zapier rollout note on #14429, except the companion here is backend-side rather than a published Zapier app.

Residual risk worth tracking in the umbrella (#13463 direction): /setup/whoop and /disconnect remain uid-keyed and unguarded — /disconnect deletes a victim's Whoop tokens by uid alone, so it's a write path, not just a read.

Leaving formal sign-off to a human maintainer: this is an auth-boundary change on user health data, and the deploy sequencing above is a rollout decision.


by AI on behalf of David

@Git-on-my-level Git-on-my-level added positive-signal Automation verified a genuine fix/quality contribution security-review Touches auth, provider routing, secrets, or security-sensitive surfaces python labels Sep 18, 2026
/disconnect deleted a victim's Whoop tokens by uid alone — a GET link
rendered in the settings page, so the Bearer tools guard cannot apply.
The page now signs uid with the shared secret (disconnect_sig) and the
endpoint verifies it (verify_disconnect_sig, fail-closed 503/401).
Flagged in review on BasedHardware#14454.
@hridaya423

Copy link
Copy Markdown
Contributor Author

Addressed the /disconnect flag in dd0581d069 — it was indeed an unguarded write (deletes a victim's Whoop tokens by uid alone).

Since it's a browser GET link rendered in the settings page, the Bearer guard can't apply directly, so I used the signed-link pattern instead: the page now renders /disconnect?uid=…&sig=… where sig = HMAC_SHA256(secret, uid)[:32], and the endpoint verifies via verify_disconnect_sig (fail-closed 503 when WHOOP_TOOLS_SECRET unset, 401 on missing/mismatch).

Added 4 tests in test_tools_auth.py (valid sig accepted, wrong uid / missing sig 401, unconfigured 503). Suite: 40/40 pass.

onkar717 pushed a commit to onkar717/omi that referenced this pull request Sep 19, 2026
Two test regressions from adding require_shipbob_tools_auth:

- test_main.py TestCancelWroRegression13183 drives /tools/cancel_wro through
  TestClient with no secret, so the guard returned 503 before the handler ran.
  Bypass the guard in those tests with app.dependency_overrides (the approach
  the whoop guard PR BasedHardware#14454 uses), restoring the BasedHardware#13183 coverage.

- test_create_wro_disambiguation.py hermetic fastapi stub lacked Depends, which
  main.py now imports. Add Depends to the stub so the import resolves. (This
  suite has separate pre-existing stub gaps on main, fastapi.exceptions and the
  models import, that are unrelated to this change and left as-is.)
@aryanorastar

Copy link
Copy Markdown
Collaborator

Verified on dd0581d06927.

Leaving this open as the remaining-hole vehicle on plugins/omi-whoop-app/main.py, plugins/omi-whoop-app/test_get_workouts.py, plugins/omi-whoop-app/test_tools_auth.py, plugins/omi-whoop-app/test_weekly_summary.py…. remaining hole: whoop uid-keyed health auth keep; 0-checks.

Not approving from here: hosted checks are not green (0-check / UNSTABLE / FTC). kodjima APPROVE is not a merge. I am not merging.

@aryanorastar

Copy link
Copy Markdown
Collaborator

Keeping this open. Not approving dd0581d06927. origin/main:plugins/omi-whoop-app/main.py tool routes take body uid with no Depends. This sha wires require_whoop_tools_auth. 0 checks. Earlier keep vs later #15918. Do not approve.

— Astar, on behalf of @aryanorastar

@Git-on-my-level

Copy link
Copy Markdown
Member

Verified on dd0581d — the follow-up to the earlier /disconnect flag is resolved, thanks @hridaya423.

  • whoop_tools_auth.py: the shared-secret guard mirrors the merged shipbob/composio pattern (hmac.compare_digest, fail-closed 503 when WHOOP_TOOLS_SECRET is unset, 401 on missing/wrong token, Bearer header or whoop_tools_token query param), and the signed /disconnect link matches the canonical prevention recorded in .github/failure-classes/FC-unsigned-disconnect-deletes-tokens.json (sign the uid, verify before delete_whoop_tokens).
  • main.py: all seven /tools/* routes now carry Depends(require_whoop_tools_auth); at this head no other uid-keyed data route is left unguarded (/, /setup/whoop, /auth/whoop*, /health match the sibling plugins' shape).
  • test_tools_auth.py pins the boundary behavior (503 unconfigured, 401 missing/wrong, bearer + query accepted) and the sig binding including wrong-uid and missing-sig cases; test_weekly_summary.py's dependency_overrides keeps the real-TestClient pagination coverage intact; test_get_workouts.py's hermetic stub gained the Depends attribute.

One gap worth a small docs commit before merge: plugins/omi-whoop-app/README.md's environment table doesn't mention WHOOP_TOOLS_SECRET — the shipbob and github-app READMEs document their equivalents, and an operator following the current setup steps would leave the tool routes returning 503.

No CI checks have run on this head. Since this gates health-data routes, leaving for maintainer sign-off on the deployment secret configuration 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.

@aryanorastar aryanorastar left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On dd0581d0692787af08e938b250600c95461afcdf, plugins/omi-whoop-app/main.py still returns str(e) from the tool routes, the chat-tool wrappers, and the authentication HTML.

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

positive-signal Automation verified a genuine fix/quality contribution 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.

3 participants