Repository navigation
Conversation
The eight chat-tool routes in omi-shipbob-app read uid from the request body and act on that user's connected ShipBob account via get_shipbob_headers(uid), with no caller authentication. Anyone who knows a uid could read another user's orders and customer data, cancel their receiving orders, or create WROs under their account. Add shipbob_tools_auth.py: a shared-secret guard (Authorization: Bearer or shipbob_tools_token query param, checked against SHIPBOB_TOOLS_SECRET with hmac.compare_digest), applied via Depends() to all eight routes. Fail-closed 503 when unconfigured, 401 on missing or wrong token. Mirrors the merged mentor guard (plugins/basic/mentor_webhook_auth.py). Register shipbob-tools-auth-tests in the checks manifest. New hermetic regression test proves the guard behaviour and that all eight routes depend on it (red before, green after). Fixes BasedHardware#14666 Failure-Class: none
|
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. |
|
Flagging that #14684 targets the same issue (#14666), so you have two PRs to choose between. Both take the same approach (shipbob_tools_auth.py, hmac.compare_digest, Depends on the eight routes). The differences that may matter for review:
For context, this is the original fix and the issue is one I filed. Happy to expand test coverage or adjust anything you'd prefer either way. |
Git-on-my-level
left a comment
There was a problem hiding this comment.
Thanks for this — the underlying issue is real and the guard itself is well built. I verified each of the eight routes in plugins/omi-shipbob-app/main.py reads uid from the body and acts with that user's stored ShipBob OAuth token via get_shipbob_headers(uid), with no caller auth on main: /select-channel (:601), /tools/get_inventory (:625), /tools/get_products (:685), /tools/create_wro (:729), /tools/get_wros (:885), /tools/cancel_wro (:942), /tools/get_orders (:982), /tools/get_fulfillment_centers (:1044). The new shipbob_tools_auth.py guard is sound: hmac.compare_digest against SHIPBOB_TOOLS_SECRET, fail-closed 503 when unconfigured, 401 on missing/wrong token — structurally the same as the merged mentor guard (plugins/basic/mentor_webhook_auth.py, #13685). Your test_tools_auth.py passes 6/6 for me too (plugin-pinned fastapi 0.111.1).
Requesting changes for two verified test regressions, both fixable in a few lines:
-
test_main.py: 66/66 on base → 62/66 on this head. The four failures are exactly theTestCancelWroRegression13183cases, which drive/tools/cancel_wrothroughfastapi.testclient.TestClientwith no secret — the guard now rejects them before the handler runs, so the #13183 regression coverage is gone. The open whoop guard #14454 kept its equivalent TestClient coverage alive viaapp.dependency_overrides; the same approach (or a set-secret fixture + auth header in those tests) restores it here. -
test_create_wro_disambiguation.py: its hermetic fastapi stub (module("fastapi", FastAPI=..., HTTPException=..., Request=..., Query=...)) has noDepends, whichmain.py:18now imports, so the suite is import-broken under any execution ordering. #14454 added the attribute to its equivalent stub — a one-line fix here. (To be fair: that suite is already broken standalone onmainfor a separate stub gap and isn't manifest-run, but this PR shouldn't widen the hole.)
Related accuracy note on the PR body: "CI runs the full suite with its pinned deps" doesn't hold — the new manifest entry shipbob-tools-auth-tests runs only test_tools_auth.py for this plugin, so neither regression above is CI-visible. Also, the whoop guard (#14454) is still open rather than merged, and #14453/#14428/#14451 are bounty issues, not merged PRs — worth softening those references.
Two items I'm flagging for maintainer sign-off rather than asking you to change unilaterally:
/select-channelis called from the plugin's own browser page (templates/setup.html:404,fetch('/select-channel', {uid, channel_id})). A browser page can't holdSHIPBOB_TOOLS_SECRET, so the channel-switch flow will 401 even once the backend is wired. This route may need a different auth path than the backend-called/tools/*routes.- Nothing in the backend sends the secret today:
backend/utils/retrieval/tools/app_tools.py:_call_tool_endpointsends onlyContent-Type, and itsauth_requiredbranch is apassplaceholder. So all eight tools will 401/503 post-merge until caller wiring plus the env var deploy exist. #13685 shipped guard-first too, so this can be a conscious deploy sequence — but it should be an explicit one.
Small follow-up worth its own issue (not a reason to expand this PR): GET /disconnect?uid= (:597) and GET /setup/shipbob?uid= (:589) remain unauthenticated uid-keyed reads/writes in the same class.
The security fix direction and guard implementation are right — with the two test suites repaired and the /select-channel + caller-wiring questions answered, this should be in good shape. Human maintainer review is needed for the /select-channel browser-flow auth design and the backend wiring/deploy sequencing decision 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.
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.)
|
Thanks for the detailed review. Addressed the two test regressions:
Corrected the PR body per your accuracy note: this follows the merged mentor guard On On rollout: guard-first takes the tools to 503/401 until the backend On the |
|
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 eight chat-tool routes in
omi-shipbob-appthat previously acted on any uid supplied in the request body.Vulnerability
Every chat-tool route in
plugins/omi-shipbob-app/main.pytakesuidfrom the request body, callsget_shipbob_headers(uid)(main.py:141), and acts on that user's connected ShipBob account, with no caller authentication:POST /tools/get_inventory(main.py:625)POST /tools/get_products(main.py:685)POST /tools/create_wro(main.py:729, write)POST /tools/get_wros(main.py:885)POST /tools/cancel_wro(main.py:942, destructive)POST /tools/get_orders(main.py:982, customer data)POST /tools/get_fulfillment_centers(main.py:1044)POST /select-channel(main.py:601, write)get_shipbob_headersreturns{"Authorization": f"Bearer {tokens['access_token']}"}for the uid's stored token, so anyone who knows a uid can read another user's orders and customer data, cancel their receiving orders, or create WROs under their account. Same defect class as the open security filings for whoop (#14453) and zapier (#14428).Fix
New
plugins/omi-shipbob-app/shipbob_tools_auth.py:require_shipbob_tools_authchecksAuthorization: Beareror ashipbob_tools_tokenquery param against theSHIPBOB_TOOLS_SECRETenv var withhmac.compare_digest, applied viaDepends()to the/tools/*routes. Fail-closed 503 when unconfigured, 401 on missing or wrong token.This follows the merged mentor guard
plugins/basic/mentor_webhook_auth.py(#13685), which is 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-shipbob-app/test_tools_auth.py(stdlib only), registered asshipbob-tools-auth-testsin.github/checks-manifest.yaml. It covers the guard behaviour (503 unconfigured, 401 missing, 401 wrong, pass on Bearer, pass on query param) and asserts all eight routes depend on the guard. 6/6 pass locally.A follow-up commit keeps the existing suites green under the guard:
test_main.pyTestCancelWroRegression13183drives/tools/cancel_wrothroughTestClientwith no secret, so the guard returned 503 before the handler. Those tests now bypass the guard withapp.dependency_overrides(the approach whoop PR fix(plugins): require auth on whoop-app routes reading uid-keyed health data #14454 uses), restoring the ShipBob cancellation reports success for empty-body HTTP errors #13183 coverage.test_create_wro_disambiguation.py's hermetic fastapi stub lackedDepends, whichmain.pynow imports;Dependswas added to that stub.Accuracy notes: the checks-manifest entry runs only
test_tools_auth.pyfor this plugin, not the full suite, so the two items above are not CI-visible today.test_create_wro_disambiguation.pyhas separate pre-existing stub gaps onmain(verified: it fails on cleanmainwithModuleNotFoundError: No module named 'fastapi.exceptions', plus an incompletemodelsstub) unrelated to this change; I left those as-is rather than widen the PR. I could not runtest_main.pylocally (nofastapi/pip on this machine, Python 3.14); thedependency_overrideschange matches the pattern named in review.Rollout note
Guard-first: until the backend caller (
backend/utils/retrieval/tools/app_tools.py,_call_tool_endpoint) sendsSHIPBOB_TOOLS_SECRETand the env var is deployed, the/tools/*routes return 503/401. This is the same coordination the whoop family needs; sequencing is a maintainer decision (discussion in the review thread)./select-channelis called from the plugin's own browser page and cannot hold the secret; per review it should use a per-uid signature (whoop'sdisconnect_sigshape) rather than the shared secret, which I will apply on your nod.Bounty
Proposing US$200, in line with the per-app security fixes proposed in this family (#14453, #14451).
PayPal: [email protected]
Fixes #14666
Failure-Class: none
Investigated and implemented with AI assistance; I verified the reproduction and the fix, and can speak to every line.