Skip to content

fix(plugins): bind mentor transcript buffer to authenticated uid - #13685

Merged
kodjima33 merged 3 commits into
BasedHardware:mainfrom
apoorvdarshan:cursor/mentor-session-auth-a0e3
Sep 13, 2026
Merged

kodjima33 merged 3 commits into
BasedHardware:mainfrom
apoorvdarshan:cursor/mentor-session-auth-a0e3

Conversation

@apoorvdarshan

@apoorvdarshan apoorvdarshan commented Sep 13, 2026 •

Copy link
Copy Markdown
Collaborator

Fixes #13665

Problem

POST /mentor in plugins/basic/mentor.py used the client-supplied session_id as 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

  • Require BASIC_MENTOR_WEBHOOK_SECRET on the plugins service. Callers must present it via Authorization: Bearer … or the mentor_webhook_token query param (so the Omi realtime webhook URL can carry ?mentor_webhook_token=…&uid=… as backend already appends uid).
  • Require uid query param and reject requests where session_id != uid.
  • Key Redis transcript buffers and in-process scan state by authenticated uid, not an unbound client session_id.

Deploy note

After merge, set BASIC_MENTOR_WEBHOOK_SECRET on the Cloud Run plugins service and add mentor_webhook_token=<same value> to the Omi Mentor app webhook URL in the app store config. Until both are set, /mentor returns 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

Review in cubic

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]>
@apoorvdarshan
apoorvdarshan marked this pull request as ready for review September 13, 2026 06:27

@cubic-dev-ai cubic-dev-ai Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

All reported issues were addressed across 4 files

Reply with feedback, questions, or to request a fix.

Re-trigger cubic

Comment thread plugins/basic/mentor_webhook_auth.py Resolved
Comment thread plugins/basic/mentor_webhook_auth.py Resolved
Comment thread plugins/test_mentor_session_auth.py Resolved
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 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.

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) when BASIC_MENTOR_WEBHOOK_SECRET is unset, uses hmac.compare_digest for the Bearer/query token, requires a non-empty uid, and reads the secret per-request rather than at import — matches the repo's lazy-env rule.
  • plugins/basic/mentor.py: buffer keys and scan_segment_session are now bound to the authenticated uid, and the 403 for session_id != uid fires 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.py posts {"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 ran python3 plugins/test_mentor_session_auth.py in 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 only mentor-01:<uid>.
  • .github/checks-manifest.yaml: the new plugin-mentor-session-auth-tests entry 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() in plugins/db.py:get_upsert_segment_to_transcript_plugin stays 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.

@Git-on-my-level Git-on-my-level added security-review Touches auth, provider routing, secrets, or security-sensitive surfaces needs-tests PR introduces logic that should be covered by tests positive-signal Automation verified a genuine fix/quality contribution backend Backend Task (python) labels Sep 13, 2026
…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]>
@apoorvdarshan

Copy link
Copy Markdown
Collaborator Author

@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: plugin-mentor-session-auth-tests now runs via scripts/run-plugin-mentor-session-auth-tests.sh, which installs pinned fastapi==0.121.0, httpx==0.28.1, pydantic==2.13.4, and starlette==0.49.1 with uv run --with … (same pattern as backend/testing/desktop_beta_admission/run.sh) before executing plugins/test_mentor_session_auth.py. Hygiene no longer hits the all-skipIf path on stdlib-only Python.

Verification (commit dede491d44):

  • python3 plugins/test_mentor_session_auth.py → OK (skipped=5) without deps (unchanged for ad-hoc runs)
  • bash scripts/run-plugin-mentor-session-auth-tests.sh → Ran 5 tests … OK (no skips)
  • python3 .github/scripts/run_checks.py --lane ci --check-id plugin-mentor-session-auth-tests → PASS with five executed tests

Deploy reminder (unchanged): set BASIC_MENTOR_WEBHOOK_SECRET on the plugins Cloud Run service and add the token to the Mentor app webhook URL (mentor_webhook_token= query param or Authorization: Bearer), otherwise /mentor stays 503 until configured.

Please re-review when Hygiene is green on the new head.

@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.

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).

@kodjima33
kodjima33 merged commit 25a145a into BasedHardware:main Sep 13, 2026
28 checks passed
hridaya423 added a commit to hridaya423/omi that referenced this pull request Sep 17, 2026
/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
hridaya423 added a commit to hridaya423/omi that referenced this pull request Sep 17, 2026
/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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backend Backend Task (python) needs-tests PR introduces logic that should be covered by tests positive-signal Automation verified a genuine fix/quality contribution security-review Touches auth, provider routing, secrets, or security-sensitive surfaces

Projects

None yet

Development

Successfully merging this pull request may close these issues.

basic/mentor: unauthenticated session_id lets callers read and poison other sessions' transcript buffers

4 participants