Repository navigation
fix(plugins): require auth on twitter-chat-tools routes acting on uid-keyed tokens - #14452
hridaya423 wants to merge 2 commits into
Conversation
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
|
Thanks @hridaya423 — this closes the uid-as-auth hole from #14451 across the whole tool surface, and the guard is a faithful replica of the pattern we merged for the mentor plugin in #13685. Verified independently:
Two small asks before merge, both following the #13685 precedent:
One sequencing note for maintainers (not a change request): the guard is fail-closed by design, and the backend chat-tool caller ( AI-generated maintainer feedback posted on David's behalf. by AI on behalf of David — if you need David’s attention urgently, please @Git-on-my-level and escalate with |
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>
|
Both asks addressed:
On the sequencing note: agreed it's a maintainer call — fail-closed mirrors the merged mentor precedent (#13685). I'll file the |
|
Verified on Leaving this open as the keep vehicle (remaining hole: twitter-chat-tools uid auth keep vs closed #14519; CONFLICTING, 0-checks). Overlap is on Head is |
|
Keeping this open. Not approving — Astar, on behalf of @aryanorastar |
|
Verified against main and ran the suites locally - a solid, well-scoped fix. Thank you @hridaya423. Per-file notes (all five changed files):
Two notes before merge:
Leaving for human maintainer review: this touches an auth surface, and the deployment decision (reusing by AI on behalf of David — if you need David’s attention urgently, please @Git-on-my-level and escalate with |
Summary
All ten chat-tool routes in
omi-twitter-chat-tools-apptakeuidfrom the JSON body and act with the stored Twitter OAuth token (get_valid_access_token(uid)/twitter_api_request(uid, ...)) with no caller authentication:post_tweet,like_tweet,unlike_tweet,retweet,delete_tweetget_timeline,get_my_tweets,get_mentions,search_tweets,get_user_profileAnyone who knows a uid can tweet, like, retweet, or delete from the victim's connected account. Same defect class as zapier (#14428/#14429), the paid mentor fix (#13685), and the transcript-webhook fix (#14446/#14447); this app was missed by all of them and by the #13463 umbrella.
Fix
twitter_tools_auth.py, a shared-secret guard (Authorization: Bearerortwitter_tools_tokenquery param →TWITTER_TOOLS_SECRETenv,hmac.compare_digest), applied via_auth: None = Depends(require_twitter_tools_auth)to all ten routes. Caller authentication only; uid stays the body-level data-plane key, matching how the backend invokes tools. Fail-closed 503 unconfigured, 401 bad token.Tests
test_tools_auth.py(hermetic, stdlib): 503 unconfigured, 401 missing/wrong, bearer + query token accepted. Existingtest_max_results.pystub gained aDependsattribute so the app still loads hermetically.pytest plugins/omi-twitter-chat-tools-app→ 9 tests + 64 subtests pass (5 new).Refs #14451
Failure-Class: none