Repository navigation
Conversation
|
Thanks for reviewing. If this is accepted and merged, what is the typical timing for the bounty payout? Happy to adjust anything you need first. |
Git-on-my-level
left a comment
There was a problem hiding this comment.
Thanks @onkar717 — the vulnerability analysis is real and well done. I verified on main that tool_dispatch (plugins/omi-ms365-app/main.py:208) reads uid from the request body and _auth_guard (main.py:187) only proves the target user is connected, so all 16 Graph tools — including send_email, send_chat_message, upload_text_file — were reachable by anyone knowing a uid. The guard itself (plugins/omi-ms365-app/ms365_tools_auth.py) is solid: hmac.compare_digest, fail-closed 503 when unconfigured, 401 on a bad token, and the Depends() wiring on the dispatch route is correct. The new tests pass 6/6 and both new .github/checks-manifest.yaml entries are valid and green.
However, I'm requesting changes before this can merge, for four concrete reasons:
1. No caller can present the secret yet — every ms365 tool would fail in production. The backend's tool caller (backend/utils/retrieval/tools/app_tools.py, _call_tool_endpoint) sends only Content-Type: application/json; its auth_required branch is currently a pass placeholder. A repo-wide search finds no sender for MS365_TOOLS_SECRET (or any *_TOOLS_SECRET), and no open PR adds one. Deploying this guard as-is takes every ms365 chat tool to 503 (secret unset) or 401 (secret set, caller sends nothing), after which the backend's webhook circuit breaker disables the app. This needs a companion backend change — sent first or in a coordinated rollout. The existing auth_required flag on chat tools is a natural hook for that side.
2. The shipbob changes break the browser-called /select-channel flow. plugins/omi-shipbob-app/templates/setup.html (line 404) calls fetch('/select-channel', ...) from the user's browser after OAuth. A browser cannot hold a service shared secret, so channel selection would always 503 with no configuration fix. Your plugins/omi-shipbob-app/shipbob_tools_auth.py mirrors the ms365 guard exactly, but the whoop PR in this same family (#14454) handles its browser-called route differently — per-uid HMAC signatures (disconnect_sig/verify_disconnect_sig) — which is the shape /select-channel needs.
3. Existing tests regress (verified by running them at head vs base):
plugins/omi-ms365-app/test_tool_dispatch.py— registered asms365-tool-dispatch-testsin the checks manifest — passes 5/5 on base and fails at head with an ImportError: its fastapi stub doesn't exportDepends, whichmain.pynow imports. GitHub Actions hasn't run on this PR yet (only the neutral cubic check), so CI is currently silent about this.plugins/omi-shipbob-app/test_main.pygoes from 66/66 on base to 4 failures here (TestCancelWroRegression13183— direct handler calls now hit the 503 guard before the handler). Your newplugins/omi-shipbob-app/test_tools_auth.pypasses 6/6; the existing suite is what breaks.
4. The PR carries a second plugin's fix undeclared, duplicating your own open PR. The title and description cover only ms365, but 4 of the 7 changed files are the complete shipbob change set — the same content as your open #14680. Please keep the shipbob work in #14680 (with a signed/session mechanism for /select-channel per point 2) and reduce this PR to the ms365 fix; the two PRs otherwise conflict on .github/checks-manifest.yaml and shipbob main.py.
One description correction for the record: this doesn't mirror a merged guard — #14453 is an open bounty issue and #14454 is an open, unmerged PR; no *_tools_auth.py or *_TOOLS_SECRET exists on main today, and there's no in-repo backend configuration sending MS365_TOOLS_SECRET. The mechanism is consistent with the open family (#14447/#14452/#14454/#14456/#14680), but none of it has a merged rollout story yet, which is exactly what point 1 needs to solve.
Suggested path forward: (a) drop the shipbob files here; (b) add Depends to the fastapi stub in test_tool_dispatch.py so the registered check stays green; (c) pair the ms365 guard with — or explicitly gate it on — the backend change that sends the secret, so the tools don't go dark on deploy. Happy to re-review once that lands.
On the bounty timing question: payout decisions and timing rest with the maintainers, so I can't promise anything from the review side.
Leaving the rollout decision (backend-first ordering, secret distribution vs. the auth_required platform hook, and how this family of guard PRs lands together) for maintainer sign-off, since it spans the plugin↔backend contract and affects every app in this fix family.
— automated review on behalf of the maintainers; human sign-off required 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.
POST /tools/{tool_name} in omi-ms365-app reads uid from the request body and
runs the named Microsoft Graph tool as that user. The only gate, _auth_guard,
calls auth.get_access_token(uid), which proves the victim is connected but
never that the caller owns the uid. Anyone who knows a connected uid could read
that user's mail and files, send mail and Teams messages, and book meetings as
them.
Add ms365_tools_auth.py: a shared-secret guard (Authorization: Bearer or
ms365_tools_token query param, checked against MS365_TOOLS_SECRET with
hmac.compare_digest), applied via Depends() in front of the dispatch route.
Fail-closed 503 when unconfigured, 401 on missing or wrong token. _auth_guard
stays as the connection check. Mirrors the merged mentor guard
(plugins/basic/mentor_webhook_auth.py).
Register ms365-tools-auth-tests in the checks manifest. New hermetic regression
test proves the guard behaviour and that the dispatch route depends on it (red
before, green after).
Fixes BasedHardware#14683
Failure-Class: none
366dffd to
c4395fe
Compare
|
Good catch, my error. I branched ms365 off the shipbob branch instead of main, so this PR carried the shipbob files. Rebased onto clean main; #14686 is now ms365-only (one commit). The shipbob work stays in #14680. Fixed the test regression: added On rollout (point 1): agreed, guard-first takes the ms365 tools to 503/401 until |
kodjima33
left a comment
There was a problem hiding this comment.
Guard itself is correct, but independently verified: backend's app_tools.py caller never sends MS365_TOOLS_SECRET (auth_required branch is just 'pass'), so merging now would 503/401 every ms365 tool in production - needs a companion backend change first. Approve only, do not merge yet.
|
Hey @onkar717 👋 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! |
What this does
Adds a shared-secret auth guard in front of the
/tools/{tool_name}dispatch route inomi-ms365-app, which previously ran Microsoft Graph tools as any uid supplied in the request body.Vulnerability
tool_dispatch(main.py:208) readsuidfrom the request body (main.py:216) and runs the named tool as that user (main.py:228), with no check that the caller owns the uid. The one gate,_auth_guard(main.py:187, called atmain.py:221), only callsauth.get_access_token(uid)(main.py:189): it proves the target user is connected, not that the caller is that user. Against a connected victim it always succeeds, so it is a no-op for access control.The 16 tools reached through the single dispatch route include reads (
get_me,list_recent_emails,read_email,search_files,read_file_text) and writes as the victim (send_email,send_chat_message,create_event,create_online_meeting,upload_text_file).Same defect class as the open security filings for whoop (#14453) and the five-app group (#14455). Distinct from #14582 (reflected HTML on the setup and OAuth-error pages), which does not touch the tool routes.
Fix
New
plugins/omi-ms365-app/ms365_tools_auth.py:require_ms365_tools_authchecksAuthorization: Beareror ams365_tools_tokenquery param against theMS365_TOOLS_SECRETenv var withhmac.compare_digest, applied viaDepends()in front of the dispatch route. Fail-closed 503 when unconfigured, 401 on missing or wrong token._auth_guardis kept as the connection check.This follows the merged mentor guard
plugins/basic/mentor_webhook_auth.py(#13685), the same shared-secret shape. The whoop guard PR #14454 (issue #14453) is the open sibling in this family; it is not merged yet, and no*_tools_auth.pyexists onmaintoday.Tests
New hermetic regression test
plugins/omi-ms365-app/test_tools_auth.py(stdlib only), registered asms365-tools-auth-testsin.github/checks-manifest.yaml. Covers the guard behaviour (503 unconfigured, 401 missing, 401 wrong, pass on Bearer, pass on query param) and asserts the dispatch route depends on the guard. 6/6 pass locally.The existing registered check
test_tool_dispatch.pybroke because its hermetic fastapi stub lackedDepends, whichmain.pynow imports;Dependswas added to that stub. It passes 5/5 locally after the fix.Accuracy note: the checks-manifest entries run the two named plugin tests, not the full suite. I did not run any test needing real
fastapi/msal/httpx(no pip on this machine, Python 3.14); the change only adds a defaultedDependsparameter and the stub fix, both verified with the hermetic tests above.Rollout note
Guard-first: until the backend caller (
backend/utils/retrieval/tools/app_tools.py,_call_tool_endpoint) sendsMS365_TOOLS_SECRETand the env var is deployed, every ms365 tool returns 503/401. This is the same coordination the whoop family needs; sequencing is a maintainer decision (discussion in the review thread).Bounty
Proposing US$200, in line with the per-app security fixes proposed in this family (#14453, #14451).
PayPal: [email protected]
Fixes #14683
Failure-Class: none
Investigated and implemented with AI assistance; I verified the reproduction and the fix, and can speak to every line.