Skip to content

fix(plugins): encode reflected uid in setup/auth pages across six apps - #13658

Open
Da7em-T wants to merge 3 commits into
BasedHardware:mainfrom
Da7em-T:fix/plugin-uid-html-encoding
Open

Da7em-T wants to merge 3 commits into
BasedHardware:mainfrom
Da7em-T:fix/plugin-uid-html-encoding

Conversation

@Da7em-T

@Da7em-T Da7em-T commented Sep 12, 2026 •

Copy link
Copy Markdown
Contributor

Summary

The client-controlled uid query param was reflected raw into HTML on the connect/setup pages of six plugins — auth_url = f"/auth?uid={uid}" rendered inside <a href="{auth_url}">, plus disconnect/back links, RedirectResponse targets, fetch() URLs, a value="{uid}" attribute, and a JS string literal in github's page:

  • omi-whoop-app, omi-twitter-chat-tools-app, omi-github-app, omi-notion-app, omi-clickup-app, omi-slack-app

uid=x" onmouseover="alert(1) breaks the href attribute — verified end-to-end: the raw payload reaches the rendered page. &, #, ? in a uid also corrupt the query param handed to the auth flow.

Each affected handler now percent-encodes uid once (uid_q = quote(uid, safe="")) for URL/href contexts; github's JS object literal uses json.dumps(uid); the value= attributes in the clickup/slack test pages use html.escape. Stats/logging paths keep the raw uid.

Verification

plugins/test_uid_reflection.py (new, hermetic, registered as plugin-uid-reflection-encoding-tests in .github/checks-manifest.yaml) loads each plugin's main.py with stubbed FastAPI/db/storage imports and drives the real root() handler on the not-connected branch:

  • uid='x" onmouseover="alert(1)&admin=1': on the old code every plugin emits a broken href (" onmouseover= survives — assertion fails on all six); with the fix the page carries x%22%20onmouseover%3D...
  • uid=user_123 still produces uid=user_123 links in all six pages

2/2 pass covering all six plugins; the injection assertion fails on the original code.

Failure-Class: none

Review in cubic

The client-controlled uid query param was interpolated raw into HTML on
the connect/setup pages of omi-whoop-app, omi-twitter-chat-tools-app,
omi-github-app, omi-notion-app, omi-clickup-app, and omi-slack-app:
auth_url = f"/auth?uid={uid}" inside <a href="{auth_url}">, plus
disconnect/back links, RedirectResponse targets, fetch() URLs, a
value="{uid}" attribute, and a JS string literal in github's page.

uid='x" onmouseover="alert(1)' breaks the attribute (verified: the raw
payload reaches the page); &, #, and ? corrupt the uid query param.

Each affected handler now percent-encodes uid once (uid_q) for URL
contexts; github's JS literal uses json.dumps; the value= attributes in
clickup/slack test pages use html.escape.

Verified: plugins/test_uid_reflection.py loads each plugin with stubbed
framework/db imports and drives the real root() handler — on old code
the hostile uid survives into a broken href (assertion fails on all
six); with the fix every page carries the percent-encoded uid. 2/2 pass
covering all six plugins.

Failure-Class: none

@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 8 files

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

Re-trigger cubic

Comment thread plugins/omi-notion-app/main.py Resolved
Comment thread plugins/omi-whoop-app/main.py Resolved
Comment thread plugins/omi-github-app/main.py Resolved
Comment thread plugins/omi-github-app/main.py Resolved
Comment thread plugins/omi-clickup-app/main.py Resolved
Comment thread plugins/omi-slack-app/main.py Resolved
Comment thread plugins/omi-clickup-app/main.py Resolved
Comment thread plugins/test_uid_reflection.py Resolved
Comment thread plugins/test_uid_reflection.py Resolved
Review follow-up: the previous commit computed uid_q at the top of the
OAuth callbacks, before uid was assigned, so every callback raised
UnboundLocalError. The encoding now happens after the state lookup has
produced and validated uid. Also escape <>& after json.dumps for the
uid injected into a script block (github dashboard), and route the
slack dev page client-side fetch URLs through encodeURIComponent.

Verification: python3 plugins/test_uid_reflection.py -> 6/6; the new
callback tests raise UnboundLocalError on the previous revision.

Failure-Class: none
Follow-up review fixes: the clickup /test?dev=true page also built
client-side fetch URLs from the raw DOM uid; route them through
encodeURIComponent like slack's. The regression suite now also covers
the OAuth callbacks, disconnect redirects, the github script-block uid,
the dev-page value attribute, and asserts %26 so an ampersand in uid
cannot inject a second query parameter.

Verification: python3 plugins/test_uid_reflection.py -> 7/7.

Failure-Class: none
@Git-on-my-level

Copy link
Copy Markdown
Member

Verified end-to-end — this is a clean, well-scoped security fix. I loaded all six plugin modules with stubbed imports and ran the new regression suite: 7/7 pass on this head, and the injection assertions fail on the pre-fix code (omi-whoop-app: attribute injection survived), so the tests are real regression guards rather than tautologies.

Per file:

  • plugins/omi-whoop-app/main.py, plugins/omi-notion-app/main.py, plugins/omi-twitter-chat-tools-app/main.py — root() now computes uid_q = quote(uid or "", safe="") before the auth link and disconnect href; the OAuth callbacks quote again after resolving uid from state (correct: the state carries the raw uid server-side, and the callback's HTML output context needs its own encode); the post-disconnect RedirectResponse(url=f"/?uid={uid_q}") is the right fix point. Leaving state = f"{uid}:{secrets.token_urlsafe(32)}" raw is correct — it is stored server-side and never reaches HTML.
  • plugins/omi-github-app/main.py — same uid_q treatment across all seven fetch() URLs, plus uid_js = json.dumps(uid).replace("<", "\\u003c")... for the inline uid: {uid_js} object. I checked that a uid of </script><script>alert(1)</script> renders as \u003c/script\u003e... — the script-context breakout is properly closed. Good catch that json.dumps alone is insufficient inside a <script> block.
  • plugins/omi-clickup-app/main.py, plugins/omi-slack-app/main.py — uid_q for server-rendered hrefs and fetch URLs, html.escape(uid, quote=True) for the dev-page value="{uid_h}" input attribute, and DOM-driven fetches moved to ${encodeURIComponent(uid)}. Each sink gets the encoding appropriate to its context. The session_id = f"omi_session_{uid}" uses stay raw, which is right for an internal dict key.
  • plugins/test_uid_reflection.py — genuinely hermetic (stubbed fastapi/db/requests modules, no network, no repo state) and it drives the real handlers: root() on the not-connected branch, all six OAuth callbacks including the invalid-state early returns, disconnect redirects, and the github </script> breakout.
  • .github/checks-manifest.yaml — one additive plugin-uid-reflection-encoding-tests entry in local+ci lanes with correct trigger paths and a truthful reason string; consistent with the surrounding schema.

Two notes:

  1. The failing Dart Analyze & Tests check is unrelated to this PR — the analyzer errors are in app/test/providers/deletion_consistency_test.dart and app/test/widgets/chat_content_blocks_test.dart, and the same job fails identically on sibling PRs that don't touch Dart (e.g. fix(google-calendar): encode calendar/event ids before URL paths #13657). That looks like pre-existing base breakage, not something to fix here.
  2. No double-encoding risk: uid_q is computed from the already-decoded query param, and I confirmed uid=user_123 still produces byte-identical links on all six pages.

Since this changes security-sensitive auth/setup page rendering across six plugins, I'd like a maintainer sign-off on the security fix before merge.


by AI on behalf of David — plugin OAuth setup-page injection fix needs maintainer security sign-off before merge.

@Git-on-my-level Git-on-my-level added positive-signal Automation verified a genuine fix/quality contribution security-review Touches auth, provider routing, secrets, or security-sensitive surfaces python labels Sep 12, 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.

Reflected uid encoded across six plugin setup/auth pages, hermetic tests prove pre/post behavior. CI: Dart Analyze & Tests fails on stale-base (unrelated compile error, fixed on current main) — approved, not merged.

@Git-on-my-level

Copy link
Copy Markdown
Member

Follow-up on the earlier automated verification, which asked for maintainer sign-off on the security fix before merge: that request is now satisfied by @kodjima33's approval on this head, so nothing further is being asked of the contributor.

Two closing notes:

  • The encoding fix and plugins/test_uid_reflection.py were re-verified independently on this head: the suite passes here, and its injection assertions fail on the merge base (omi-whoop-app: attribute injection survived), so it genuinely guards the regression rather than asserting the fix.
  • The failing Dart Analyze & Tests lane errors in app/test/providers/deletion_consistency_test.dart and app/test/widgets/chat_content_blocks_test.dart — files this Python-only diff does not touch. That is pre-existing base breakage, not a reason to hold this PR.

No further action requested from automation; the merge decision rests with maintainers.


by AI on behalf of David — if you need David’s attention urgently, please @Git-on-my-level and escalate with need human response.

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

Reflected-uid HTML/JS injection fix across 6 plugin setup pages; correct context-specific encoding (percent-encode for URLs, html.escape for attrs, JSON-safe escape for script), hermetic tests added.

@Git-on-my-level

Copy link
Copy Markdown
Member

Independent verification of the uid-encoding fix across the six plugin apps:

  • Reproduced the vulnerability: running plugins/test_uid_reflection.py against the pre-fix main.py files (base 9180aff) fails immediately with omi-whoop-app: attribute injection survived — the " onmouseover= payload survives in the rendered href. On this PR's head the suite passes 7/7 (run hermetically with stubbed FastAPI/db imports, no network, no secrets).
  • The per-context encoding choices check out:
    • plugins/omi-whoop-app/main.py, plugins/omi-notion-app/main.py, plugins/omi-twitter-chat-tools-app/main.py: uid_q = quote(uid, safe="") applied on the connect page, the callback success/error links, and the /disconnect RedirectResponse; the external provider auth URLs were already urlencoded.
    • plugins/omi-github-app/main.py: beyond uid_q, the uid: '{uid}' JS literal becomes uid: {uid_js} with \u003c-style escaping — correctly closes the </script> breakout that plain json.dumps would have left open.
    • plugins/omi-clickup-app/main.py / plugins/omi-slack-app/main.py: dev /test pages get html.escape on the value="{uid_h}" attribute and encodeURIComponent on every DOM-derived fetch URL (/setup-completed, /auth, /webhook, /logout).
  • uid_q is computed after the if not uid early return in each root() and derived once from the decoded query param, so normal uids don't double-encode (uid=user_123 is asserted by the suite); server-side token/state paths keep the raw uid.
  • .github/checks-manifest.yaml: the plugin-uid-reflection-encoding-tests entry is correctly placed inside checks: ahead of exempt:, with sensible triggers.

The red "Dart Analyze & Tests" check is unrelated to this PR: the errors are ActionItemsFetcher compile-time type mismatches in app/test/providers/deletion_consistency_test.dart and app/test/widgets/chat_content_blocks_test.dart, files this PR doesn't touch, and Mobile App Checks is green on current main (the failure reflects a transient window around the 2026-09-15 merge commit).

Two optional non-blocking follow-ups (both pre-existing): the OAuth callback error pages still reflect {str(e)} unescaped into HTML (e.g. the clickup auth_callback error branch), and the same encode-at-sink pattern is now repeated across six apps if a shared helper ever becomes attractive.

Nice fix — clear per-context encoding with a regression suite that demonstrably fails on the old code.


This review was conducted by an AI reviewing agent on behalf of the maintainers.


by AI on behalf of David — if you need David’s attention urgently, please @Git-on-my-level and escalate with need human response.

kodjima33 pushed a commit that referenced this pull request Sep 18, 2026
…tup pages (#14581)

Two unauthenticated routes render client-controlled input into HTML with no
encoding.

GET /auth/google/callback takes `error` straight off the query string and
interpolates it into the page body:

    <p>{error}</p>

so /auth/google/callback?error=<script>alert(1)</script> executes on the
plugin's origin. No code, state or prior session is needed — the `if error:`
branch is the first thing the handler does.

GET / reflects `uid` into two href attributes and a hidden input value; a uid
of "><script>alert(1)</script> breaks out of the attribute, and a bare & or #
corrupts the query instead.

Follows the encoding pattern of #13658 (six sibling apps) and #14579
(omi-dropbox-app): quote(uid, safe="") for URL contexts, html.escape() for
text and attribute contexts.

Verified:
- plugins/omi-google-calendar-app/test_uid_reflection.py — 5/5 pass on this head
- red→green: 3 of the 5 fail against main's plugin code; the other two are
  ordinary-input controls that pass both ways
- registered as gcal-uid-reflection-encoding-tests; manifest parses, 228
  checks, no duplicate ids

Failure-Class: none

Co-authored-by: Claude Opus 5 <[email protected]>
tluangtea-lab pushed a commit to tluangtea-lab/omi that referenced this pull request Sep 18, 2026
…ack pages

The OAuth callback error branches of omi-dropbox-app, omi-ms365-app,
and omi-notion-app interpolated the client-controlled error and
error_description query parameters into HTML without escaping, so a
crafted callback URL (e.g. error=<script>alert(1)</script>) is a
reflected-XSS vector on an unauthenticated route. Same class as the
uid reflections fixed in BasedHardware#14350 and PR BasedHardware#13658, via the error fields.

Verification:
- python3 plugins/test_oauth_error_params_escaped.py -> 3 passed
  (hermetic; drives the real auth_callback / notion_callback handlers
  through a hostile error value per app)
- same suite against unpatched main.py files -> dropbox fails at the
  script-reflection assertion (execution stops at the first failure)

Failure-Class: new
tluangtea-lab pushed a commit to tluangtea-lab/omi that referenced this pull request Sep 18, 2026
…ack pages

The OAuth callback error branches of omi-dropbox-app, omi-ms365-app,
and omi-notion-app interpolated the client-controlled error and
error_description query parameters into HTML without escaping, so a
crafted callback URL (e.g. error=<script>alert(1)</script>) is a
reflected-XSS vector on an unauthenticated route. Same class as the
uid reflections fixed in BasedHardware#14350 and PR BasedHardware#13658, via the error fields.

Verification:
- python3 plugins/test_oauth_error_params_escaped.py -> 3 passed
  (hermetic; drives the real auth_callback / notion_callback handlers
  through a hostile error value per app)
- same suite against unpatched main.py files -> dropbox fails at the
  script-reflection assertion (execution stops at the first failure)

Failure-Class: new
Mateidslx added a commit to Mateidslx/omi that referenced this pull request Sep 18, 2026
`GET /auth/whoop/callback?error=...` is unauthenticated. The current
`main` branch interpolates the `error` OAuth parameter directly into
`<p>{error}</p>` without `html.escape`, so an attacker can craft a URL
that injects arbitrary HTML/JS into the callback page (reflected XSS,
no preconditions).

Fix: add `import html` (stdlib, no new dependency) and replace
`<p>{error}</p>` with `<p>{html.escape(error or "", quote=True)}</p>`.

Deconfliction:
- PR BasedHardware#13658 encodes uid in redirect URLs (different sink, different lines)
- PR BasedHardware#14504 escapes str(e) in except block (different sink, different lines)
- This sink ({error} in <p>) is not covered by either open PR
kodjima33 pushed a commit that referenced this pull request Sep 19, 2026
…ge (#14603) (#14604)

* fix(whoop-app): escape OAuth `error` parameter in callback failure page

`GET /auth/whoop/callback?error=...` is unauthenticated. The current
`main` branch interpolates the `error` OAuth parameter directly into
`<p>{error}</p>` without `html.escape`, so an attacker can craft a URL
that injects arbitrary HTML/JS into the callback page (reflected XSS,
no preconditions).

Fix: add `import html` (stdlib, no new dependency) and replace
`<p>{error}</p>` with `<p>{html.escape(error or "", quote=True)}</p>`.

Deconfliction:
- PR #13658 encodes uid in redirect URLs (different sink, different lines)
- PR #14504 escapes str(e) in except block (different sink, different lines)
- This sink ({error} in <p>) is not covered by either open PR

* test(whoop-app): hermetic regression for OAuth callback error escaping

Six stdlib-only tests confirm that the `error` OAuth parameter is
now HTML-escaped before insertion into <p>, and that benign error
codes still render correctly.

* style(whoop): normalize line endings to LF for clean 2-line diff

* style(whoop): normalize test file line endings to LF
tluangtea-lab pushed a commit to tluangtea-lab/omi that referenced this pull request Sep 20, 2026
…hrefs

GET /auth/callback's error branch interpolated the client-controlled
`state` query param raw into <a href="/auth?uid={error_uid}">, and
GET / interpolated `uid` raw into <a href="{auth_url}">. A crafted
state like "><script>alert(1)</script> was reflected unescaped into
the 500 error page (reflected XSS on an unauthenticated route); a
bare & or # corrupted the retry link.

Percent-encode both values once at their reflection sites
(urllib.parse.quote), matching the hardening already applied to six
other plugin apps in PR BasedHardware#13658.

Verification:
- python3 plugins/test_uid_reflection_twitter.py -> 5 passed; on
  unpatched main the suite fails at the script-tag reflection
  assertion (regression test reproduces the issue first)
- real FastAPI TestClient round-trip on the patched app:
  GET /auth/callback?code=x&state="><script>alert(1)</script>&x=1#frag
  -> 500 page with uid=%22%3E%3Cscript%3E...%26x%3D1%23frag, no raw
  script; GET /?uid='x" onmouseover="alert(1)&admin=1' -> attribute
  intact, %22/%26 encoded; benign uid=user_123 still links
- registered plugin-twitter-app-uid-state-reflection-tests in
  .github/checks-manifest.yaml (local + ci lanes)

Failure-Class: new
tluangtea-lab pushed a commit to tluangtea-lab/omi that referenced this pull request Sep 20, 2026
…n apps

Seven plugin apps still reflected the client-controlled uid query
parameter into URLs without encoding: HTML form actions and hrefs
(dropbox, google-calendar), a hidden input value (google-calendar),
and redirect targets (dropbox, hive, linear, ms365, shipbob, shopify).
A uid containing a double quote breaks out of the attribute (reflected
XSS on an unauthenticated page); a bare & or # corrupts the query
handed to the next hop. The same hardening already landed for six apps
in PR BasedHardware#13658 and for omi-twitter-app via BasedHardware#14350; this completes the
sweep for the remaining apps.

Each encoded value is computed once per handler (urllib.parse.quote,
safe=''), and google-calendar's callback error page additionally
HTML-escapes the client-controlled error parameter it renders.

Verification:
- python3 plugins/test_uid_reflection_remaining_apps.py -> 9 passed
  (hermetic: AST-driven per-app import stubbing; drives the real
  handlers - dropbox home connected/unconnected + disconnect, gcal root
  unconnected + disconnect + update-calendar + callback error page,
  hive/ms365/shipbob/shopify/linear disconnect or setup handlers, and
  linear's home template context)
- registered plugin-remaining-apps-uid-reflection-tests in
  .github/checks-manifest.yaml (local + ci lanes)

Failure-Class: new
tluangtea-lab pushed a commit to tluangtea-lab/omi that referenced this pull request Sep 20, 2026
…ack pages

The OAuth callback error branches of omi-dropbox-app, omi-ms365-app,
and omi-notion-app interpolated the client-controlled error and
error_description query parameters into HTML without escaping, so a
crafted callback URL (e.g. error=<script>alert(1)</script>) is a
reflected-XSS vector on an unauthenticated route. Same class as the
uid reflections fixed in BasedHardware#14350 and PR BasedHardware#13658, via the error fields.

Verification:
- python3 plugins/test_oauth_error_params_escaped.py -> 3 passed
  (hermetic; drives the real auth_callback / notion_callback handlers
  through a hostile error value per app)
- same suite against unpatched main.py files -> dropbox fails at the
  script-reflection assertion (execution stops at the first failure)

Failure-Class: new
tluangtea-lab pushed a commit to tluangtea-lab/omi that referenced this pull request Sep 20, 2026
…lure pages

Five plugin apps' OAuth callback failure branches interpolated dynamic
strings into HTMLResponses without escaping:

- omi-dropbox-app: token-exchange failure rendered the provider
  response body raw; the exception path rendered str(e) raw
- omi-google-calendar-app: exception path rendered str(e) raw
- omi-twitter-chat-tools-app: token-exchange failure rendered the
  provider response body raw; exception path rendered str(e) raw
- omi-whoop-app: exception path rendered str(e) raw

HTMLResponse defaults to text/html, so raw provider bodies or exception
messages that embed a crafted URL execute as markup in the browser -
the same reflected-content class as the uid fixes (BasedHardware#14350, BasedHardware#13658).

Verification:
- python3 plugins/test_callback_error_pages_escaped.py -> 6 passed
  (hermetic; drives the real callbacks through a failing token exchange
  and a raising transport, asserting the escaped form and no raw script)
- registered plugin-callback-error-pages-escaped-tests in
  .github/checks-manifest.yaml (local + ci lanes)

Failure-Class: new
t3ratech added a commit to t3ratech/omi that referenced this pull request Sep 20, 2026
…setup page

GET / on omi-dropbox-app is unauthenticated and takes uid straight off the
query string, then renders it into href/action attributes:

    <a href="/auth/dropbox?uid={uid}" class="btn">Connect Dropbox</a>

A uid of "><script>alert(1)</script> breaks out of the attribute and executes
on the plugin's origin. A bare & or # silently corrupts the query instead.

folder_name is a second, stored sink: the user sets it via POST /settings and
it is rendered back into value="{...}" with no escaping. display_name/email
from Dropbox and the auth-callback error page (which interpolated str(e)) are
escaped for the same reason.

Follows the encoding pattern of BasedHardware#13658, which fixed this class in six sibling
apps but did not cover omi-dropbox-app: quote(uid, safe="") for URL contexts,
html.escape() for text and attribute contexts.

Verified:
- plugins/omi-dropbox-app/test_uid_reflection.py — 6/6 pass on this head
- red→green: 5 of the 6 fail against main's plugin code (the sixth is the
  "ordinary uid still renders" control, which passes both ways)
- registered as dropbox-uid-reflection-encoding-tests; manifest parses,
  228 checks, no duplicate ids

Failure-Class: none

Co-Authored-By: Claude Opus 5 <[email protected]>
@aryanorastar

Copy link
Copy Markdown
Collaborator

Keeping this open on be3204d87f7e.

DIRTY + Dart Analyze red; six-app reflected uid encode + tests; kodjima APPROVE ≠ merge.

kodjima APPROVE is the size gate, not maintainer merge.

I am not approving or merging this SHA.

tluangtea-lab pushed a commit to tluangtea-lab/omi that referenced this pull request Sep 20, 2026
…n apps

Seven plugin apps still reflected the client-controlled uid query
parameter into URLs without encoding: HTML form actions and hrefs
(dropbox, google-calendar), a hidden input value (google-calendar),
and redirect targets (dropbox, hive, linear, ms365, shipbob, shopify).
A uid containing a double quote breaks out of the attribute (reflected
XSS on an unauthenticated page); a bare & or # corrupts the query
handed to the next hop. The same hardening already landed for six apps
in PR BasedHardware#13658 and for omi-twitter-app via BasedHardware#14350; this completes the
sweep for the remaining apps.

Each encoded value is computed once per handler (urllib.parse.quote,
safe=''), and google-calendar's callback error page additionally
HTML-escapes the client-controlled error parameter it renders.

Verification:
- python3 plugins/test_uid_reflection_remaining_apps.py -> 9 passed
  (hermetic: AST-driven per-app import stubbing; drives the real
  handlers - dropbox home connected/unconnected + disconnect, gcal root
  unconnected + disconnect + update-calendar + callback error page,
  hive/ms365/shipbob/shopify/linear disconnect or setup handlers, and
  linear's home template context)
- registered plugin-remaining-apps-uid-reflection-tests in
  .github/checks-manifest.yaml (local + ci lanes)

Failure-Class: new
tluangtea-lab pushed a commit to tluangtea-lab/omi that referenced this pull request Sep 20, 2026
…lure pages

Five plugin apps' OAuth callback failure branches interpolated dynamic
strings into HTMLResponses without escaping:

- omi-dropbox-app: token-exchange failure rendered the provider
  response body raw; the exception path rendered str(e) raw
- omi-google-calendar-app: exception path rendered str(e) raw
- omi-twitter-chat-tools-app: token-exchange failure rendered the
  provider response body raw; exception path rendered str(e) raw
- omi-whoop-app: exception path rendered str(e) raw

HTMLResponse defaults to text/html, so raw provider bodies or exception
messages that embed a crafted URL execute as markup in the browser -
the same reflected-content class as the uid fixes (BasedHardware#14350, BasedHardware#13658).

Verification:
- python3 plugins/test_callback_error_pages_escaped.py -> 6 passed
  (hermetic; drives the real callbacks through a failing token exchange
  and a raising transport, asserting the escaped form and no raw script)
- registered plugin-callback-error-pages-escaped-tests in
  .github/checks-manifest.yaml (local + ci lanes)

Failure-Class: new
tluangtea-lab pushed a commit to tluangtea-lab/omi that referenced this pull request Sep 20, 2026
…ack pages

The OAuth callback error branches of omi-dropbox-app, omi-ms365-app,
and omi-notion-app interpolated the client-controlled error and
error_description query parameters into HTML without escaping, so a
crafted callback URL (e.g. error=<script>alert(1)</script>) is a
reflected-XSS vector on an unauthenticated route. Same class as the
uid reflections fixed in BasedHardware#14350 and PR BasedHardware#13658, via the error fields.

Verification:
- python3 plugins/test_oauth_error_params_escaped.py -> 3 passed
  (hermetic; drives the real auth_callback / notion_callback handlers
  through a hostile error value per app)
- same suite against unpatched main.py files -> dropbox fails at the
  script-reflection assertion (execution stops at the first failure)

Failure-Class: new

@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 reflected-uid HTML injection across six plugin setup pages (whoop, twitter-chat-tools, github, notion, clickup, slack), fixed with consistent percent-encoding/html.escape at each sink, hermetic test drives the real handlers pre/post fix. Only red check is the same pre-existing unrelated Dart compile error.

@aryanorastar

Copy link
Copy Markdown
Collaborator

Verified on be3204d87f7e.

This stays the six-app reflected-uid vehicle. Whoop, twitter-chat-tools, github, notion, and clickup still interpolate raw uid on current main.

Slack uid quote(..., safe="") already landed in merged #14877, which is why plugins/omi-slack-app/main.py conflicts. Complementary to #13659 / #14502, not a later copy of #14882.

I am not approving or merging this SHA. GitHub reports CONFLICTING/DIRTY on .github/checks-manifest.yaml plus clickup/github/notion/slack main.py. Please rebase onto current main and union the manifest — do not resolve those files in the web editor.

kodjima APPROVE is the size gate, not merge. Dart Analyze is still the unrelated flake.

tluangtea-lab pushed a commit to tluangtea-lab/omi that referenced this pull request Sep 21, 2026
…lure pages

Five plugin apps' OAuth callback failure branches interpolated dynamic
strings into HTMLResponses without escaping:

- omi-dropbox-app: token-exchange failure rendered the provider
  response body raw; the exception path rendered str(e) raw
- omi-google-calendar-app: exception path rendered str(e) raw
- omi-twitter-chat-tools-app: token-exchange failure rendered the
  provider response body raw; exception path rendered str(e) raw
- omi-whoop-app: exception path rendered str(e) raw

HTMLResponse defaults to text/html, so raw provider bodies or exception
messages that embed a crafted URL execute as markup in the browser -
the same reflected-content class as the uid fixes (BasedHardware#14350, BasedHardware#13658).

Verification:
- python3 plugins/test_callback_error_pages_escaped.py -> 6 passed
  (hermetic; drives the real callbacks through a failing token exchange
  and a raising transport, asserting the escaped form and no raw script)
- registered plugin-callback-error-pages-escaped-tests in
  .github/checks-manifest.yaml (local + ci lanes)

Failure-Class: new
tluangtea-lab pushed a commit to tluangtea-lab/omi that referenced this pull request Sep 21, 2026
…n apps

Seven plugin apps still reflected the client-controlled uid query
parameter into URLs without encoding: HTML form actions and hrefs
(dropbox, google-calendar), a hidden input value (google-calendar),
and redirect targets (dropbox, hive, linear, ms365, shipbob, shopify).
A uid containing a double quote breaks out of the attribute (reflected
XSS on an unauthenticated page); a bare & or # corrupts the query
handed to the next hop. The same hardening already landed for six apps
in PR BasedHardware#13658 and for omi-twitter-app via BasedHardware#14350; this completes the
sweep for the remaining apps.

Each encoded value is computed once per handler (urllib.parse.quote,
safe=''), and google-calendar's callback error page additionally
HTML-escapes the client-controlled error parameter it renders.

Verification:
- python3 plugins/test_uid_reflection_remaining_apps.py -> 9 passed
  (hermetic: AST-driven per-app import stubbing; drives the real
  handlers - dropbox home connected/unconnected + disconnect, gcal root
  unconnected + disconnect + update-calendar + callback error page,
  hive/ms365/shipbob/shopify/linear disconnect or setup handlers, and
  linear's home template context)
- registered plugin-remaining-apps-uid-reflection-tests in
  .github/checks-manifest.yaml (local + ci lanes)

Failure-Class: new
tluangtea-lab pushed a commit to tluangtea-lab/omi that referenced this pull request Sep 21, 2026
…ack pages

The OAuth callback error branches of omi-dropbox-app, omi-ms365-app,
and omi-notion-app interpolated the client-controlled error and
error_description query parameters into HTML without escaping, so a
crafted callback URL (e.g. error=<script>alert(1)</script>) is a
reflected-XSS vector on an unauthenticated route. Same class as the
uid reflections fixed in BasedHardware#14350 and PR BasedHardware#13658, via the error fields.

Verification:
- python3 plugins/test_oauth_error_params_escaped.py -> 3 passed
  (hermetic; drives the real auth_callback / notion_callback handlers
  through a hostile error value per app)
- same suite against unpatched main.py files -> dropbox fails at the
  script-reflection assertion (execution stops at the first failure)

Failure-Class: new
@aryanorastar

Copy link
Copy Markdown
Collaborator

Whoop, Twitter chat tools, and ClickUp setup URLs on main still interpolate a raw uid. This head quotes those. GitHub, Notion, and Slack hunks in the same diff are already encoded on main, so rebase be3204d87f7e. This stays open and unapproved.

— Astar, on behalf of @aryanorastar

aryanorastar added a commit that referenced this pull request Sep 22, 2026
…ack error page (#14352)

## What

The Twitter voice-posting plugin's OAuth callback error page
(`plugins/omi-twitter-app/main_simple.py`, `GET /auth/callback`) now
percent-encodes and HTML-escapes the `state` query param before building
its "Try again" link, instead of reflecting the raw value into an `href`
attribute. Fixes #14350.

## Why

Any token-exchange failure renders the error page, and its link was
`f'<a href="/auth?uid={error_uid}">'` with `error_uid = state`, where
`state` is `Query(None)` straight from the request. On current `main`:

```
GET /auth/callback?code=x&state=%22%3E%3Cscript%3Ealert(1)%3C/script%3E
->  <p><a href="/auth?uid="><script>alert(1)</script>">Try again</a></p>
```

The quote closes the attribute and the script executes on the plugin's
origin (reflected XSS). The branch is reachable without any session: a
`state` with no stored OAuth handler makes `get_access_token()` raise
`OAuth session not found`, which is the path that renders the page. A
benign `&` or `#` in `state` corrupted the retry query the same way.

The value is now encoded at both boundaries it crosses —
`urllib.parse.quote(value, safe="")` for the query, `html.escape(...,
quote=True)` for the attribute — so the link still carries the original
value (it round-trips through `parse_qs`) but can no longer break out of
the `href`.

## Changes

- `plugins/omi-twitter-app/main_simple.py`: import `html` and
`urllib.parse.quote`; the callback error page interpolates
`html.escape(quote(state, safe=""), quote=True)`.
- Second commit (leave it better, same file): the setup page at `GET
/?uid=` built its "Connect Twitter Account" link as `f"/auth?uid={uid}"`
inside an `href` — the same raw reflection. Encoded the same way.
omi-twitter-app is not among the six apps the pattern-wide PR #13658
covers; no overlap with that diff. Open PR #13782 also edits
`main_simple.py`, but only its logging lines (hunks at `main` lines
222-231, 638-649, 665-671 and 697-752); this branch touches the import
block, `root()` (`main_simple.py:29-35`) and the `auth_callback` error
branch (`:523-536`), so the two do not overlap textually either.
- `plugins/omi-twitter-app/test_callback_error_escaping.py` (new):
hermetic regression test — stubs FastAPI, dotenv and the sibling
modules, drives the real `auth_callback` handler down its error branch
and the real `root` handler, parses the page with `html.parser` the way
a browser would and pins that no `<script>` element opens, the `href` is
percent-encoded, `&`/`#` cannot corrupt the query, and the uid
round-trips; plain and missing `state` keep their links unchanged.
- `.github/checks-manifest.yaml`: registers
`twitter-app-callback-error-escaping-tests` (local + ci lanes, triggered
by `plugins/omi-twitter-app/**`).

## Tests

```
PYTHONUTF8=1 python3 plugins/omi-twitter-app/test_callback_error_escaping.py
PASS test_script_in_state_is_not_reflected_raw
PASS test_try_again_link_round_trips_state
PASS test_plain_state_link_is_unchanged
PASS test_missing_state_falls_back_to_unknown
PASS test_setup_page_encodes_uid_in_connect_link
5 tests passed
```

Same test against `main`'s `main_simple.py` fails as intended (control
cases pass):

```
FAIL test_script_in_state_is_not_reflected_raw: ... <a href="/auth?uid="><script>alert(1)</script>">Try again</a> ...
FAIL test_try_again_link_round_trips_state: ('"><script>alert(1)</script>', '/auth?uid=')
PASS test_plain_state_link_is_unchanged
PASS test_missing_state_falls_back_to_unknown
FAIL test_setup_page_encodes_uid_in_connect_link: ['/auth?uid=']
```

Also run: `python3 plugins/oauth/test_client_log_safety.py` (OK, 5
tests), `git diff --check main..fix/twitter-app-callback-xss` (clean),
`bash scripts/pr-preflight --pr-body-file <this body>` (passed). The
live path (a real Twitter OAuth round trip on a deployed instance with
client credentials) needs a Railway deployment and X app keys I do not
have; the handlers were exercised through the hermetic harness above,
which calls the real functions with only FastAPI and the network-bound
siblings stubbed.

## Failure-Class

Failure-Class: none

(`scripts/failure-class prepare` validates the declaration (`OK:
prepare`, patch operation=none) and none of the 253 registry definitions
describes client input reflected unescaped into HTML; the advisory
candidates it surfaced for this path —
nonexecuting-verification-command, runtime-image-boundary,
secret-printed-to-plugin-logs — do not apply.)

## Invariants

`scripts/pr-preflight --suggest` reports no affected product invariants
for this diff (plugin-only change).

## Bounty

Claims the US$25 proposed in #14350; payout details will be sent to
[email protected] after merge as the Contribution guide asks.

<sub>Authored with Claude Code on behalf of @Suyann; every command
listed was actually run on this branch.</sub>


<!-- This is an auto-generated description by cubic. -->
<a
href="https://cubic.dev/pr/BasedHardware/omi/pull/14352?utm_source=github"
target="_blank" rel="noopener noreferrer"
data-no-image-dialog="true"><picture><source
media="(prefers-color-scheme: dark)"
srcset="https://www.cubic.dev/buttons/review-in-cubic-dark.svg"><source
media="(prefers-color-scheme: light)"
srcset="https://www.cubic.dev/buttons/review-in-cubic-light.svg"><img
alt="Review in cubic"
src="https://www.cubic.dev/buttons/review-in-cubic-dark.svg"></picture></a>
<!-- End of auto-generated description by cubic. -->
t3ratech added a commit to t3ratech/omi that referenced this pull request Sep 22, 2026
…setup page

GET / on omi-dropbox-app is unauthenticated and takes uid straight off the
query string, then renders it into href/action attributes:

    <a href="/auth/dropbox?uid={uid}" class="btn">Connect Dropbox</a>

A uid of "><script>alert(1)</script> breaks out of the attribute and executes
on the plugin's origin. A bare & or # silently corrupts the query instead.

folder_name is a second, stored sink: the user sets it via POST /settings and
it is rendered back into value="{...}" with no escaping. display_name/email
from Dropbox and the auth-callback error page (which interpolated str(e)) are
escaped for the same reason.

Follows the encoding pattern of BasedHardware#13658, which fixed this class in six sibling
apps but did not cover omi-dropbox-app: quote(uid, safe="") for URL contexts,
html.escape() for text and attribute contexts.

Verified:
- plugins/omi-dropbox-app/test_uid_reflection.py — 6/6 pass on this head
- red→green: 5 of the 6 fail against main's plugin code (the sixth is the
  "ordinary uid still renders" control, which passes both ways)
- registered as dropbox-uid-reflection-encoding-tests; manifest parses,
  228 checks, no duplicate ids

Failure-Class: none

Co-Authored-By: Claude Opus 5 <[email protected]>
kodjima33 pushed a commit that referenced this pull request Sep 22, 2026
…n apps (#14502)

* fix(plugins): percent-encode reflected uid across the remaining plugin apps

Seven plugin apps still reflected the client-controlled uid query
parameter into URLs without encoding: HTML form actions and hrefs
(dropbox, google-calendar), a hidden input value (google-calendar),
and redirect targets (dropbox, hive, linear, ms365, shipbob, shopify).
A uid containing a double quote breaks out of the attribute (reflected
XSS on an unauthenticated page); a bare & or # corrupts the query
handed to the next hop. The same hardening already landed for six apps
in PR #13658 and for omi-twitter-app via #14350; this completes the
sweep for the remaining apps.

Each encoded value is computed once per handler (urllib.parse.quote,
safe=''), and google-calendar's callback error page additionally
HTML-escapes the client-controlled error parameter it renders.

Verification:
- python3 plugins/test_uid_reflection_remaining_apps.py -> 9 passed
  (hermetic: AST-driven per-app import stubbing; drives the real
  handlers - dropbox home connected/unconnected + disconnect, gcal root
  unconnected + disconnect + update-calendar + callback error page,
  hive/ms365/shipbob/shopify/linear disconnect or setup handlers, and
  linear's home template context)
- registered plugin-remaining-apps-uid-reflection-tests in
  .github/checks-manifest.yaml (local + ci lanes)

Failure-Class: new

* test(omi-hive-app): update create-task fixture to the (project, candidates) contract

find_project_by_name returns (project, candidates) since the
disambiguation work, but test_create_task_success still stubbed the
old single-project return, so the handler raised TypeError on the
unpack and the lane has been red on main for every hive change.

Repair the fixture, restore the lane to green:

- python3 plugins/omi-hive-app/test_main.py -> 7 tests OK

* fix: drop duplicate gcal-uid-reflection-encoding-tests manifest id

* test: stub fastapi.Depends so shipbob uid-reflection suite imports

---------

Co-authored-by: omi-bounty-contributor <[email protected]>
kodjima33 pushed a commit that referenced this pull request Sep 22, 2026
…ack pages (#14503)

* fix(plugins): html-escape reflected OAuth error params in three callback pages

The OAuth callback error branches of omi-dropbox-app, omi-ms365-app,
and omi-notion-app interpolated the client-controlled error and
error_description query parameters into HTML without escaping, so a
crafted callback URL (e.g. error=<script>alert(1)</script>) is a
reflected-XSS vector on an unauthenticated route. Same class as the
uid reflections fixed in #14350 and PR #13658, via the error fields.

Verification:
- python3 plugins/test_oauth_error_params_escaped.py -> 3 passed
  (hermetic; drives the real auth_callback / notion_callback handlers
  through a hostile error value per app)
- same suite against unpatched main.py files -> dropbox fails at the
  script-reflection assertion (execution stops at the first failure)

Failure-Class: new

* fix: put oauth-error-params check under checks:, valid YAML

---------

Co-authored-by: omi-bounty-contributor <[email protected]>
tluangtea-lab pushed a commit to tluangtea-lab/omi that referenced this pull request Sep 22, 2026
…lure pages

Five plugin apps' OAuth callback failure branches interpolated dynamic
strings into HTMLResponses without escaping:

- omi-dropbox-app: token-exchange failure rendered the provider
  response body raw; the exception path rendered str(e) raw
- omi-google-calendar-app: exception path rendered str(e) raw
- omi-twitter-chat-tools-app: token-exchange failure rendered the
  provider response body raw; exception path rendered str(e) raw
- omi-whoop-app: exception path rendered str(e) raw

HTMLResponse defaults to text/html, so raw provider bodies or exception
messages that embed a crafted URL execute as markup in the browser -
the same reflected-content class as the uid fixes (BasedHardware#14350, BasedHardware#13658).

Verification:
- python3 plugins/test_callback_error_pages_escaped.py -> 6 passed
  (hermetic; drives the real callbacks through a failing token exchange
  and a raising transport, asserting the escaped form and no raw script)
- registered plugin-callback-error-pages-escaped-tests in
  .github/checks-manifest.yaml (local + ci lanes)

Failure-Class: new
t3ratech added a commit to t3ratech/omi that referenced this pull request Sep 23, 2026
…setup page

GET / on omi-dropbox-app is unauthenticated and takes uid straight off the
query string, then renders it into href/action attributes:

    <a href="/auth/dropbox?uid={uid}" class="btn">Connect Dropbox</a>

A uid of "><script>alert(1)</script> breaks out of the attribute and executes
on the plugin's origin. A bare & or # silently corrupts the query instead.

folder_name is a second, stored sink: the user sets it via POST /settings and
it is rendered back into value="{...}" with no escaping. display_name/email
from Dropbox and the auth-callback error page (which interpolated str(e)) are
escaped for the same reason.

Follows the encoding pattern of BasedHardware#13658, which fixed this class in six sibling
apps but did not cover omi-dropbox-app: quote(uid, safe="") for URL contexts,
html.escape() for text and attribute contexts.

Verified:
- plugins/omi-dropbox-app/test_uid_reflection.py — 6/6 pass on this head
- red→green: 5 of the 6 fail against main's plugin code (the sixth is the
  "ordinary uid still renders" control, which passes both ways)
- registered as dropbox-uid-reflection-encoding-tests; manifest parses,
  228 checks, no duplicate ids

Failure-Class: none

Co-Authored-By: Claude Opus 5 <[email protected]>
@aryanorastar

Copy link
Copy Markdown
Collaborator

Keeping this open. Not approving be3204d87f7e. origin/main ClickUp main.py already html.escape/quote. CONFLICTING/DIRTY, CI FAILURE. Do not approve.

— Astar, on behalf of @aryanorastar

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

be3204d87f7e — plugins/omi-clickup-app/main.py, plugins/omi-github-app/main.py, and plugins/omi-slack-app/main.py still render Failed to complete authentication: {str(e)}. That detail has to be a fixed string.

undivisible pushed a commit that referenced this pull request Oct 19, 2026
…setup page (#14578) (#14579)

* fix(dropbox-app): encode reflected uid and escape stored settings in setup page

GET / on omi-dropbox-app is unauthenticated and takes uid straight off the
query string, then renders it into href/action attributes:

    <a href="/auth/dropbox?uid={uid}" class="btn">Connect Dropbox</a>

A uid of "><script>alert(1)</script> breaks out of the attribute and executes
on the plugin's origin. A bare & or # silently corrupts the query instead.

folder_name is a second, stored sink: the user sets it via POST /settings and
it is rendered back into value="{...}" with no escaping. display_name/email
from Dropbox and the auth-callback error page (which interpolated str(e)) are
escaped for the same reason.

Follows the encoding pattern of #13658, which fixed this class in six sibling
apps but did not cover omi-dropbox-app: quote(uid, safe="") for URL contexts,
html.escape() for text and attribute contexts.

Verified:
- plugins/omi-dropbox-app/test_uid_reflection.py — 6/6 pass on this head
- red→green: 5 of the 6 fail against main's plugin code (the sixth is the
  "ordinary uid still renders" control, which passes both ways)
- registered as dropbox-uid-reflection-encoding-tests; manifest parses,
  228 checks, no duplicate ids

Failure-Class: none

Co-Authored-By: Claude Opus 5 <[email protected]>

* fix(dropbox-app): escape auth_callback error and token-exchange sinks (#14578)

Addresses aryanorastar review on #14579: the two remaining unauthenticated
HTML sinks in /auth/dropbox/callback are now escaped the same way as the
500 handler — `error_description or error` (reflected OAuth params) and the
token-exchange failure body (provider-supplied response.text) both go
through html.escape(..., quote=True).

Tests: 3 new hermetic cases in test_uid_reflection.py prove the
<script>alert(1)</script> payload cannot appear raw in either body
(9 tests, all passing).

Failure-Class: none

---------

Co-authored-by: Claude Opus 5 <[email protected]>

This branch has not been deployed

No deployments
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.

4 participants