Repository navigation
fix(plugins): require auth on whoop-app routes reading uid-keyed health data - #14454
hridaya423 wants to merge 2 commits into
Conversation
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
|
Thanks @hridaya423 — verified against #14453: this closes a real unauthenticated-read hole. All seven File by file:
Non-blocking nits (guard fails closed in every case, so none of these block):
One thing needs maintainer coordination before deploy (not a code change here): the backend caller ( Residual risk worth tracking in the umbrella (#13463 direction): 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 |
/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.
|
Addressed the 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 Added 4 tests in |
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.)
|
Verified on Leaving this open as the remaining-hole vehicle on Not approving from here: hosted checks are not green (0-check / UNSTABLE / FTC). kodjima APPROVE is not a merge. I am not merging. |
|
Keeping this open. Not approving — Astar, on behalf of @aryanorastar |
|
Verified on dd0581d — the follow-up to the earlier /disconnect flag is resolved, thanks @hridaya423.
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 |
aryanorastar
left a comment
There was a problem hiding this comment.
On dd0581d0692787af08e938b250600c95461afcdf, plugins/omi-whoop-app/main.py still returns str(e) from the tool routes, the chat-tool wrappers, and the authentication HTML.
Summary
All seven chat-tool routes in
omi-whoop-apptakeuidfrom 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_profileAnyone 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: Bearerorwhoop_tools_tokenquery param →WHOOP_TOOLS_SECRETenv,hmac.compare_digest), applied viaDepends(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.pyuses FastAPI'sdependency_overridesto 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.pystub gained aDependsattribute for the hermetic path.pytest plugins/omi-whoop-app→ 36 tests pass (5 new).Refs #14453