[Bounty proposal] security(github-app): require shared-secret auth on chat-tool routes ($50 proposed)
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):
- Add
plugins/omi-github-app/github_tools_auth.pyto enforceGITHUB_TOOLS_SECRETviaAuthorization: Bearer <secret>or?github_tools_token=. Fails closed with 503 if unconfigured, 401 on missing or invalid token. Constant-time comparison usinghmac.compare_digest. - Apply
dependencies=[Depends(require_github_tools_auth)]across all 8 chat-tool routes inplugins/omi-github-app/main.py. - 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. - Add hermetic test suite
plugins/omi-github-app/test_github_tools_auth.py(10 tests) with stubbed FastAPI for standard python3 execution. - Register
github-app-tools-auth-testsin.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.
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.