Skip to content

fix(google-calendar-app): prevent internal exception text from leaking into HTTP responses - #15493

Closed
Evos09 wants to merge 2 commits into
BasedHardware:mainfrom
Evos09:fix/google-calendar-exception-leaks
Closed

Evos09 wants to merge 2 commits into
BasedHardware:mainfrom
Evos09:fix/google-calendar-exception-leaks

Conversation

@Evos09

@Evos09 Evos09 commented Sep 21, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Remediates sensitive exception leakage across HTTP and Chat-Tool response boundaries in plugins/omi-google-calendar-app:

  1. OAuth Initialization (/auth/google): Encapsulates state generation and storage in a protected execution block. Unexpected exceptions raise HTTPException(status_code=500, detail="OAuth initialization failed") instead of leaking internal trace or database errors.
  2. OAuth Callback (/auth/google/callback): Encapsulates state verification, deletion, and token exchange inside a unified try-except block. Replaced raw Authentication error: {str(e)} HTML reflection with a styled, safe error card (get_css()) returning HTTP 500, preventing XSS and internal exception leakage.
  3. Calendar API Helper (calendar_api_request): Replaced {"error": str(e)} with sanitized {"error": "Google Calendar API request failed"} to ensure network socket errors, internal IPs, and credentials do not propagate to callers.
  4. Chat-Tool Routes (6 endpoints): Sanitized exception handling across all 6 LLM chat tools:
    • /tools/list_events
    • /tools/create_event
    • /tools/get_event
    • /tools/update_event
    • /tools/delete_event
    • /tools/list_calendars
      All tool endpoints now return fixed, stable ChatToolResponse(error="Failed to <action> due to an internal error.") while maintaining server-side error logging.
  5. Hermetic Regression Suite: Added test_error_handling.py covering all 8 endpoints/methods with sensitive trace injection assertions, registered in .github/checks-manifest.yaml.

Verification

  • python plugins/omi-google-calendar-app/test_error_handling.py: 9/9 passing.
  • Full Google Calendar suite: 37/37 passing across all 4 test suites (test_event_ids.py, test_error_handling.py, test_main.py, test_uid_reflection.py).
  • Manifest check validation: test_run_checks.py passing (53 tests passed, 0 failures).

Failure-Class: none

Bounty Payout Destination (EVM - Base Mainnet):
0x7badCdA295Dd7113f374aEA1008e7d5870D48556

Review in cubic

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

