Skip to content

fix(plugins): sanitize sensitive logging of tokens, credentials, and user data (#13777) - #13782

Closed
Evos09 wants to merge 3 commits into
BasedHardware:mainfrom
Evos09:fix/sanitize-sensitive-logging
Closed

Evos09 wants to merge 3 commits into
BasedHardware:mainfrom
Evos09:fix/sanitize-sensitive-logging

Conversation

@Evos09

@Evos09 Evos09 commented Sep 14, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Resolves #13777.

This PR audits and sanitizes sensitive logging across plugins to prevent OAuth access tokens, API keys, webhook URLs, and user speech transcripts from leaking into deployment logs:

  • plugins/oauth/client.py & conversation_created.py:
    • Removed raw resp.json() dumps containing Notion access_token and database response bodies.
    • Removed print({'uid': uid, 'api_key': access_token, ...}) in OAuth callback.
    • Sanitized create_notion_row logging to output only HTTP status codes.
  • Token Exchange & Refresh Failure Paths:
    • Sanitized plugins/omi-notion-app/main.py and plugins/omi-google-calendar-app/main.py to prevent raw response.text from being rendered in callback HTML or logs.
    • Sanitized plugins/omi-clickup-app/clickup_client.py and plugins/omi-github-app/github_client.py to remove OAuth response dumps and prevent raw response.text from being placed into exception messages.
  • plugins/omi-hive-app/main.py:
    • Removed API key prefix and query string printing.
    • Removed full REST Headers and response body dumps.
  • plugins/omi-slack-app/slack_client.py:
    • Removed user token prefix logging (user_token[:15]) and OAuth response keys printing.
  • plugins/omi-twitter-app/main_simple.py:
    • Removed access/refresh token prefix logging.
    • Removed raw user speech transcript segment printing.
  • plugins/zapier/client.py & conversation_created.py:
    • Removed target_url subscriber logging and full conversation dumps.
    • Sanitized RequestException error formatting so webhook URLs are not embedded in error messages.
  • plugins/notifications/hey_omi.py:
    • Removed OpenAI API key prefix print.
    • Sanitized OMI notification logging and exception handling to prevent leaking user messages.

Testing

  • Ran python -m py_compile across all 12 modified plugin files (all passed with 0 errors).
  • Ran existing plugin test suites (plugins/test_db_transcript_segments.py, plugins/test_mentor_session_auth.py): 8/8 passed.

Base Mainnet Payout Treasury: 0x7badCdA295Dd7113f374aEA1008e7d5870D48556

Review in cubic

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

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

Re-trigger cubic

Comment thread plugins/omi-twitter-app/main_simple.py Resolved
Comment thread plugins/notifications/hey_omi.py Resolved
Comment thread plugins/zapier/client.py Resolved

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

Thanks for this cleanup — removing token/API-key/transcript prints across the plugin fleet is the right thing to do, and most of this checks out on the current head. Verified good, among others: the api_key dump in the Notion CRM OAuth callback (plugins/oauth/conversation_created.py), the OpenAI key-suffix print (plugins/notifications/hey_omi.py), the Slack user_token[:15] prefix log (plugins/omi-slack-app/slack_client.py), the Hive key prefix and REST header dumps (plugins/omi-hive-app/main.py), the raw response.text rendered into callback HTML (plugins/omi-notion-app/main.py, plugins/omi-google-calendar-app/main.py), and the Zapier target_url/response dumps.

Two issues block merge because they contradict the PR's own goal, plus one smaller regression:

  1. ClickUp OAuth still leaks client_secret on transport failure. plugins/omi-clickup-app/clickup_client.py:30-37 sends the token exchange as params= (URL query), and the except Exception: block re-raises the raw requests exception. /auth/callback then renders it verbatim — Failed to complete authentication: {str(e)} at plugins/omi-clickup-app/main.py:633 — so a ConnectionError/Timeout on that call puts the full URL, including client_secret and the OAuth code, into the error page and logs. Please send the credentials as data= (the GitHub client in plugins/omi-github-app/github_client.py:36-41 already does this correctly) and/or wrap the re-raised exception so no raw transport detail escapes.

  2. The final tweet text is still logged. process_segments returns f"✅ Tweet posted: '{cleaned_content}'" (plugins/omi-twitter-app/main_simple.py:737), and the webhook prints that whole message (USER NOTIFICATION: {response_message} at line 662, Silent response at 670). Since cleaned_content is AI-extracted from the user's speech, this reintroduces exactly the transcript logging the PR removes elsewhere. Logging the status plus tweet_id (already printed at line 736) is enough.

  3. Non-blocking: several handlers now swallow all diagnostic signal. hey_omi.py:166 logs HTTP error for Timeout/ConnectionError (misleading — there is no HTTP status), and plugins/zapier/client.py + the ClickUp/GitHub token-exchange handlers collapse every failure to a fixed string. type(e).__name__ carries no secrets and keeps failures diagnosable — same philosophy as backend/utils/log_sanitizer (mask, don't blind). Happy to see this addressed in the same pass or a follow-up.

Once 1 and 2 are fixed this is a solid hygiene improvement. Given the PR touches OAuth credential handling in plugin callbacks, I'd like a maintainer sign-off on those paths before merge.


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 python labels Sep 14, 2026
@Evos09

Evos09 commented Sep 14, 2026

Copy link
Copy Markdown
Contributor Author

Updated commit 0ddd572 pushed addressing all review suggestions:

  • ClickUp OAuth: Wrapped transport requests.RequestException into a sanitized RuntimeError("Token exchange request failed") to prevent query parameter and secret exposure.
  • Twitter Webhook: Sanitized final user notification and return string to ✅ Tweet posted (ID: {tweet_id}) so full tweet text is never written to deployment logs.
  • OMI Notifications: Preserved type(e).__name__ for non-HTTP exceptions (DNS/Timeout/Connection) while retaining HTTP status code logging without dumping response payloads.
  • Zapier Client: Updated fallback exception handler to RequestException {type(e).__name__} for non-sensitive error classification.

Base Treasury Payout: 0x7badCdA295Dd7113f374aEA1008e7d5870D48556

@Evos09

Evos09 commented Sep 14, 2026

Copy link
Copy Markdown
Contributor Author

@Git-on-my-level Thank you for the detailed and constructive review!

All points have been fully resolved across commits 0ddd572 and 03e2344:

  1. ClickUp OAuth Credential Leak:

    • Switched the token exchange request in plugins/omi-clickup-app/clickup_client.py from URL query params= to POST data= payload (matching plugins/omi-github-app/github_client.py).
    • Kept transport requests.RequestException wrapped into a clean RuntimeError("Token exchange request failed") to ensure no low-level transport strings escape to callback error pages or logs.
  2. Tweet Text Redaction:

    • In plugins/omi-twitter-app/main_simple.py:737, updated process_segments() return value to f"✅ Tweet posted (ID: {tweet_id})" instead of echoing the user-extracted cleaned_content. The notification webhook condition was updated accordingly.
  3. Diagnostic Signal Preservation:

    • In plugins/notifications/hey_omi.py, preserved type(e).__name__ for non-HTTP transport exceptions while checking isinstance(e, requests.exceptions.HTTPError) for status code.
    • In plugins/zapier/client.py, preserved type(e).__name__ in RequestException messages.

Ready for maintainer sign-off and merge. Base Mainnet treasury payout address: 0x7badCdA295Dd7113f374aEA1008e7d5870D48556.

@Git-on-my-level
Git-on-my-level dismissed their stale review September 15, 2026 06:43

Both concerns raised in this review are verified resolved on the current head (03e2344): the ClickUp token exchange now sends credentials as POST data with transport errors wrapped in a sanitized RuntimeError, and the Twitter webhook no longer logs tweet or transcript content.

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

Both blocking issues from the earlier review are verified fixed on 03e2344, along with the diagnostic-signal follow-ups:

  • ClickUp OAuth (plugins/omi-clickup-app/clickup_client.py:30-54): the token exchange now POSTs client_id/client_secret/code as form data — ClickUp documents these as body params, and this keeps the secret out of URLs, access logs, and exception strings. Transport failures are re-raised as a sanitized RuntimeError("Token exchange request failed"), so the {str(e)} rendered by the callback error page at plugins/omi-clickup-app/main.py:633 can no longer carry request details.
  • Twitter transcript logging (plugins/omi-twitter-app/main_simple.py): all speech-content prints are gone (Received: '{full_text}', Segment 1 content, Full accumulated, AI extracted tweet), the success path returns ✅ Tweet posted (ID: {tweet_id}) only (line 738), and the webhook notification condition (line 661) matches the new format.
  • Diagnostics (plugins/notifications/hey_omi.py:166-170, plugins/zapier/client.py): non-HTTP failures now log type(e).__name__, HTTP failures log the status code — failures stay diagnosable without payload dumps.

Spot-checked the rest of the fleet on the head: the Notion access_token/api_key dumps in plugins/oauth/client.py and plugins/oauth/conversation_created.py, the Slack user_token[:15] print, the Hive key/headers/body dumps, the GitHub client's token-response exception text, and the Notion/Google Calendar callback HTML that embedded raw response.text are all removed. All 12 files compile.

Two pre-existing leaks adjacent to (but outside) this PR's hunks, fine as follow-ups: plugins/omi-google-calendar-app/main.py:158-159 still logs and returns response.text from calendar_api_request, and plugins/omi-clickup-app/clickup_client.py:357-361 logs response.text on task-create failures.

Thanks for iterating on this — it's a real hygiene win for deployment logs. Given it changes credential-handling behavior in OAuth plugin callbacks (the ClickUp exchange now uses a POST body), leaving security sign-off to a human maintainer before merge.


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 needs-maintainer-review Needs a human maintainer to sign off before merge labels Sep 15, 2026
@Evos09

Evos09 commented Sep 15, 2026

Copy link
Copy Markdown
Contributor Author

Hi @Git-on-my-level and @BasedHardware team, just following up on this PR! All review items from cubic-dev-ai are resolved and verified in commits 0ddd572 and 03e2344, and all checks are passing cleanly. Please let me know if any further tweaks or adjustments are needed before merge. Thank you for your time and review!


Autonomous Contributor Base Payout Address: 0x7badCdA295Dd7113f374aEA1008e7d5870D48556

@Evos09

Evos09 commented Sep 19, 2026

Copy link
Copy Markdown
Contributor Author

Hi maintainers! Just checking in on this PR. All CI checks and tests are passing cleanly. Please let me know if any further tweaks or adjustments are needed—happy to update anytime!

— Evos09

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

Log redaction spans 12 plugin files (hey_omi.py, oauth clients, clickup/github/gcal/hive/notion/slack/twitter/zapier) with no test that a token/secret is actually stripped.

That is too wide to land without a hermetic suite, and the head is CONFLICTING. Add tests for the redaction helper, or shrink to one sink. I am not merging.

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

Copy link
Copy Markdown
Collaborator

Closing this pull request. The production change is already on main, and this head adds no extra production file.

@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

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.

Plugins print OAuth tokens, API keys, webhook URLs, and transcript text to stdout logs (US$200 bounty proposal)

3 participants