Repository navigation
security: P0 uid-as-auth + ADMIN_KEY default-off - #13463
undivisible wants to merge 5 commits into
Conversation
P0-2 from the 2026-09-11 Grok audit: ADMIN_KEY impersonation (Bearer <ADMIN_KEY><uid>) now requires an intentional opt-in. Prod overlays leave the flag unset so they stay fail-closed. First-party test stacks that rely on impersonation set the flag explicitly. Admin router secret-key auth is unchanged.
P0-1 from the 2026-09-11 Grok audit: restore omi_plugin_sdk.auth HMAC helpers, sign backend→plugin webhooks/tools when OMI_PLUGIN_WEBHOOK_SECRET is set, and reject uid-only auth on GitHub mutations/tools, Dropbox disconnect/settings/webhook, hey_omi inbound webhook, and legacy Notion OAuth state. Setup/OAuth-start identity still needs a product-signed uid.
Git-on-my-level
left a comment
There was a problem hiding this comment.
Thanks @undivisible — the direction here is right and the substance is strong: fail-closed ADMIN_KEY_AUTH_ENABLED, shared HMAC identity for the plugin fleet, opaque OAuth state, and key-out-of-query-string are all real improvements. I did a full pass over the diff plus triage of the four failing checks; root causes below so you don't have to dig.
Blocking (CI — all small fixes)
- Hermetic Backend E2E: 99 failures, one root cause. The
account_deletion_identityfixture inbackend/testing/e2e/test_account_deletion_cloud_tasks.pysetsADMIN_KEYand authenticates viaBearer <ADMIN_KEY><uid>, but never setsADMIN_KEY_AUTH_ENABLED. With the new fail-closed default the token no longer matches the admin prefix path, falls through to Firebase, raisesInvalidIdTokenError, and theLOCAL_DEVELOPMENTbypass returns the shared dev uid123. The delete-account call then writes a marker toaccount_deletions/123, which neither the fixture (it cleansaccount_deletions/<fresh_uid>) norisolate_e2e_state'sclear_user_data(DEV_UID)(users-subtree scoped) removes — so every subsequent test in the suite 403s withaccount_deletion_in_progress. You updated the three stack runners (listen_pusher_stack/run.py,sync_cloud_tasks_stack/run.py,replay_harness_phase0a/runner.py) but this fourth consumer was missed: addADMIN_KEY_AUTH_ENABLED=truein the fixture (orconftest._set_e2e_env). - Backend unit: two stale-contract tests in
tests/unit/test_async_app_integrations.pyafterapp_integrations.pycorrectly switchedjson=payload→content=body_bytes(so the signature covers the exact delivered bytes):test_finalization_delivery_sends_the_durable_idempotency_keyasserts headers =={'X-Omi-Idempotency-Key': ...}; the code now also setsContent-Type: application/json.test_creation_webhook_payload_strips_geolocationreadscall_args.kwargs['json']→KeyError; it shouldjson.loads(kwargs['content']).
- Hygiene ratchet:
backend/testing/listen_pusher_stack/run.pygrew 1843 → 1844 lines; add theLine-Count-Exception:line to the PR body or absorb the line.
Design questions before merge
- Rollout coupling: with
OMI_PLUGIN_WEBHOOK_SECRETunset anywhere,resolve_authenticated_uidraises on the plugin side (secret=None is fail-closed;allow_uid_onlydefaults False) and the backend signs nothing — so github-app/dropbox-app webhooks and tools hard-fail 401 until the same secret is deployed to both the API and the plugin services, and the webhook circuit breaker may then disable those apps. This needs a coordinated config rollout plan (or an explicit shortallow_uid_onlymigration window) as part of landing it. - hey_omi uses a different scheme than the fleet:
plugins/notifications/hey_omi.pynow requiresAuthorization: Bearer <HEY_OMI_APP_SECRET>, but the backend's outbound realtime-integration call ({"session_id": uid, "segments": ...}inapp_integrations.py) sends only theX-Omi-*HMAC headers — no bearer. Unless something else furnishes that header, the "hey omi" webhook 401s post-deploy. Can hey_omi also accept the shared HMAC (omi_plugin_sdk.auth.verify_headers), or should the backend send an app-level bearer? - Setup-UI flows are intentionally disabled pending product work: the TODO(security) comments on
omi-github-app/main.py(/,/auth, and the/save-agent-keyJS which now surfaces an auth-required alert) andomi-dropbox-app/main.py(/settings,/disconnect) mean browser-driven mutations can't mint the plugin HMAC. Right security call, but save-key / update-repo / settings flows stay broken until setup URLs are signed on the product side — worth an explicit tracking issue so it isn't discovered in production.
What looks good (verified)
backend/utils/other/endpoints.py: the default flip to'false'is exactly the fail-closed behavior the title promises; constant-time compare and audit logging retained; the admin-routersecret-keypath untouched.backend/utils/plugin_auth.py↔plugins/omi-plugin-sdk/src/omi_plugin_sdk/auth.py: algorithms match (HMAC-SHA256(secret, "{uid}.{timestamp}." + body)), 300s max age,compare_digesteverywhere, uid-mismatch rejection, and both new test files cover roundtrip/tamper/skew/mismatch.plugins/oauth/client.py: HMAC-signed state with 600s expiry replaces bare-uid state; the callback inconversation_created.pyrejects invalid state with a restart-setup page.plugins/omi-dropbox-app/db.py: opaquetoken:<state>→ uid map with 10-min TTL and pop-once semantics, legacyuid:noncefallback retained.- Docs (
plugins/README.md, SDK README,backend/.env.template) accurately describe the new env vars and the uid-is-a-hint rule.
Requesting changes only for the CI items above — the security substance is in good shape. Leaving for human maintainer review: the coordinated OMI_PLUGIN_WEBHOOK_SECRET rollout decision across backend + plugin services, and the product call on signed setup URLs.
by AI on behalf of David — if you need David’s attention urgently, please @Git-on-my-level and escalate with need human response.
/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
- account_deletion_identity now sets ADMIN_KEY_AUTH_ENABLED=true so the hermetic e2e fixture authenticates via Bearer <ADMIN_KEY><uid> again; without it the token falls through to the LOCAL_DEVELOPMENT dev uid, writes the deletion marker to account_deletions/123, and 403s the rest of the suite with account_deletion_in_progress. - test_async_app_integrations: assert the Content-Type header the signed body path now sets, and read the delivered bytes via kwargs['content'] Amp-Thread-ID: https://ampcode.com/threads/T-01a0d867-2f0a-75f2-838d-07056aadf229 Co-authored-by: Max Carter <[email protected]>
Preserves both fail-closed auth layers on the github-app /tools/* routes: main's shared-secret bearer guard (require_github_tools_auth) and this PR's per-request plugin HMAC (_require_uid). Takes main's hardened input normalization (hey_omi webhook session/uid stripping, github-app issue-number coercion, repo short-name resolution, oauth.py setup URL query separator) while keeping the PR's HMAC fleet identity, signed OAuth state, and key-out-of-query-string save-agent-key POST body. Amp-Thread-ID: https://ampcode.com/threads/T-01a0d867-2f0a-75f2-838d-07056aadf229 Co-authored-by: Max Carter <[email protected]>
The plugin apps now import omi_plugin_sdk.auth, which the stdlib-only hermetic suites cannot import (package __init__ pulls pydantic-dependent models). File-load the real stdlib-only auth.py into each suite's stubs so the genuine HMAC scheme stays under test: - omi-github-app/test_main.py: _Request now carries request.body(), query_params, and real signed X-Omi-* headers (secret pinned via OMI_PLUGIN_WEBHOOK_SECRET); tool/JSON-endpoint tests updated to the new (request, body-uid) contracts. - omi-dropbox-app test_main + test_token_refresh_and_tools: real SDK auth stub + new db symbols (store_oauth_state_by_token, pop_oauth_uid_for_state). - plugins/test_oauth_error_params_escaped.py + test_uid_reflection_remaining_apps.py: permissive omi_plugin_sdk stub replaced with the real auth module; dropbox disconnect test now signs its request (HMAC required, query uid is a hint only). - notifications/test_hey_omi_extraction.py: webhook() takes (http_request, request) and requires inbound bearer auth; calls send an authenticated Starlette-style request and a new test pins the 401 fail-closed path. Pin a non-empty test secret (empty secret rejects all requests by design). Also fix a real reflected-XSS vector the uid-reflection suite caught: the github-app root page embedded the raw uid into the save-agent-key JS body string, where a uid containing </script> breaks out of the script block. Use the percent-encoded safe_uid like every other JS embedding in that template. TODO(security) markers now cite #13463 where the deferred signed-setup- URL work is tracked (deferred-work-markers gate). Amp-Thread-ID: https://ampcode.com/threads/T-01a0d867-2f0a-75f2-838d-07056aadf229 Co-authored-by: Max Carter <[email protected]>
|
@/tmp/pr-comment-current.md |
| logger.warning( | ||
| '%s unset — outbound plugin calls are unsigned; ' | ||
| 'plugins that enforce omi_plugin_sdk.auth will reject bare uid', | ||
| WEBHOOK_SECRET_ENV, |
Dismissing as stale: the blocking items in this review (missing ADMIN_KEY_AUTH_ENABLED in the account_deletion_identity E2E fixture, the two stale-contract tests in test_async_app_integrations.py, and the Hygiene line ratchet) are all verified fixed and green on the current head 69fc79b. Current follow-up is tracked in the new review (hey_omi inbound auth mismatch + a CodeQL false positive).
Git-on-my-level
left a comment
There was a problem hiding this comment.
Thanks @undivisible — this head resolves every blocking item from my earlier review. Verified on 69fc79b: the account_deletion_identity fixture in backend/testing/e2e/test_account_deletion_cloud_tasks.py now sets ADMIN_KEY_AUTH_ENABLED=true (Hermetic Backend E2E green); the two stale-contract tests in backend/tests/unit/test_async_app_integrations.py were updated for the content=/signed-bytes change (Backend unit + Hermetic Merge Gate green); Hygiene green.
The fail-closed core is in good shape: backend/utils/other/endpoints.py defaults the flag to 'false' while keeping the constant-time compare and audit logging; backend/utils/plugin_auth.py and plugins/omi-plugin-sdk/src/omi_plugin_sdk/auth.py agree on HMAC-SHA256(secret, "{uid}.{timestamp}." + body) with a 300s skew window and compare_digest throughout, and both new test files (backend/tests/unit/test_plugin_auth.py, plugins/omi-plugin-sdk/tests/test_auth.py) cover roundtrip/tamper/skew/mismatch from each side. plugins/oauth/client.py HMAC-signs the Notion state with a 600s window and plugins/oauth/conversation_created.py rejects invalid state with a restart-setup page; plugins/omi-dropbox-app/db.py adds the opaque token:<state> -> uid map with pop-once semantics; backend/routers/oauth.py, backend/utils/app_integrations.py, and backend/utils/retrieval/tools/app_tools.py now sign outbound plugin calls over the exact delivered bytes (GET signs an empty body — query params uncovered, as the code comment notes).
Two items before this moves forward:
-
hey_omi webhook will 401 every backend call.
plugins/notifications/hey_omi.py_require_hey_omi_inbound_authrequiresAuthorization: Bearer <HEY_OMI_APP_SECRET>and rejects everything else (fail-closed when unset), but the only caller,_async_trigger_realtime_integrationsinbackend/utils/app_integrations.py(payload{"session_id": uid, "segments": ...}), sends only theX-Omi-*HMAC headers, and nothing in the backend readsHEY_OMI_APP_SECRET. Post-deploy every realtime hey-omi delivery 401s, the journey fails, and the webhook circuit breaker will disable the app. Either have hey_omi also accept the shared plugin HMAC (omi_plugin_sdk.auth.verify_headers) alongside the bearer, or have the backend send an app-level bearer for this app. -
The CodeQL failure is a false positive. Alert 364 flags
backend/utils/plugin_auth.py:67as clear-text secret logging, but that line logsWEBHOOK_SECRET_ENV, the env-var name constant, not the value. It needs to be dismissed on the Code Scanning tab (a re-run alone won't clear it) so the check can go green.
Still maintainer decisions, non-blocking from my side: the coordinated OMI_PLUGIN_WEBHOOK_SECRET rollout across API + plugin services before enforcement flips live, and the product call on signing setup URLs — the TODO(security) comments in plugins/omi-github-app/main.py and plugins/omi-dropbox-app/main.py leave those browser flows intentionally broken pending that work, which deserves its own tracking issue so it isn't discovered in production.
I've dismissed my earlier changes-requested review since its blocking items were exactly those CI failures, all verified fixed. Requesting changes now only for the hey_omi auth mismatch. Because this changes the fleet-wide auth model and the ADMIN_KEY bypass default, it still needs maintainer sign-off on rollout sequencing 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.
Summary
Draft fix for the two omi P0s from the 2026-09-11 Grok audit (
.grok-audits/grok-audit-omi-20260911.mdon the auditor checkout). Based on currentorigin/main(worktree/Users/undivisible/projects/omi-sec-p0).P0-2 —
ADMIN_KEY_AUTH_ENABLEDfail-closedverify_tokennow defaultsADMIN_KEY_AUTH_ENABLEDto off (false).ADMIN_KEY_AUTH_ENABLED=trueintentionally for local/dev/CI/break-glass that needAuthorization: Bearer <ADMIN_KEY><uid>.secret-key: ADMIN_KEYis unchanged (separate path).listen_pusher_stack,sync_cloud_tasks_stack,replay_harness_phase0a) set the flag explicitly.P0-1 — Plugin fleet uid-as-auth (shared pattern)
omi_plugin_sdk.authHMAC helpers (X-Omi-Uid/X-Omi-Timestamp/X-Omi-Signature).OMI_PLUGIN_WEBHOOK_SECRETis set (backend/utils/plugin_auth.pymirrors the SDK algorithm)./save-agent-keyJSON body only, no key-in-query), tools, etc.Authorization: Bearer <HEY_OMI_APP_SECRET>How to enable
ADMIN_KEYimpersonation intentionallyDo not set
ADMIN_KEY_AUTH_ENABLED=truein prod overlays unless you have a dedicated break-glass plan.How to enable plugin HMAC
Until this secret is deployed to both backend and enforcing plugins, signed delivery is optional on the backend (warns once if unset) and enforcing plugin endpoints return 401 on bare uid (fail-closed).
Residual risk / follow-ups (out of scope for this PR)
app_home_url/ OAuth start (?uid=alone is still forgeable for setup/OAuth-start binding). TODOs left in GitHub/Dropbox setup + auth-start handlers.omi-*-appfleet (Notion app, Slack, Whoop, Shopify, …) not mass-migrated — SDK is ready; migrate per app.Test plan
plugins/omi-plugin-sdk/tests/test_auth.py(8 passed)backend/tests/unit/test_plugin_auth.py+test_verify_token_admin_and_local_dev_gating.py(14 passed)OMI_PLUGIN_WEBHOOK_SECRETto backend + GitHub/Dropbox plugins before relying on 401 enforcement in prodsecret-key: ADMIN_KEYstill work (impersonation flag does not gate them)Line-Count-Exception: backend/testing/listen_pusher_stack/run.py | 1843 -> 1844 | ADMIN_KEY_AUTH_ENABLED=true harness env line required so the hermetic listen/pusher stack keeps impersonation auth under the new fail-closed default
Failure-Class: FC-fixture-mock-signature-drift