Repository navigation
fix(shipbob): require shared secret on chat-tool routes - #14684
Merged
kodjima33 merged 1 commit intoSep 19, 2026
Merged
Conversation
The /select-channel and /tools/* routes read uid from the request body and act on that user's stored ShipBob token with no caller authentication, letting anyone who reaches the service read another user's orders/catalog, cancel their receiving orders, or repoint their channel. Add shipbob_tools_auth.py (shared-secret guard, hmac.compare_digest against SHIPBOB_TOOLS_SECRET, Authorization: Bearer header or shipbob_tools_token query param) and apply it via Depends() to all eight routes. Fails closed: 503 when unconfigured, 401 on missing/wrong token. Mirrors the merged mentor_webhook_auth.py precedent. Tests: new test_shipbob_tools_auth.py (unit + route-wiring + integration); updated the cancel_wro regression tests and the hermetic disambiguation stub for the new dependency.
Git-on-my-level
left a comment
Member
There was a problem hiding this comment.
Verified this end-to-end — nice, clean fix.
What I checked:
shipbob_tools_auth.py— correct shape: constant-timehmac.compare_digest, fail-closed 503 whenSHIPBOB_TOOLS_SECRETis unset (whitespace-only counts as unset), 401 on missing/wrong token or non-Bearer scheme. Function-for-function consistent with the mergedplugins/basic/mentor_webhook_auth.pyprecedent.main.py— all eight chat-tool routes (/tools/get_inventory,get_products,create_wro,get_wros,cancel_wro,get_orders,get_fulfillment_centers) plus/select-channelnow carrydependencies=[Depends(require_shipbob_tools_auth)]. I enumerated every route in the base file to confirm none is left unguarded and nothing else changed behavior.- Tests — I re-ran the suite in a clean venv with the pinned
fastapi==0.111.1: 84/84 pass, matching your description. As a control I also ran the newShipBobRoutesAuthWiringTestswiring assertion against unpatchedmain.py— it fails there, so the regression coverage is real, not decorative. The hermetic stub updates intest_create_wro_disambiguation.py(addingDepends,exception_handler, theshipbob_tools_authmodule, and the request-model names) are the minimal set needed for that test's fake-FastAPI harness. README.md— accurately documents the new env var and the 401/503 contract.
Notes for maintainer sign-off (non-blocking for the contributor):
- The guard fails closed —
SHIPBOB_TOOLS_SECRETmust be provisioned in the deployment environment before/at merge, or all chat-tool endpoints will 503. That deploy-side coordination is a maintainer call, so I'm labeling thissecurity-reviewrather than sign-off myself. - Same residual surface as the sibling fixes (#14453, #14428, #14451):
/setup/shipboband/disconnectstill accept an unauthenticateduidquery param. Out of scope here and consistent with how the previous fixes landed, but worth a follow-up sweep issue. - Tiny README nits: stray backtick in the
Authorization: Bearer *** headerline and a doubled blank line before "Example Voice Commands".
Fixes a real, open security report (#14666) with verified regression coverage — thank you for the careful work. Leaving the merge decision and secret provisioning to a human maintainer.
by AI on behalf of David — if you need David’s attention urgently, please @Git-on-my-level and escalate with need human response.
5 tasks done
This was referenced Sep 21, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Cosa
Aggiunge un guard a secret condiviso (
shipbob_tools_auth.py) applicato viaDepends()a tutte le otto route chat-tool di ShipBob:POST /select-channelPOST /tools/get_inventoryPOST /tools/get_productsPOST /tools/create_wroPOST /tools/get_wrosPOST /tools/cancel_wroPOST /tools/get_ordersPOST /tools/get_fulfillment_centersIl guard accetta il secret come header
Authorization: Bearer <secret>o come query paramshipbob_tools_token, confrontato in tempo costante (hmac.compare_digest) con la variabile d'ambienteSHIPBOB_TOOLS_SECRET.Perché
Ogni route fa
uid = _clean_str(body.get("uid"))e poiget_shipbob_headers(uid), che restituisceBearer {token}deluidricevuto, senza alcuna autenticazione del chiamante. Chiunque raggiunga il servizio e conosca (o indovini) unuidpuò leggere ordini/dati cliente di un'altra persona, cancellare i suoi receiving order o crearne di nuovi a suo nome — stessa classe di difetto già pagata su whoop (#14453), zapier (#14428) e twitter-chat-tools (#14451).Come testato
test_shipbob_tools_auth.py:TestClient(401 senza token, 503 non configurato, ok con Bearer).test_main.py(regression cancel_wro: ora passano il secret) e lo stub hermetico ditest_create_wro_disambiguation.pyper la nuova dependency.python -m unittest discover -s . -p "test_*.py").Fail-closed:
503quando il secret non è configurato,401su token mancante o errato. Stesso meccanismo del precedente già mergeatoplugins/basic/mentor_webhook_auth.py.Closes #14666