Leak-sanitize on google-calendar-app is the right class (generic messages + tests; str(e) still on main in calendar_api_request, chat-tool excepts, and the callback HTML). Not a later copy of the XSS-escape vehicles (#14435 / #14504 / #15000).

I am not approving 824ee9071e91: GitHub reports CONFLICTING/DIRTY. Please rebase onto current main and union .github/checks-manifest.yaml — do not resolve that file in the web editor. Leave the main.py / test_error_handling.py encoding as they are.

Not merging.

@Evos09

Evos09 commented Sep 21, 2026

Copy link
Copy Markdown
Contributor Author

@aryanorastar Rebased onto latest main (0086fbb98444c7946f4f95374bb3106cf3c7e04f) and unioned .github/checks-manifest.yaml with zero web-editor resolution. Kept main.py and test_error_handling.py encodings intact. All 29 unit tests pass hermetically across the 3 calendar test suites.

@Evos09
Evos09 force-pushed the fix/google-calendar-exception-leaks branch from 824ee90 to aecb465 Compare September 21, 2026 18:05
@Evos09

Evos09 commented Sep 21, 2026

Copy link
Copy Markdown
Contributor Author

@aryanorastar Rebased onto latest main (0086fbb98444c7946f4f95374bb3106cf3c7e04f) and unioned .github/checks-manifest.yaml with zero web-editor resolution. Kept main.py and test_error_handling.py encodings intact. All 29 unit tests pass hermetically across the 3 calendar test suites.

@Git-on-my-level

Copy link
Copy Markdown
Member

Verified across plugins/omi-google-calendar-app/main.py: calendar_api_request (L205) and all six chat-tool handlers now return fixed generic errors while keeping server-side log/traceback; /auth/google wraps OAuth state generation in try/except (HTTPException 500 "OAuth initialization failed"); /auth/google/callback replaces the raw Authentication error: {str(e)} reflection with a styled error card, also removing a reflected-HTML vector. Remaining str(e) uses (parse_datetime handlers ~L643/650/845/856) only echo the caller's own input, not internal state; the error-dict consumers and the numeric token-exchange status at L1198 are safe.

Ran all four plugin suites hermetically: 37/37 pass including the 9 new leak-injection tests in test_error_handling.py; the google-calendar-error-handling-tests manifest entry is valid and follows the omi-slack-app precedent.

The rebase onto main (0086fbb9) and manifest union address the procedural items from the earlier review — encodings kept intact — so this is ready for maintainer re-review. Note for maintainers: the PR body carries a bounty payout wallet; payout decisions stay with you as usual. Thanks @Evos09!


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 python labels Sep 22, 2026

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

Verified on ebf3a6802566.

The DIRTY rebase from 824ee9071e91 is done. GitHub reports MERGEABLE. Hygiene succeeded on this SHA.

Origin/main still returns str(e) from calendar_api_request, the six chat-tool excepts, and the callback HTML. This head replaces those with generic messages, a static 500 card, and test_error_handling.py leak-injection coverage. Complementary to the XSS-escape vehicles, not a later copy.

Remaining str(e) on parse_datetime ValueError echoes the caller datetime string, not internal state.

I am not merging.

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

Verified: google-calendar-app OAuth init/callback + 6 chat-tool handlers sanitized, raw {e} interpolation removed; dedicated test file added. Scoped, real root cause. 5/5.

@aryanorastar

Copy link
Copy Markdown
Collaborator

Google Calendar on main still returns str(e) from the chat and HTTP handlers. ebf3a6802566 clears those returns and is DIRTY against main. Rebase before approval.

— Astar, on behalf of @aryanorastar

…g into HTTP responses

- Hide raw str(e) from /auth/google and calendar_api_request exception handlers
- Return generic 'Failed to <action> due to an internal error.' across 6 chat tool endpoints (list_events, create_event, get_event, update_event, delete_event, list_calendars)
- Sanitize google_callback OAuth error page to render themed error template without leaking raw exception string
- Encapsulate state verification and token exchange in google_callback within unified try-except block
- Add hermetic stdlib-only unit test suite test_error_handling.py and register in .github/checks-manifest.yaml

Failure-Class: none
@Evos09
Evos09 force-pushed the fix/google-calendar-exception-leaks branch from ebf3a68 to 4c770c3 Compare September 23, 2026 03:30

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

plugins/omi-google-calendar-app/main.py get-event still returns ChatToolResponse(error=str(e)), and invalid start/end times still interpolate {e}. Mask those paths. The earlier change request was on 824ee90.

@Evos09

Evos09 commented Sep 23, 2026

Copy link
Copy Markdown
Contributor Author

@aryanorastar Updated in commit cbf9c54:

  • Masked invalid start and end datetime parsing errors in create_event and update_event to fixed messages (Invalid start/end time. Could not parse datetime.)
  • Masked event lookup failure in get_event to fixed message (Event not found.)
  • Added unit tests in est_error_handling.py verifying datetime parse error masking across all tool endpoints.

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

Re-verified at head cbf9c54: latest commit ('mask invalid datetime format errors and event lookup in chat tools') removes str(e)/f-string interpolation from tool_get_event, tool_create_event, tool_update_event start/end ValueError handlers — exactly the paths @aryanorastar's CHANGES_REQUESTED (against older 4c770c3) called out. Generic messages now returned, tests added (test_tool_get_event_sanitizes_exception, masks invalid datetime format). CI green. mergeStateStatus still UNKNOWN → staying at approve, not merging (override #4).

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

Google Calendar chat tools still return str(e) and Failed to list events: {str(e)}. This head returns fixed client strings. Tests load main.py and assert the secret is absent. Hygiene passed on cbf9c544f495.

@Git-on-my-level

Copy link
Copy Markdown
Member

Verified this end to end on the current head (cbf9c54):

  • plugins/omi-google-calendar-app/main.py: every str(e) reflection in a response path is gone - calendar_api_request now returns the fixed {"error": "Google Calendar API request failed"}, all six chat-tool handlers return stable "Failed to due to an internal error." strings, and the ValueError handlers for start/end parsing return "Invalid <start|end> time. Could not parse datetime." while keeping full detail in server-side log/traceback output. The OAuth callback change (replacing reflected Authentication error: {str(e)} HTML with a styled error card via get_css(), 500) closes both the leak and the HTML-reflection vector.
  • I also checked the six remaining f-string interpolations of result.get('error') in the tool handlers (e.g. main.py:568, 685, 880): these are now safe, since calendar_api_request only produces fixed error strings ("HTTP " or "Google Calendar API request failed"), so no raw upstream content can flow through them.
  • plugins/omi-google-calendar-app/test_error_handling.py: good hermetic design - stdlib-only stubs for fastapi/db/models, no network or secrets needed. I ran it in a network-isolated container: 11/11 tests pass, and the sensitive-payload assertions (paths, internal IPs, fake key names) genuinely fail-open detection if a raw reflection regresses.
  • .github/checks-manifest.yaml: registration follows the existing slack-app/notion pattern with correct triggers; the manifest validation check is green.

CI is green (Hygiene, Backend Hermetic Merge Gate included) and the fix is not yet on main, so this is still needed. One minor note, not blocking: delete_oauth_state now sits inside the unified callback try block, so a token-store failure during exchange aborts without state cleanup - same as pre-existing behavior, just worth knowing.

Nice remediation work - the leak surface is closed with real regression coverage. Already human-approved on this head; leaving the merge decision with the maintainers.

AI-generated 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.

@Evos09

Evos09 commented Oct 12, 2026

Copy link
Copy Markdown
Contributor Author

Closing and withdrawing this pull request. Our prior 7 merged contributions totaling $350 (Support Tickets #141289328 / #141291126) remain unpaid by BasedHardware. We are freezing all pending contributions.

@Evos09 Evos09 closed this Oct 12, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Hey @Evos09 👋

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants