Skip to content

fix(plugins): sign twitter /disconnect links, verify on the endpoint - #14519

Closed
hridaya423 wants to merge 3 commits into
BasedHardware:mainfrom
hridaya423:fix/twitter-disconnect-sig
Closed

hridaya423 wants to merge 3 commits into
BasedHardware:mainfrom
hridaya423:fix/twitter-disconnect-sig

Conversation

@hridaya423

@hridaya423 hridaya423 commented Sep 18, 2026 •

Copy link
Copy Markdown
Contributor

Problem

GET /disconnect?uid= deleted a victim's stored Twitter tokens for any supplied uid, no authentication. It's a browser-rendered GET link on the settings page, so the Bearer/twitter_tools_token tools guard from #14452 can't apply directly.

/setup/twitter?uid= still returns only an is_setup_completed boolean: same shape as the setup check intentionally left open in the whoop PR (#14454), no mutation.

Flagged in review on #14452 → #14505.

Fix

Same signed-link pattern as the whoop /disconnect fix:

  • disconnect_sig(uid) signs the uid with TWITTER_TOOLS_SECRET (HMAC-SHA256, truncated hex); the settings page renders /disconnect?uid=…&sig=….
  • verify_disconnect_sig(uid, sig) runs before delete_twitter_tokens: 503 when TWITTER_TOOLS_SECRET is unset (fail-closed, same posture as the tools guard), 401 on missing/bad signature (hmac.compare_digest).

Verification

python3 test_tools_auth.py: 9/9 pass, incl. new TestDisconnectSig (valid sig accepted, wrong-uid sig 401, missing sig 401, unconfigured secret 503). run_checks.py --lane local --check-id twitter-chat-tools-auth-tests → PASS.

Failure-Class: none

Depends on #14452 (extends twitter_tools_auth.py introduced there). Closes #14505.

hridaya423 and others added 3 commits September 18, 2026 01:59
All ten chat-tool routes took uid from the JSON body and acted with the
stored Twitter OAuth token — post_tweet/like/retweet/delete write as the
victim, timeline/mentions/profile read as the victim — with no caller
authentication. Same defect class as zapier (BasedHardware#14428) and the paid mentor
fix; this app was missed by both and by BasedHardware#13463.

Adds twitter_tools_auth.py (shared-secret bearer/query-token guard,
TWITTER_TOOLS_SECRET env) applied via Depends() to every tool route.
Fails closed 503 when unconfigured, 401 on missing/wrong token.

Verified: 9 tests + 64 subtests pass including 5 new guard tests;
existing test stub gained a Depends attribute.

Refs BasedHardware#14451
Reviewer asks: test_tools_auth.py was not in .github/checks-manifest.yaml
(the existing max-results entry only runs test_max_results.py), and the
docstring cited BasedHardware#14448 instead of the BasedHardware#14451 bounty issue. Registers
twitter-chat-tools-auth-tests (PASS via run_checks.py --check-id) and
corrects the reference. PR body now declares Failure-Class: none.

Generated with [Devin](https://devin.ai)

Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
/disconnect deleted a victim's Twitter tokens by uid alone — a GET link
rendered in the settings page, so the Bearer tools guard cannot apply.
The page now signs uid with the shared secret (disconnect_sig) and the
endpoint verifies it (verify_disconnect_sig, fail-closed 503/401).
Same pattern as the whoop /disconnect fix. Closes BasedHardware#14505.
@Git-on-my-level

Copy link
Copy Markdown
Member

Thanks @hridaya423 — clean follow-up to #14452, reusing the signed-link pattern from the whoop fix (#14454). Verified against head 95e985:

Security review of the change

  • plugins/omi-twitter-chat-tools-app/twitter_tools_auth.py — disconnect_sig() binds the link to the uid via HMAC-SHA256 over TWITTER_TOOLS_SECRET (32 hex chars = 128 bits); verify_disconnect_sig() fails closed 503-before-401, so an unconfigured secret can never fall through to a signature comparison, and both token and sig checks use hmac.compare_digest. Relative to fix(plugins): require auth on twitter-chat-tools routes acting on uid-keyed tokens #14452 this commit adds only the two disconnect functions — the bearer guard itself is unchanged.
  • plugins/omi-twitter-chat-tools-app/main.py — verify_disconnect_sig(uid, sig) runs before delete_twitter_tokens(uid) in GET /disconnect, closing the delete-any-user's-tokens-by-uid hole from omi-twitter-chat-tools-app: /disconnect and /setup/twitter trust bare uid #14505; the settings-page link now embeds the sig. I also confirmed against the head file that all ten /tools/* routes carry Depends(require_twitter_tools_auth) and no other mutating route is left unguarded.
  • plugins/omi-twitter-chat-tools-app/test_tools_auth.py — new TestDisconnectSig covers valid sig, wrong-uid sig → 401, missing sig → 401, unconfigured secret → 503. I ran the suite against the head files: 9/9 pass.
  • plugins/omi-twitter-chat-tools-app/test_max_results.py — Depends added to the fastapi stub so the existing suite keeps importing main.py; its assertions are untouched.
  • .github/checks-manifest.yaml — registers twitter-chat-tools-auth-tests in local+ci lanes. Note this entry is byte-identical to the one in fix(plugins): require auth on twitter-chat-tools routes acting on uid-keyed tokens #14452, so whichever PR merges second will carry a no-op manifest diff — harmless, but a rebase keeps history clean.

Residual properties — inherent to the signed-link pattern, same trade-off the whoop fix accepted, fine to merge with but worth being aware of:

  • The sig is not single-use or expiring: anyone who captures a rendered link (history, logs) holds a working disconnect capability for that uid indefinitely.
  • GET /disconnect still mutates state and the sig acts as a capability in the URL (no session/Origin check) — unchanged from before this PR, nothing regressed.
  • /setup/twitter?uid= intentionally stays boolean-only, matching the posture kept open in fix(plugins): require auth on whoop-app routes reading uid-keyed health data #14454.

Dependency note: this branch sits one commit on top of #14452's head, so that PR should merge first.

The uid-as-authentication hole is closed and the implementation matches the established pattern. The remaining call is a maintainer one — sign-off on the shared-secret auth posture (one TWITTER_TOOLS_SECRET guarding both bearer tool calls and signed disconnect links) for this plugin.

(Automated maintainer review on behalf of David · AI-generated feedback)


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 positive-signal Automation verified a genuine fix/quality contribution python labels Sep 18, 2026
@aryanorastar

Copy link
Copy Markdown
Collaborator

Closing as a later duplicate of #14452, opened earlier for the same file class.

Both PRs still change overlapping production files (plugins/omi-twitter-chat-tools-app/main.py, plugins/omi-twitter-chat-tools-app/test_max_results.py, plugins/omi-twitter-chat-tools-app/test_tools_auth.py, plugins/omi-twitter-chat-tools-app/twitter_tools_auth.py). This later head is 95e9850324c1. MERGEABLE or extra tests on this tip do not replace the earlier vehicle. Continue on #14452.

@github-actions

Copy link
Copy Markdown
Contributor

Hey @hridaya423 👋

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.

omi-twitter-chat-tools-app: /disconnect and /setup/twitter trust bare uid

3 participants