Skip to content

fix(plugins): require auth on iq-rating routes keyed only by uid - #14431

Closed
hridaya423 wants to merge 2 commits into
BasedHardware:mainfrom
hridaya423:fix/iq-rating-auth
Closed

hridaya423 wants to merge 2 commits into
BasedHardware:mainfrom
hridaya423:fix/iq-rating-auth

Conversation

@hridaya423

@hridaya423 hridaya423 commented Sep 17, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #14430

Summary

The iq_rating router mounted in plugins/main.py trusts the client-supplied uid with no credential:

Route Unauthenticated effect
GET /iq-rating/iq/preload?uid= / GET /iq-rating/iq/refresh?uid= Triggers a scrape of all memories + conversations for any uid via the server-side OMI_APP_SECRET; extracted names stored in the plugin DB
GET /iq-rating/iq?uid= / GET /iq-rating/iq/api?uid= Publicly serves the extracted people names/IQ data
POST /iq/hide, /iq/unhide, /iq/adjust Mutates any uid's stored rows

One GET request converts a bare uid into a full conversation-history scrape with public read-back. Same contract violation as the merged mentor session fix (#13665), wider blast radius.

Fix

plugins/iq_rating/iq_auth.py mirrors the mentor/zapier pattern: IQ_RATING_SECRET env secret, Authorization: Bearer or iq_rating_token query param, hmac.compare_digest, fail-closed 503 when unconfigured, 401 on missing/mismatched token. Wired via Depends onto all six uid-keyed routes.

Left public deliberately: the uid-less /iq landing state (renders only the "add ?uid=" hint, no data path) and /iq/setup-status (Omi directory metadata).

Also fixed here

  • const uid = '{uid}' reflected-XSS sink, now json.dumps(uid).
  • The rendered page's hide/adjust fetches now carry the iq_rating_token query param so authenticated page actions keep working.

Residual + deployment note

  • The /iq HTML page is browser-facing: legitimate opens need iq_rating_token appended to the URL. Deployment must set IQ_RATING_SECRET and configure the Omi app/webview caller to send it, same shape as the merged mentor fix.
  • A per-user capability token (the security: P0 uid-as-auth + ADMIN_KEY default-off #13463 direction) would remove the shared-secret UX caveat; tracked on the issue.

Tests

python3 plugins/iq_rating/test_iq_auth.py: 11 tests, fail-closed unconfigured (503 incl. blank secret), missing/wrong/non-bearer token (401), bearer + query token accepted, uid trimming, optional-uid page gate, and a labeled static wiring check across all six routes plus the raw-uid JS sink.

Failure-Class: new — client-supplied uid accepted as authorization on unauthenticated plugin routes

The iq_rating router mounted in the plugins monolith trusts the
client-supplied uid with no credential:

- GET /iq-rating/iq/preload and /iq/refresh trigger a scrape of ALL
  memories and conversations for any uid via the server-side
  OMI_APP_SECRET
- GET /iq-rating/iq and /iq/api serve the extracted people names and
  scores for any uid (the HTML page embeds them publicly)
- POST /iq/hide, /iq/unhide, /iq/adjust mutate any uid's data

Same contract violation as the merged mentor session fix, wider blast
radius: one request converts a uid into a full memory/conversation
scrape.

Adds plugins/iq_rating/iq_auth.py mirroring the mentor/zapier pattern:
IQ_RATING_SECRET env secret, Bearer or iq_rating_token query param,
hmac.compare_digest, fail-closed 503 when unconfigured. Wired onto the
six uid-keyed data routes; the uid-less /iq landing state and
/iq/setup-status stay public.

Also escapes the uid embedded in the page JS (was a reflected-XSS
sink) and threads the query token into the page's hide/adjust fetches
so authenticated page actions keep working.

Deployment note: IQ_RATING_SECRET must be set and the Omi app/webview
caller must pass iq_rating_token, matching the mentor precedent.

Verification: python3 plugins/iq_rating/test_iq_auth.py — 11 tests
(fail-closed unconfigured, missing/wrong/non-bearer token, bearer and
query token accepted, uid trimming, optional-uid page gate, route
wiring) all pass.

Failure-Class: new — client-supplied uid accepted as authorization on
unauthenticated plugin routes
The query token was interpolated raw inside a single-quoted JS literal —
a token containing ' would break out of the string. json.dumps keeps it
inside a double-quoted literal with proper escaping, same as the uid fix.

Verified: render check with token x'-alert(1)-' produces
const tokenParam = "iq_rating_token=x'-alert(1)-'&";; 11 iq auth tests pass.

@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 against main and the head - this is a real fix for a real hole. Leaving merge sign-off to a human maintainer since it changes auth on a conversation-derived-data surface and needs deployment coordination.

What I verified

  • The vulnerability is real on main: plugins/main.py mounts the iq_rating router, and every data route took a bare client-supplied uid with no credential. load_and_process_user_data(uid) pages memories and conversations server-side using OMI_APP_SECRET, so one unauthenticated GET could scrape any uid, and /iq/api read the extracted names back.
  • plugins/iq_rating/iq_auth.py - a faithful mirror of the merged mentor pattern (plugins/basic/mentor_webhook_auth.py, #13665): hmac.compare_digest, Authorization: Bearer or iq_rating_token query param, fail-closed 503 when IQ_RATING_SECRET is unset or blank (the blank-string check is a nice touch), 401 otherwise, uid trimmed with 422 on empty.
  • plugins/iq_rating/main.py - all six uid-keyed routes (/iq/api, /iq/hide, /iq/unhide, /iq/adjust, /iq/preload, /iq/refresh) now resolve uid via Depends(require_iq_auth); the /iq page uses require_iq_auth_if_uid, so the uid-less landing state (empty-state hint only - no data path) stays public while any real uid requires the token. The reflected-XSS sink const uid = '{uid}' is gone - json.dumps(uid) emits a quoted JS string literal - and the hide/adjust fetches now encodeURIComponent(uid) and thread iq_rating_token through, so authenticated page actions keep working.
  • plugins/iq_rating/test_iq_auth.py - ran the suite in a sandbox against the head sources: 11/11 pass. Good coverage: fail-closed 503 (missing and blank secret), 401 (missing/wrong/non-Bearer token), Bearer and query-param acceptance, uid trimming, the if-uid variant, plus a static wiring test asserting every data route declares the dependency and the raw '{uid}' sink stays gone.

Notes for the maintainer

  • Merge requires deployment coordination: IQ_RATING_SECRET must be set and the app/webview caller updated to send it, otherwise the plugin fails closed with 503 by design (same rollout shape as the mentor fix).
  • /iq/setup-status and the uid-less /iq landing state remain public by design - correct: neither touches user data.
  • Non-blocking hardening nit: json.dumps does not escape /, so a uid (or an extracted person name) containing </script> can still terminate the script block in the rendered page. With the route now token-gated this is only reachable by callers holding the secret, but escaping < as \u003c at the embed sites would close it. The pre-existing error path also interpolates {e} into HTML.
  • The shared-secret-in-query tradeoff is inherited from the mentor pattern (tokens can land in access logs); the per-user capability direction noted on #14430 is the longer-term answer.

Since #14430 publicly documents the scrape primitive, prompt human sign-off and rollout would close that window; bounty adjudication also belongs to a human. Thanks for the clean fix and the hermetic test suite - it made this easy to verify.


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-maintainer-review Needs a human maintainer to sign off before merge positive-signal Automation verified a genuine fix/quality contribution python labels Sep 18, 2026
@aryanorastar

Copy link
Copy Markdown
Collaborator

Verified on b8bfade64ed7.

Leaving this open as the remaining-hole vehicle on plugins/iq_rating/iq_auth.py, plugins/iq_rating/main.py, plugins/iq_rating/test_iq_auth.py. remaining hole: iq-rating uid-only auth keep; 0-checks.

Not approving from here: hosted checks are not green (0-check / UNSTABLE / FTC). kodjima APPROVE is not a merge. I am not merging.

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

Reviewed b8bfade.

plugins/iq_rating/main.py iq_rating_api still raises HTTPException(..., detail=str(e)). This head wires Depends(require_iq_auth) and does not change that except. test_iq_auth.py never imports the route module. Mask the detail and import the route in the test.

@aryanorastar

Copy link
Copy Markdown
Collaborator

Keeping this open. Not approving b8bfade64ed7. plugins/iq_rating/main.py on origin/main keys rows by raw uid with no shared-secret guard. This sha adds iq_auth.py. 0 checks. MERGEABLE BLOCKED.

— Astar, on behalf of @aryanorastar

@omiagent

omiagent Bot commented Oct 1, 2026

Copy link
Copy Markdown
Contributor

Thanks for this fix, @hridaya423! Your commits are being carried forward in #20223 (cherry-picked with your original authorship intact) so they can land with the current CI and repo conventions. Closing this in favor of that branch — your contribution is credited there and in the git history.

@omiagent omiagent Bot closed this Oct 1, 2026
@github-actions

github-actions Bot commented Oct 1, 2026

Copy link
Copy Markdown
Contributor

Hey @hridaya423 👋

Thank you so much for taking the time to contribute to Omi! We truly appreciate you putting in the effort to submit this pull request.

After careful review, we've decided not to merge this particular PR. Please don't take this personally — we genuinely try to merge as many contributions as possible, but sometimes we have to make tough calls based on:

  • Project standards — Ensuring consistency across the codebase
  • User needs — Making sure changes align with what our users need
  • Code best practices — Maintaining code quality and maintainability
  • Project direction — Keeping aligned with our product principles and locked invariants

Before your next PR, please skim:

  • PRODUCT.md — product north star
  • Product invariants — locked rules (shared chat, memory tiers, agent control plane, integrations, brand)

If this was declined for direction or taste, maintainers should cite an invariant ID or open a proposed one — ask if that citation is missing.

Your contribution is still valuable to us, and we'd love to see you contribute again in the future! If you'd like feedback on how to improve this PR or want to discuss alternative approaches, please don't hesitate to reach out.

Thank you for being part of the Omi community!

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

Labels

needs-maintainer-review Needs a human maintainer to sign off before merge 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.

[Bounty $200] iq-rating routes scrape + expose any uid's memories/conversations with no auth

3 participants