Repository navigation
fix(plugins): bind mentor transcript buffer to authenticated uid - #13685
Conversation
POST /mentor accepted any client session_id for the shared Redis transcript buffer with no caller authentication, enabling cross-session disclosure and buffer poisoning (BasedHardware#13665). Require BASIC_MENTOR_WEBHOOK_SECRET (Bearer or mentor_webhook_token query), mandatory uid query param, session_id == uid, and use uid as the buffer key. Hermetic regression tests cover unauthenticated, cross-session, and legitimate calls. Verification: python3 plugins/test_mentor_session_auth.py Failure-Class: none Co-authored-by: Apoorv Darshan <[email protected]>
There was a problem hiding this comment.
All reported issues were addressed across 4 files
Reply with feedback, questions, or to request a fix.
Re-trigger cubic
Parse Authorization Bearer case-insensitively, reject whitespace-only uid after trim, and add hermetic 503 fail-closed test when BASIC_MENTOR_WEBHOOK_SECRET is unset. Verification: python3 plugins/test_mentor_session_auth.py (5 passed) Co-authored-by: Apoorv Darshan <[email protected]>
Git-on-my-level
left a comment
There was a problem hiding this comment.
Thanks @apoorvdarshan — well-scoped fix for #13665, and the core approach is right. I verified the production change and ran the new tests; one CI-wiring gap should be fixed before merge.
What I verified (all four changed files):
plugins/basic/mentor_webhook_auth.py: fails closed (503) whenBASIC_MENTOR_WEBHOOK_SECRETis unset, useshmac.compare_digestfor the Bearer/query token, requires a non-emptyuid, and reads the secret per-request rather than at import — matches the repo's lazy-env rule.plugins/basic/mentor.py: buffer keys andscan_segment_sessionare now bound to the authenticated uid, and the 403 forsession_id != uidfires before any buffer read/write, closing both the cross-session read and the poisoning paths from #13665. The contract matches the real caller:backend/utils/app_integrations.pyposts{"session_id": uid, ...}to a URL with?uid=appended, so the token can ride in the stored webhook URL as the PR describes.plugins/test_mentor_session_auth.py: I ranpython3 plugins/test_mentor_session_auth.pyin an isolated container (Python 3.11, matching the plugins service) — all 5 tests pass: 503 fail-closed, 401 unauthenticated, 403 cross-session, and the happy path writes onlymentor-01:<uid>..github/checks-manifest.yaml: the newplugin-mentor-session-auth-testsentry is correctly triggered by this PR's files — but see below.
One change needed: the new CI check is vacuously green. In the Hygiene job for this head, the check output is sssss — OK (skipped=5): fastapi/httpx are not installed in that environment, and @unittest.skipIf(TestClient is None, ...) turns the whole suite into a skip, so plugin-mentor-session-auth-tests passes without exercising anything. That defeats the check's purpose and the repo rule that hermetic tests must actually run in CI. Please either make the test fail (not skip) when its dependencies are missing in the ci lane, or have the manifest command set up its dependencies first (e.g. install fastapi/httpx before running, as a small pinned step).
Non-blocking notes:
- Carrying the shared secret in the
mentor_webhook_token=query param is fine for a webhook-URL pattern, but it then lives in stored app config and any URL-bearing logs; worth keeping in mind if this route ever gains richer auth. - The pre-existing
eval()inplugins/db.py:get_upsert_segment_to_transcript_pluginstays tracked separately in #13664 — good that this PR did not widen scope.
Also note: Dart Analyze & Tests is red on app/test/providers/deletion_consistency_test.dart and app/test/widgets/chat_content_blocks_test.dart (ActionItemsFetcher type errors) — main-side failures in files this PR does not touch; a rebase should pick up the fix once main is green again.
Since this changes an auth boundary and requires deploy coordination (set BASIC_MENTOR_WEBHOOK_SECRET on the plugins Cloud Run service and update the Mentor app webhook URL with the rollout, otherwise /mentor returns 503), it will need maintainer sign-off after the CI-wiring fix.
by AI on behalf of David — if you need David’s attention urgently, please @Git-on-my-level and escalate with need human response.
…in CI
Hygiene invoked plugins/test_mentor_session_auth.py on stdlib Python, so
skipIf(TestClient is None) skipped all five cases and the manifest check
passed vacuously.
Route plugin-mentor-session-auth-tests through a small runner that uses
uv --with pins matching plugins/requirements.txt (fastapi/httpx/pydantic/
starlette), mirroring backend/testing/desktop_beta_admission/run.sh.
Verification:
python3 plugins/test_mentor_session_auth.py # OK (skipped=5) without deps
bash scripts/run-plugin-mentor-session-auth-tests.sh # Ran 5 tests OK
python3 .github/scripts/run_checks.py --lane ci \
--check-id plugin-mentor-session-auth-tests # PASS, 5 executed
Co-authored-by: Apoorv Darshan <[email protected]>
|
@Git-on-my-level Re-review when you have a moment — the CI-wiring gap from your CHANGES_REQUESTED review should be fixed on this branch. What changed: Verification (commit
Deploy reminder (unchanged): set Please re-review when Hygiene is green on the new head. |
kodjima33
left a comment
There was a problem hiding this comment.
Real auth-bypass fix for /mentor (fixes #13665): binds transcript buffer to authenticated uid instead of client-supplied session_id, fails closed (503) without the new secret. CI-wiring gap from initial review already fixed on this head (dede491). CI green, tests pass, scoped. Confidence 4/5. Merging — note: BASIC_MENTOR_WEBHOOK_SECRET must be set on the plugins Cloud Run service post-merge or /mentor stays 503 (fail-closed, not a regression).
/zapier/trigger/memory/sample returned the caller-chosen uid's latest conversation including the full transcript; /zapier/action/memories wrote an arbitrary conversation into any uid's account; the trigger subscribe/unsubscribe pair stored an attacker-controlled target_url against any uid; /zapier/memories accepted webhooks with no caller binding; /zapier/me answered status probes. All six trusted the client-supplied uid with no credential. Add require_zapier_webhook_auth (same fail-closed pattern as the merged mentor session fix, BasedHardware#13685): Authorization bearer or zapier_webhook_token query param checked against ZAPIER_WEBHOOK_SECRET with hmac.compare_digest; 503 when unconfigured, 401 on missing or mismatched token. Residual, tracked in BasedHardware#14428: the browser control-plane endpoints (/setup-zapier, /zapier/connect, /zapier/disconnect, /setup/zapier) remain uid-keyed because the Omi app opens them without a credential; with the data plane closed, toggling enabled state grants no data access. Binding them needs a capability token issued by the Omi backend link (the direction of BasedHardware#13463). Deployment note: ZAPIER_WEBHOOK_SECRET must be set and the Zapier app / Omi webhook callers configured to send it, matching the mentor precedent. Verification: python3 test_webhook_auth.py (10 tests incl. boundary cases) and python3 test_zapier_hardening.py (18 tests) all pass. Failure-Class: new — client-supplied uid accepted as authorization on unauthenticated plugin routes
/zapier/trigger/memory/sample returned the caller-chosen uid's latest conversation including the full transcript; /zapier/action/memories wrote an arbitrary conversation into any uid's account; the trigger subscribe/unsubscribe pair stored an attacker-controlled target_url against any uid; /zapier/memories accepted webhooks with no caller binding; /zapier/me answered status probes. All six trusted the client-supplied uid with no credential. Add require_zapier_webhook_auth (same fail-closed pattern as the merged mentor session fix, BasedHardware#13685): Authorization bearer or zapier_webhook_token query param checked against ZAPIER_WEBHOOK_SECRET with hmac.compare_digest; 503 when unconfigured, 401 on missing or mismatched token. Residual, tracked in BasedHardware#14428: the browser control-plane endpoints (/setup-zapier, /zapier/connect, /zapier/disconnect, /setup/zapier) remain uid-keyed because the Omi app opens them without a credential; with the data plane closed, toggling enabled state grants no data access. Binding them needs a capability token issued by the Omi backend link (the direction of BasedHardware#13463). Deployment note: ZAPIER_WEBHOOK_SECRET must be set and the Zapier app / Omi webhook callers configured to send it, matching the mentor precedent. Verification: python3 test_webhook_auth.py (10 tests incl. boundary cases) and python3 test_zapier_hardening.py (18 tests) all pass. Failure-Class: new — client-supplied uid accepted as authorization on unauthenticated plugin routes
Fixes #13665
Problem
POST /mentorinplugins/basic/mentor.pyused the client-suppliedsession_idas the sole Redis transcript-buffer identity. The route had no caller authentication, so anyone who knew (or guessed) another session id could read accumulated transcript text from the returned mentor prompt and append poison segments into that buffer.Fix
BASIC_MENTOR_WEBHOOK_SECRETon the plugins service. Callers must present it viaAuthorization: Bearer …or thementor_webhook_tokenquery param (so the Omi realtime webhook URL can carry?mentor_webhook_token=…&uid=…as backend already appendsuid).uidquery param and reject requests wheresession_id != uid.uid, not an unbound clientsession_id.Deploy note
After merge, set
BASIC_MENTOR_WEBHOOK_SECRETon the Cloud Run plugins service and addmentor_webhook_token=<same value>to the Omi Mentor app webhook URL in the app store config. Until both are set,/mentorreturns 503 (fail closed).Tests
python3 plugins/test_mentor_session_auth.py— hermetic FastAPI tests (no Redis): unauthenticated write blocked, cross-session read/write blocked (403), authenticated matching uid succeeds.Failure-Class: none