Skip to content

fix(plugins): html-escape provider and exception strings in OAuth failure pages - #14504

Closed
tluangtea-lab wants to merge 1 commit into
BasedHardware:mainfrom
tluangtea-lab:fix/callback-error-strings-escaped
Closed

tluangtea-lab wants to merge 1 commit into
BasedHardware:mainfrom
tluangtea-lab:fix/callback-error-strings-escaped

Conversation

@tluangtea-lab

@tluangtea-lab tluangtea-lab commented Sep 18, 2026 •

Copy link
Copy Markdown
Contributor

html.escape provider response bodies and exception strings on OAuth failure pages in dropbox, google-calendar, twitter-chat-tools, and whoop apps.

Verification

  • python3 plugins/test_callback_error_pages_escaped.py — 6 passed.
  • Registered plugin-callback-error-pages-escaped-tests in .github/checks-manifest.yaml.

Failure-Class: new

Review in cubic

@Git-on-my-level

Copy link
Copy Markdown
Member

Verified end to end — this is a clean, complete fix. Thank you @tluangtea-lab!

Per-file review (all 7 changed files):

  • plugins/omi-dropbox-app/main.py — both failure branches are now escaped: the token-exchange failure (html.escape(response.text, quote=True)) and the exception path (html.escape(str(e), quote=True)); on main the exception path rendered str(e) raw into an HTMLResponse.
  • plugins/omi-google-calendar-app/main.py — google_callback's exception path is escaped; the remaining Token exchange failed: {response.status_code} interpolation is an integer, so it is safe as-is.
  • plugins/omi-twitter-chat-tools-app/main.py — both the token-exchange failure (response.text) and the exception path are escaped.
  • plugins/omi-whoop-app/main.py — whoop_callback's exception path is escaped; its status_code interpolation is safe as-is.
  • plugins/test_callback_error_pages_escaped.py — I ran the suite in an isolated container: 6/6 pass on this head, and against the pre-fix code it fails with "raw script tag rendered" on the dropbox exception path, so the assertions genuinely pin the behavior. The AST stub-loader approach matches the sibling suites (omi-twitter-app: reflected XSS — /auth/callback error page interpolates the raw state query param into its HTML ($25 bounty proposed) #14350, fix(plugins): encode reflected uid in setup/auth pages across six apps #13658).
  • .github/checks-manifest.yaml — plugin-callback-error-pages-escaped-tests is registered with triggers covering all four touched apps plus the suite itself; the entry sits mid-file, so it classifies normally.
  • .github/failure-classes/FC-provider-exception-strings-reflected-into-html.json — valid schema and the right failure-class record for this fix. One tiny nit: violated_contract says "Five plugin apps'" but four apps are named and four are fixed — worth aligning the count.

I also scanned every plugins/*/main.py for other HTMLResponse f-string interpolations: no remaining raw response.text/str(e) reflections; the only unescaped ones left are integer status codes. Failure-Class: new is the correct classification here.

Not submitting a formal approval since this modifies OAuth callback failure paths — leaving merge sign-off on that auth surface to a human maintainer. The change itself looks correct and is well pinned by tests.

AI-generated on behalf of the Omi 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.

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

Confirmed reflected-XSS on main: raw f-string interpolation of response.text/str(e) into HTMLResponse in dropbox/google-calendar/twitter/whoop OAuth failure pages. Narrow html.escape fix + hermetic regression suite, 5/5. Merging.

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
@tluangtea-lab
tluangtea-lab force-pushed the fix/callback-error-strings-escaped branch from b60b3a0 to 9b19b4d Compare September 18, 2026 18:05
@tluangtea-lab
tluangtea-lab force-pushed the fix/callback-error-strings-escaped branch from 9b19b4d to d3702df Compare September 19, 2026 04:46

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

Confirmed real reflected-XSS in OAuth failure pages, 5/5, but DIRTY (conflict) -- approve only.

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
tluangtea-lab force-pushed the fix/callback-error-strings-escaped branch from d3702df to 97e711c Compare September 20, 2026 11:35
@aryanorastar

Copy link
Copy Markdown
Collaborator

Verified on 97e711c25f98.

Leaving this open as the remaining-hole vehicle on .github/checks-manifest.yaml, .github/failure-classes/FC-provider-exception-strings-reflected-into-html.json, plugins/omi-dropbox-app/main.py, plugins/omi-google-calendar-app/main.py…. remaining hole: OAuth failure-page escape across 4 apps; CI red.

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.

Dropbox, Google Calendar, Twitter, and Whoop OAuth pages on main still interpolate raw exception text into HTML. This head escapes those four, and the regression test pins a script payload. Hygiene is green on 909b9bbaec90.

…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
tluangtea-lab force-pushed the fix/callback-error-strings-escaped branch from 909b9bb to 2527f91 Compare September 22, 2026 15:04
@aryanorastar

Copy link
Copy Markdown
Collaborator

OAuth error-page escaping on 2527f91e3cb4 covers four apps, Desktop Swift has no conclusion, and it overlaps the single-app keeps. This stays open and unapproved.

— Astar, on behalf of @aryanorastar

@tluangtea-lab

Copy link
Copy Markdown
Contributor Author

Thanks for the clarification. I audited the overlap against the single-app keep series and confirmed that the four-app scope of #14504 is largely subsumed by #15476 (Whoop), #15493 (Google Calendar), #15497 (Dropbox), and #15517 (Twitter).

I also confirmed that the remaining Twitter token-exchange response.text sink is already identified in #15517, so I won't duplicate that work in a separate PR.

I'm therefore closing #14504 as superseded and will keep any remaining fixes within the canonical single-app PRs.

@github-actions

Copy link
Copy Markdown
Contributor

Hey @tluangtea-lab 👋

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

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