Skip to content

fix(google-calendar-app): escape calendar list in settings and exception in callback (#14994) - #15000

Merged
undivisible merged 1 commit into
BasedHardware:mainfrom
kaleidoscopeAI:fix/google-calendar-app-stored-xss
Oct 19, 2026
Merged

undivisible merged 1 commit into
BasedHardware:mainfrom
kaleidoscopeAI:fix/google-calendar-app-stored-xss

Conversation

@kaleidoscopeAI

@kaleidoscopeAI kaleidoscopeAI commented Sep 19, 2026 •

Copy link
Copy Markdown
Contributor

Resolves #14994

Summary

Harden plugins/omi-google-calendar-app against stored cross-site scripting (XSS) and attribute breakout in the connected settings page and unescaped exception messages in OAuth error handling.

  1. Settings Page Stored XSS & Attribute Breakout:

    • cal["name"] and cal["id"] from get_user_calendars(uid) were interpolated raw into the <option> elements of calendar_options.
    • Any malicious calendar name or ID (e.g. <script>... or " onfocus="alert(1)) would inject arbitrary HTML/JS into the settings page view.
    • Fixed by escaping cal["name"] via html.escape() and cal["id"] via html.escape(..., quote=True).
  2. OAuth Callback Exception Escaping:

    • Exception str(e) was interpolated raw into HTMLResponse on line 1186 upon authorization errors.
    • Fixed by wrapping with html.escape(str(e)).
  3. Hermetic Test Coverage:

    • Extended plugins/omi-google-calendar-app/test_uid_reflection.py with ConnectedCalendarEscapingTest and CallbackExceptionEscapingTest verifying that calendar name XSS, calendar ID breakout, and exception reflection are sanitized.

💳 Bounty Disbursement Details

Upon review and merge, the bounty reward can be disbursed directly via:

/claim #14994

Failure-Class: none

Review in cubic

…ion in callback (BasedHardware#14994)

- HTML-escape calendar name and quote-escape calendar ID in settings page options
- HTML-escape exception message in OAuth callback error response
- Add hermetic regression tests in test_uid_reflection.py for calendar list XSS and callback exception reflection

Failure-Class: none
@kaleidoscopeAI

Copy link
Copy Markdown
Contributor Author

💳 Bounty Disbursement Details

Upon review and merge, the bounty reward can be disbursed directly via:

Thank you!

Copy link
Copy Markdown
Contributor Author

@kodjima33 — requesting maintainer review of this Google Calendar security fix. The PR includes the bounty claim, security hardening, and regression coverage. Please review the current head and merge if it satisfies the bounty requirements.

@Git-on-my-level

Copy link
Copy Markdown
Member

Thanks for this clean security fix — I verified it end to end and it holds up.

What I checked in plugins/omi-google-calendar-app/main.py:

  • The connected settings branch now normalizes cal_id/cal_name via str(cal.get(...)) and escapes on output: html.escape(cal_id, quote=True) for the value="…" attribute and html.escape(cal_name) for the option body (lines 997–1003). Selection still compares the raw cal_id, so behavior is unchanged. On the pre-fix code this page renders a calendar named <script>alert('stored_xss')</script> verbatim, so both the stored-XSS and the value="cal2" onfocus="alert(1)" breakout were real.
  • The OAuth callback error path now renders html.escape(str(e)) (line ~1190), closing raw exception-message reflection.
  • I swept the remaining HTML responses in the file: the only unescaped interpolation left is {response.status_code} (an int), so the HTML surfaces here are now consistently escaped. tool_list_calendars interpolates calendar names raw, but into a chat-tool markdown string rather than HTML — fine as is.

Tests (plugins/omi-google-calendar-app/test_uid_reflection.py): I ran the suite — 7/7 pass on this branch, and the two new classes (ConnectedCalendarEscapingTest, CallbackExceptionEscapingTest) fail on the pre-fix code exactly as intended, so they genuinely pin the fix rather than passing vacuously. Two minor, non-blocking notes:

  • current_calendar_name (main.py ~line 1005) still stores the un-escaped name, but it is never rendered anywhere — a pre-existing dead assignment. Escaping it too would be tidy if it ever gets used.
  • The new tests patch get_user_calendars/get_default_calendar/get_oauth_state on the module without restoring them in tearDown. Harmless in this file today (the run is order-independent), but restoring patched attributes would keep the suite robust as it grows.

Since this changes a security-sensitive surface (the unauthenticated OAuth callback and settings-page rendering), the merge call stays with the maintainers. Nice work — the issue report and the fix both look solid.

🤖 Automated review 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.

@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 20, 2026
@aryanorastar

Copy link
Copy Markdown
Collaborator

Verified on 9338067356d1.

Leaving this open as the remaining-hole vehicle on plugins/omi-google-calendar-app/main.py, plugins/omi-google-calendar-app/test_uid_reflection.py. unique gcal XSS+tests remaining hole but 0 CI cannot approve.

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

Copy link
Copy Markdown
Contributor Author

Maintainer action requested: this Google Calendar security fix addresses the reflected HTML/attribute issues and callback escaping. Please review/merge if accepted and confirm the $75 bounty payout. Payout details can be provided privately.

@aryanorastar

Copy link
Copy Markdown
Collaborator

Google Calendar on main still builds an <option> from the calendar name and returns Authentication error: {str(e)}. This head escapes both, and the test pins a script payload. The only check on 9338067356d1 is cubic, so this stays open and unapproved.

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

Reviewed 9338067.

Calendar option text and the callback exception are still unescaped on main. This head escapes them. Hygiene passed on this head. Not merging.

@Git-on-my-level

Copy link
Copy Markdown
Member

Thanks @kaleidoscopeAI — verified both fixes against the diff and against current main (main still renders these values raw, so the fix is needed):

  • plugins/omi-google-calendar-app/main.py (settings page): the <option> loop now escapes cal["id"] with html.escape(..., quote=True) and cal["name"] with html.escape(...) before interpolation, closing the stored-XSS / attribute-breakout path from get_user_calendars(). The str(cal.get(...)) coercions also make missing keys non-fatal, and the selected comparison correctly stays on the raw values (escaping only at output).
  • plugins/omi-google-calendar-app/main.py (OAuth callback): the exception path at the end of google_callback now renders html.escape(str(e)), so error text can no longer inject markup into the 500 page.
  • plugins/omi-google-calendar-app/test_uid_reflection.py: ConnectedCalendarEscapingTest and CallbackExceptionEscapingTest assert both that the escaped forms appear and that the raw payloads (<script>alert('stored_xss')</script>, cal2" onfocus="alert(1)) are absent; the requests.post stub keeps _load_main() hermetic. Good, targeted coverage of the exact sinks.

One small non-blocking nit: in the settings loop, current_calendar_name = cal_name + primary_badge stores the unescaped name. That variable is never rendered in this file today (dead assignment, so no live sink), but if it ever gains a render site, use safe_name there to avoid reintroducing the issue.

Checks pass on this head and it already carries a maintainer approval. Since this is a security-sensitive change (stored XSS in an OAuth-linked settings page), I'm keeping security-review for maintainer sign-off ahead of the merge decision.


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

@kaleidoscopeAI

Copy link
Copy Markdown
Contributor Author

@aryanorastar — the "only check is cubic" concern is resolved, no code change needed.

main has since registered a real Hygiene check that covers this head:

gcal-uid-reflection-encoding-tests
  command:  ["python3", "plugins/omi-google-calendar-app/test_uid_reflection.py"]
  triggers: ["plugins/omi-google-calendar-app/**"]

This PR changes exactly plugins/omi-google-calendar-app/test_uid_reflection.py (the command target) and plugins/omi-google-calendar-app/main.py (matched by the /** trigger), so the check is selected and runs.

Hygiene on 9338067356d1 is green:
https://github.com/BasedHardware/omi/actions/runs/35458806151/job/106737022742

Both fixes you verified still stand — the <option> calendar-name escaping and the Authentication error: {str(e)} escaping are unchanged on this head, and the script payload test still pins the regression.

mergeable is true (this branch did not go dirty; it never touched .github/checks-manifest.yaml in a way that conflicts with main).

@kaleidoscopeAI

Copy link
Copy Markdown
Contributor Author

CI is green on this head — ready to merge.

Head: 9338067356d1e6ad89cdf9141042e602edb333d9
Hygiene: success, mergeable

Fix (plugins/omi-google-calendar-app/main.py): the calendar list and
the auth error were reflected raw into the settings page (reflected XSS).

  • html.escape(cal_id, quote=True) and html.escape(cal_name) when building
    the calendar <option> list, so a crafted calendar id cannot break out of
    the value attribute and a crafted name cannot inject markup.
  • html.escape(str(e)) on the authentication error before it is reflected.

Tests (plugins/omi-google-calendar-app/test_uid_reflection.py):

  • 7/7 in the dependency-free CI lane and 7/7 with real dependencies installed.

@kaleidoscopeAI

Copy link
Copy Markdown
Contributor Author

@kodjima33 Gentle ping — this security hardening fix is approved, clean, and mergeable. Ready to merge whenever you have a moment!

@undivisible
undivisible merged commit c772af5 into BasedHardware:main Oct 19, 2026
38 of 41 checks passed
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

4 participants