omi icon indicating copy to clipboard operation
omi copied to clipboard

[Bounty proposal] security(github-app): require shared-secret auth on chat-tool routes ($50 proposed)

Open TheRWX opened this issue 2 months ago • 1 comments

Summary

The server-to-server chat-tool routes under /tools/* in plugins/omi-github-app/main.py accepted uid directly from unauthenticated JSON request bodies and performed authorized GitHub actions using the victim's stored OAuth credentials (SimpleUserStorage.get_user(uid)["access_token"]).

Any unauthenticated caller knowing or guessing a target user's uid could:

  • List all private and public repositories (POST /tools/list_repos)
  • List repository issues (POST /tools/list_issues)
  • Read full details of any repository issue (POST /tools/get_issue)
  • List repository labels (POST /tools/list_labels)
  • Post comments on issues under the victim's GitHub identity (POST /tools/add_issue_comment, POST /tools/add_comment)
  • Create issues in repositories under the victim's GitHub identity (POST /tools/create_issue)
  • Trigger AI agent coding tasks and PR creations using the victim's GitHub identity (POST /tools/code_feature)

Proposed Fix

Following the established plugin shared-secret authorization pattern (#13685, #14455, #14700):

  1. Add plugins/omi-github-app/github_tools_auth.py to enforce GITHUB_TOOLS_SECRET via Authorization: Bearer <secret> or ?github_tools_token=. Fails closed with 503 if unconfigured, 401 on missing or invalid token. Constant-time comparison using hmac.compare_digest.
  2. Apply dependencies=[Depends(require_github_tools_auth)] across all 8 chat-tool routes in plugins/omi-github-app/main.py.
  3. Preserve browser-facing setup and settings endpoints (/, /auth, /auth/callback, /setup-completed, /update-repo, /refresh-repos, /check-repo-access, /save-agent-provider, /save-agent-key, /delete-agent-key, /test-agent, /health) without auth to prevent functional regressions.
  4. Add hermetic test suite plugins/omi-github-app/test_github_tools_auth.py (10 tests) with stubbed FastAPI for standard python3 execution.
  5. Register github-app-tools-auth-tests in .github/checks-manifest.yaml.

Verification

All 10 tests in test_github_tools_auth.py, 73 tests in test_main.py, 10 tests in test_github_client.py, 5 tests in test_create_issue_auto_labels.py (98 total discovery tests), and 53 manifest contract tests pass locally (100% green). All 17 checks in scripts/pr-preflight pass cleanly.

PR is ready to submit.

TheRWX avatar Sep 19 '26 17:09 TheRWX

Implemented and verified in PR #15012.

Hermetic test suite added in plugins/omi-github-app/test_github_tools_auth.py (10 tests passing) and registered in .github/checks-manifest.yaml.

TheRWX avatar Sep 19 '26 17:09 TheRWX