Repository navigation
fix(github-app): require shared-secret auth on chat-tool routes - #15012
Conversation
The server-to-server /tools/* chat-tool routes in plugins/omi-github-app accepted uid directly from unauthenticated JSON request bodies and performed authorized GitHub actions using the victim's stored OAuth credentials. Requires callers to present GITHUB_TOOLS_SECRET via Authorization: Bearer header or ?github_tools_token= query parameter. Fails closed (503) when unset, 401 on missing or invalid token. Preserves browser setup/settings endpoints without auth to prevent functional regressions. Failure-Class: none
Git-on-my-level
left a comment
There was a problem hiding this comment.
Thanks for this — the underlying issue is real, and the overall shape matches the shared-secret pattern we've merged for the other tool plugins (#13685, #14455, #14684, #14700). The /tools/* routes in plugins/omi-github-app/main.py do act on stored OAuth credentials with only a body-supplied uid, so closing that gap here is the right call, and I appreciate you catching that this app was left out of the earlier sweep. I verified the route wiring independently (all eight chat-tool routes guarded, browser/setup routes left open as intended) and ran the suites locally: test_github_tools_auth.py (10), test_main.py (73), test_github_client.py (10), test_create_issue_auto_labels.py (5) — all green, matching the PR description.
One blocking issue and one should-fix:
1. The import fallback fails open (blocking) — plugins/omi-github-app/main.py:
try:
from .github_tools_auth import require_github_tools_auth
except (ImportError, AttributeError):
try:
from github_tools_auth import require_github_tools_auth
except (ImportError, AttributeError):
require_github_tools_auth = lambda request=None: NoneIf github_tools_auth.py is ever missing at runtime (partial deploy, packaging mistake), the module still boots and every /tools/* route silently loses its guard — exactly the exposure this PR exists to close. The merged precedents (notion/linear in #14455, shipbob in #14684) stop at two levels and let the import fail loudly. Please drop the third fallback so the guard fails closed at startup. Nothing depends on it: with the third level removed, all 98 tests still pass (I checked). The wrapped Depends import just above is also dead weight — the unwrapped from fastapi import FastAPI, ... on the preceding line already fails first if fastapi were absent — but that one is harmless.
2. Document GITHUB_TOOLS_SECRET (should-fix) — the .env block in plugins/omi-github-app/README.md doesn't mention the new secret. #14684 added both the env line and a short "Chat Tool Authentication" section to the shipbob README; doing the same here keeps docs moving with the code.
On github_tools_auth.py itself and the tests: no concerns. The guard mirrors mentor_webhook_auth.py (constant-time compare via hmac.compare_digest, 503 when unconfigured / 401 on invalid, Bearer header plus query-param fallback), and test_github_tools_auth.py covers both the unit behavior and the route wiring — the AST wiring test is a nice touch given the hermetic harness calls handlers directly. The github-app-tools-auth-tests entry in .github/checks-manifest.yaml is correctly registered with both lanes and matching triggers.
Note for maintainers: same deployment coordination as the earlier shared-secret rollouts — once this lands, GITHUB_TOOLS_SECRET must be configured on the service and the backend caller must present it, or the GitHub chat tools will (correctly) start failing closed. Since this is an auth-surface change, maintainer sign-off on the final shape before merge would be good.
🤖 Automated review on behalf of the maintainers.
by AI on behalf of David — if you need David’s attention urgently, please @Git-on-my-level and escalate with need human response.
…ent secret - Drop third import fallback in main.py so auth guard fails closed loudly if github_tools_auth cannot be imported. - Document GITHUB_TOOLS_SECRET in README.md .env example and add Chat Tool Authentication section. - Add test_import_fails_closed_without_noop_lambda_fallback in test_github_tools_auth.py. Failure-Class: none
Review Remediation: Fail-Closed Import Guard & Secret Documentation (Commit
|
kodjima33
left a comment
There was a problem hiding this comment.
Reviewed and approved by automated PR pipeline.
Resolves #15010
/claim #15010
Summary
The server-to-server
/tools/*chat-tool routes inplugins/omi-github-appaccepteduiddirectly 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
uidcould:POST /tools/list_repos)POST /tools/list_issues)POST /tools/get_issue)POST /tools/list_labels)POST /tools/add_issue_comment,POST /tools/add_comment)POST /tools/create_issue)POST /tools/code_feature)Fix
Follows the maintainer-approved plugin shared-secret authorization pattern (established in #13685, #14455, and #14700):
plugins/omi-github-app/github_tools_auth.py:GITHUB_TOOLS_SECRETviaAuthorization: Bearer <secret>header or?github_tools_token=query parameter fallback.hmac.compare_digest.GITHUB_TOOLS_SECRETis unset or blank so endpoints are never left silently open in production.dependencies=[Depends(require_github_tools_auth)]inplugins/omi-github-app/main.pyacross all 8 chat-tool routes:POST /tools/create_issuePOST /tools/list_reposPOST /tools/list_issuesPOST /tools/get_issuePOST /tools/list_labelsPOST /tools/add_issue_commentPOST /tools/add_commentPOST /tools/code_feature/,/auth,/auth/callback,/setup-completed,/update-repo,/refresh-repos,/check-repo-access,/save-agent-provider,/save-agent-key,/delete-agent-key,/test-agent,/health,/.well-known/omi-tools.json,/manifest.json) are intentionally left unguarded to avoid functional UI regressions.plugins/omi-github-app/test_github_tools_auth.py(10 tests) covering:github-app-tools-auth-testsin.github/checks-manifest.yaml.Verification
All test suites pass standalone and under discovery:
Failure-Class: none
Payout Details