Repository navigation
fix(plugins): require auth on whoop-app tool routes reading uid-keyed health data (#14453) - #23689
hardik4love-lang wants to merge 3 commits into
Conversation
… 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]>
0089979 to
ff76f7c
Compare
|
Verdict: correct, well-scoped security fix — all seven Correctness:
Security: this closes a real hole — previously anyone who could reach the plugin could read any user's Whoop health data by supplying their Blast radius: once deployed, every Whoop tool call requires the configured secret. Deployment must set Action items:
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 |
|
Hi @Git-on-my-level, Thank you for the thorough review! Addressed action item #1 in commit \8d533e41bb:
Ready for maintainer sign-off on deployment wiring and merge! Thank you! |
|
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:
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 |
|
Thank you @Git-on-my-level for the feedback! Updated in commit \d1740c0618:
Ready for maintainer sign-off on the deployment wiring. |
|
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):
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 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 |
|
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:
Before your next PR, please skim:
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! |
🎯 Summary
Fixes #14453 ($200 USD Bounty)
Failure-Class: none
All seven
/tools/*routes inplugins/omi-whoop-app/main.pypreviously accepted a user-supplieduidin 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:
whoop_tools_auth.py:require_whoop_tools_authguard verifying caller credentials againstWHOOP_TOOLS_SECRET.Authorization: Bearer <secret>header and?whoop_tools_token=query parameter using constant-timehmac.compare_digest.503 Service Unavailablewhen unconfigured and401 UnauthorizedwithWWW-Authenticate: Beareron missing or invalid tokens.main.py:dependencies=[Depends(require_whoop_tools_auth)]to all seven data-plane tool endpoints:POST /tools/get_recoveryPOST /tools/get_strainPOST /tools/get_sleepPOST /tools/get_workoutsPOST /tools/get_weekly_summaryPOST /tools/get_body_measurementsPOST /tools/get_profileRegression 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.pyandtest_weekly_summary.py: Verified hermetic stub compatibility and pass 100% clean.Bounty Settlement Details
[email protected])Closes #14453