Skip to content

fix(shipbob): require shared secret on chat-tool routes - #14684

Merged
kodjima33 merged 1 commit into
BasedHardware:mainfrom
glmbugbounty:fix/shipbob-tools-auth
Sep 19, 2026
Merged

kodjima33 merged 1 commit into
BasedHardware:mainfrom
glmbugbounty:fix/shipbob-tools-auth

Conversation

@glmbugbounty

@glmbugbounty glmbugbounty commented Sep 19, 2026 •

Copy link
Copy Markdown
Contributor

Cosa

Aggiunge un guard a secret condiviso (shipbob_tools_auth.py) applicato via Depends() a tutte le otto route chat-tool di ShipBob:

Route Azione
POST /select-channel cambia il channel binding
POST /tools/get_inventory legge i livelli di inventario
POST /tools/get_products legge il catalogo prodotti
POST /tools/create_wro crea un warehouse receiving order
POST /tools/get_wros legge i receiving order
POST /tools/cancel_wro cancella un receiving order
POST /tools/get_orders legge ordini + dati cliente
POST /tools/get_fulfillment_centers legge i fulfillment center

Il guard accetta il secret come header Authorization: Bearer <secret> o come query param shipbob_tools_token, confrontato in tempo costante (hmac.compare_digest) con la variabile d'ambiente SHIPBOB_TOOLS_SECRET.

Perché

Ogni route fa uid = _clean_str(body.get("uid")) e poi get_shipbob_headers(uid), che restituisce Bearer {token} del uid ricevuto, senza alcuna autenticazione del chiamante. Chiunque raggiunga il servizio e conosca (o indovini) un uid può 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

  • Nuovo test_shipbob_tools_auth.py:
    • unit test del guard (503 se non configurato, 401 su token mancante/sbagliato/schema non-Bearer, ok su header Bearer e su query param);
    • verifica che tutte e otto le route abbiano la dependency;
    • integration test via TestClient (401 senza token, 503 non configurato, ok con Bearer).
  • Aggiornati test_main.py (regression cancel_wro: ora passano il secret) e lo stub hermetico di test_create_wro_disambiguation.py per la nuova dependency.
  • Suite completa dell'app: 84 test OK (python -m unittest discover -s . -p "test_*.py").

Fail-closed: 503 quando il secret non è configurato, 401 su token mancante o errato. Stesso meccanismo del precedente già mergeato plugins/basic/mentor_webhook_auth.py.

Closes #14666

Review in cubic

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 Git-on-my-level left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verified this end-to-end — nice, clean fix.

What I checked:

  • shipbob_tools_auth.py — correct shape: constant-time hmac.compare_digest, fail-closed 503 when SHIPBOB_TOOLS_SECRET is unset (whitespace-only counts as unset), 401 on missing/wrong token or non-Bearer scheme. Function-for-function consistent with the merged plugins/basic/mentor_webhook_auth.py precedent.
  • 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-channel now carry dependencies=[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 new ShipBobRoutesAuthWiringTests wiring assertion against unpatched main.py — it fails there, so the regression coverage is real, not decorative. The hermetic stub updates in test_create_wro_disambiguation.py (adding Depends, exception_handler, the shipbob_tools_auth module, 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):

  1. The guard fails closed — SHIPBOB_TOOLS_SECRET must 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 this security-review rather than sign-off myself.
  2. Same residual surface as the sibling fixes (#14453, #14428, #14451): /setup/shipbob and /disconnect still accept an unauthenticated uid query param. Out of scope here and consistent with how the previous fixes landed, but worth a follow-up sweep issue.
  3. Tiny README nits: stray backtick in the Authorization: Bearer *** header line 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.

@Git-on-my-level Git-on-my-level added security-review Touches auth, provider routing, secrets, or security-sensitive surfaces positive-signal Automation verified a genuine fix/quality contribution python labels Sep 19, 2026

@kodjima33 kodjima33 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Security fix for open shipbob uid-trust issue #14666: adds shared-secret auth guard + tests on all 8 chat-tool routes; not yet fixed on main. Winner of duplicate cluster vs #14680.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

positive-signal Automation verified a genuine fix/quality contribution python security-review Touches auth, provider routing, secrets, or security-sensitive surfaces

Projects

None yet

Development

Successfully merging this pull request may close these issues.

security: shipbob: eight routes trust body uid and act with the victim's ShipBob token

3 participants