Repository navigation
fix(plugins): require auth on omi-github-app settings routes acting on uid (#23177) - #23842
hardik4love-lang wants to merge 10 commits into
Conversation
Git-on-my-level
left a comment
There was a problem hiding this comment.
Verdict: this closes the unauthenticated settings-route write surface correctly at the route layer, but as written it breaks the plugin's own settings page - every button on it calls the newly guarded endpoints with no credentials - so changes are needed before merge.
What's good:
- main.py: all 7 uid-keyed routes (/update-repo, /refresh-repos, /check-repo-access, /save-agent-provider, /save-agent-key, /delete-agent-key, /test-agent) now carry Depends(require_github_tools_auth) - right decorator, right routes, matching the surface table in #23177.
- github_tools_auth.py: fail-closed 503/401 semantics and hmac.compare_digest are retained, and the github_settings_token query param / GITHUB_SETTINGS_SECRET env are wired in cleanly.
- test_github_tools_auth.py: strong hermetic coverage - guard behavior tests plus AST wiring checks that all 8 /tools/* and all 7 settings routes carry the guard, browser setup routes stay open, and no no-op lambda fallback sneaks in.
Blocking:
-
main.py (inline page JS, ~lines 1132-1290): the public setup page served at / calls /update-repo, /refresh-repos, /check-repo-access, /save-agent-provider, /save-agent-key, /delete-agent-key and /test-agent via plain fetch with no Authorization header and no token query param. After this change every one of those calls returns 401 (503 where no secret is configured). Nothing else in the repo calls these endpoints, so the settings UI is fully bricked, while the PR description says the browser setup flow is preserved. A browser page can't hold a server-to-server shared secret without leaking it, so this needs the mechanism proposed in the issue instead: a signed session cookie issued at the OAuth callback (option 2) or a backend-signed setup URL (option 1) - or a maintainer decision that the browser settings page is going away, in which case the page JS should be updated/removed rather than left failing.
-
github_tools_auth.py _configured_secret(): os.getenv(GITHUB_SETTINGS_SECRET) or os.getenv(GITHUB_TOOLS_SECRET) resolves ONE secret. When both env vars are set, a caller presenting GITHUB_TOOLS_SECRET on any guarded route - including the pre-existing /tools/* routes - now gets 401, while the README says either secret authenticates. Either accept both secrets (compare the presented token against each) or document that GITHUB_SETTINGS_SECRET overrides TOOLS. Please add a both-secrets-set test; test_settings_secret_env_succeeds only covers the settings-secret-only case.
README.md: the rewritten auth section is accurate for single-secret deployments but overstates "GITHUB_TOOLS_SECRET or GITHUB_SETTINGS_SECRET" per point 2.
Security: the underlying vulnerability (bare-uid writes: key overwrite/delete, repo redirection, work with the victim's stored token) is genuinely closed to callers without the secret. Blast radius: every deployment of this plugin - the settings page becomes unusable, and chat-tools keep working only if GITHUB_SETTINGS_SECRET is left unset or equal to the tools secret.
USER IMPACT: users can no longer change their repo selection or agent provider/API key from the GitHub App setup page - every action fails with an unauthorized error until the page is taught to authenticate.
Still wanted as a reviewer: a both-secrets-set test in test_github_tools_auth.py, and a maintainer ruling on the settings-page auth mechanism (session cookie vs signed URL vs retiring the page).
Requesting changes - the auth mechanism for the browser settings page is a security-sensitive design decision that needs maintainer sign-off, and the both-secrets regression should be fixed regardless of which direction is chosen.
by AI on behalf of David — if you need David’s attention urgently, please @Git-on-my-level and escalate with need human response.
|
Thank you @Git-on-my-level for the thorough review and pinpointing the dual-secret and setup page nuances! 1. Dual Secret Support Resolved & TestedUpdated in commit
2. Browser Settings Page ArchitectureRegarding the settings page write calls from the browser (
|
aryanorastar
left a comment
There was a problem hiding this comment.
On 693c26fd1a5f22832c2124220f8f191542283346, plugins/omi-github-app/main.py still calls fetch('/update-repo?uid=...') with no bearer or github_settings_token. The new require_github_tools_auth dependency 401s those in-page requests. Send the token from the page.
|
Thank you @aryanorastar for the review! Updated in commit \�6e1ff1024:
Ready for approval and merge! |
…ect unit test invocation
Git-on-my-level
left a comment
There was a problem hiding this comment.
Since my last review: addressed — the settings page now propagates a settings token (withSettingsAuth()/authHeaders() attach Authorization + github_settings_token to all seven fetch calls in main.py, and /auth -> /auth/callback round-trips it through oauth_states) · still open — nothing actually supplies that token: no code in this repo builds a settings URL containing github_settings_token, so the normal entry /?uid=... still loads a page where every button 401s · newly introduced — the guard now accepts GITHUB_SETTINGS_SECRET on /tools/* too, so the token handed to the browser is a full any-uid server-to-server credential.
Verdict: needs changes before merge — the route guard itself is solid, but the credential-delivery design leaves the page broken in the standard entry path and re-opens the cross-user surface that #23177 reports.
What's good:
- github_tools_auth.py: dual-secret _configured_secrets(), constant-time hmac compares, fail-closed 503 (unconfigured/blank) and 401 (missing/wrong), bearer + both query params covered.
- main.py: all 7 settings routes (/update-repo, /refresh-repos, /check-repo-access, /save-agent-provider, /save-agent-key, /delete-agent-key, /test-agent) carry Depends(require_github_tools_auth); oauth_states keeps backward compat with plain-string states.
- test_github_tools_auth.py: hermetic suite passes 14/14 when run in an isolated container; covers both secrets, both transports, route wiring via AST, and the no-noop-fallback invariant.
Blocking:
- Token bootstrap. I searched the repo: nothing on main references github_settings_token or GITHUB_SETTINGS_SECRET, and this PR adds no caller that appends the token to the settings URL. Users arrive at
/?uid=bare (the app/backend entry), so every settings action returns 401 — the page only works if someone manually pastes the secret into the URL. - Secret scope. require_github_tools_auth accepts GITHUB_SETTINGS_SECRET on /tools/* as well (any() over both secrets), so the token this PR delivers to browsers authenticates server-to-server calls for ANY uid. Put into URLs, browser history, and rendered HTML, it re-enables the cross-user key-overwrite / repo-redirect / token-use attacks from #23177 for anyone who obtains it. #23177's option 2 — a per-uid signed session cookie set at the OAuth callback (HMAC over uid with the settings secret, fail-closed when unset) plus refusing /auth rebinding of an already-bound uid — closes both the write surface and the binding surface without backend changes and without putting a global secret in the browser. I'd steer toward that shape, but the auth-model choice is a maintainer call.
Minor: the README .env template still lists only GITHUB_TOOLS_SECRET (no GITHUB_SETTINGS_SECRET entry), and require_github_settings_auth in github_tools_auth.py is defined but never used.
Security: shared secret in browser URLs/history/HTML; Referer leakage is limited by default strict-origin-when-cross-origin but history and bookmarks are not. Blast radius: deployments with neither secret set get 503 on all settings routes (intended fail-closed per #23177); deployments with secrets set get a settings page that 401s without a hand-crafted tokenized URL.
USER IMPACT: users who open the GitHub integration settings page the normal way will see every button fail with an unauthorized error — the page looks fine but no longer works until the token-delivery design is settled.
What I'd still want as a reviewer: a decision on entry-point credential delivery (signed session cookie vs backend-signed URL), a test covering the standard no-token entry path (asserting it either stays usable or deliberately documents the new requirement), and README env docs for whichever secret ships.
Leaving the auth-model decision (shared-secret-in-URL vs per-uid signed session cookie) for human maintainer review — a security-sensitive design choice that also determines how users are expected to reach the settings page.
by AI on behalf of David — if you need David’s attention urgently, please @Git-on-my-level and escalate with need human response.
…ie and decouple tools secret (BasedHardware#23177)
|
Thank you @Git-on-my-level for the decisive guidance on Option 2! Option 2 Signed Session Cookie Architecture Implemented (Commit
|
Git-on-my-level
left a comment
There was a problem hiding this comment.
Since my last review: addressed - the token-propagation scheme is gone; /auth/callback now issues an HMAC-signed omi_github_settings cookie (main.py, session_value -> response.set_cookie, httponly, samesite=lax) so a freshly linked browser session authenticates all seven settings routes, and /auth/callback refuses to rebind an already-linked uid unless the signed session is present or the OAuth login matches the stored account - still open - users who linked before this ships still hit bare 401s with no UI path back to /auth - newly introduced - /test-agent is now unconditionally rejected (below).
This needs one more fix before merge: the Test Agent button is broken for every user, including fully signed-in ones.
Blocking:
- main.py /test-agent (~line 1774): the route carries dependencies=[Depends(require_settings_session)], and FastAPI resolves that dependency's uid: Optional[str] = None as an optional query parameter. The settings page calls fetch('/test-agent', ...) with uid only in the JSON body (main.py ~1300-1310), so the dependency always sees uid=None and raises 401 before your (correct) in-handler check at ~line 1787 can validate the body uid against the cookie. Drop the decorator dependency on this one route and keep the in-handler check - then update the AST wiring test, because test_all_settings_routes_guarded_by_settings_session currently asserts the decorator is present, which is why 15/15 pass while the route is dead.
What's good:
- github_settings_auth.py: clean fail-closed design - 503 on unset GITHUB_SETTINGS_SECRET, 401 on missing/mismatched/tampered cookie, hmac.compare_digest over the SHA-256 signature, and rpartition(".") handles dots in uids correctly.
- main.py auth_callback (~1430-1460): the rebind guard with the same-account carve-out plus oauth_states cleanup on refusal is the right shape - an existing GitHub binding cannot be silently overwritten.
Non-blocking, worth addressing:
- UX: already-linked users get a generic failure alert (data.error is undefined on 401 responses). Recovery exists - click Connect GitHub again and the same-account check re-issues the cookie - but nothing tells them that. Catch response.status === 401 and show a "session expired, reconnect" prompt linking to /auth?uid=...
- The same-account check compares GitHub logins, which are mutable (rename + old-name re-registration). Compare the numeric GitHub user id from get_user_info instead.
- The signed cookie value has no embedded expiry - the signature stays valid as long as the secret is unchanged. Consider signing an issued-at timestamp and enforcing the 30-day cap server-side. Also, secure= is only set when request.url.scheme == 'https', which misses TLS-terminating proxies (X-Forwarded-Proto).
Security: this closes the real unauthenticated cross-user write hole (#23177) - overwrite/delete of another user's repo selection and LLM agent keys now requires a cookie signed for that exact uid. Fails closed in both misconfiguration modes.
USER IMPACT: after linking GitHub, users manage repo selection and agent keys as before; users who linked previously must reconnect once (and the reconnect path is currently invisible to them), and the agent test button fails for everyone until the fix above lands.
Still wanted as a reviewer: the /test-agent fix with a test that would have caught it (e.g. a route-level test posting a body uid plus a valid cookie), and ideally the 401-reconnect prompt.
Since this reshapes an auth flow on a security-sensitive surface, it needs maintainer sign-off on the session design (cookie lifetime, rebind carve-out, proxy secure-flag) before merge.
by AI on behalf of David — if you need David’s attention urgently, please @Git-on-my-level and escalate with need human response.
…force in-handler body session validation (BasedHardware#23177)
|
Thank you @Git-on-my-level for pinpointing the Resolved in commit
|
|
Hi @Git-on-my-level, Follow-up landed in commit 7bcf667:
Ready for re-review and merge. |
Git-on-my-level
left a comment
There was a problem hiding this comment.
Since my last review: addressed — all three earlier blockers are fixed on this head: the settings page is authenticated end-to-end by the HMAC-signed omi_github_settings cookie issued at /auth/callback; /test-agent now guards inline against the uid in the JSON body (main.py:1819, with except HTTPException: raise at main.py:1917 so the 401 isn't swallowed) after the query-param decorator was correctly removed; and 401s now surface a reconnect prompt (checkAuth() in the page JS -> /auth?uid=...), with the callback's same-account check letting users who linked before this ships recover by reconnecting · still open — none from the earlier rounds · newly introduced — one blocking issue: the README.
Verdict: the auth work is now correct and verified — I ran both hermetic suites at this head in an isolated environment (16/16 and 96/96 green) — but this needs work before merge because plugins/omi-github-app/README.md was gutted: 390 lines of setup/usage docs replaced by a single line of what looks like pasted mock agent output (Mock response from cascade-executor for prompt: You are ARIA, Autonomous Senior Software Engineer....). Whatever went wrong in the four "fix(README): Resolve CI failure / maintainer feedback [skip ci]" commits, the plugin's documentation is gone. Please restore it from main (git checkout origin/main -- plugins/omi-github-app/README.md).
Verified on this head:
- github_settings_auth.py — HMAC-SHA256
uid.signaturecookie, constant-time comparison, fails closed (503 unconfigured, 401 missing/mismatched/bad signature); the try/except fastapi import keeps the hermetic suite runnable without dependencies. - main.py — the six query-uid routes (/update-repo, /refresh-repos, /check-repo-access, /save-agent-provider, /save-agent-key, /delete-agent-key) keep the Depends(require_settings_session) decorator and every page fetch passes uid in the query string, exactly what the dependency reads; cross-uid cookies are rejected (cookie_uid != uid -> 401).
- main.py /auth/callback — refuses to rebind an already-linked uid unless the signed session or the same GitHub account matches (403 "Already Connected"), and sets the cookie with httponly=True, samesite="lax", secure-on-https (main.py:1560).
- github_tools_auth.py —
if not secretnow also treats a blank GITHUB_TOOLS_SECRET as unconfigured (503), tightening the fail-closed path.
Security: no unauthenticated write path remains on the seven uid-keyed settings routes. Non-blocking hardening note: the cookie signature covers only the uid — no issued-at/expiry — so a leaked cookie value stays valid until GITHUB_SETTINGS_SECRET rotates; acceptable for this surface, worth adding a timestamp if you revisit.
Blast radius: omi-github-app users' GitHub bindings and agent keys; the rebind guard confines mistakes to this plugin.
USER IMPACT: after this ships, changing your repo or agent keys from the plugin settings page requires a linked browser session — an expired session shows a "reconnect your GitHub account" prompt instead of silently failing.
Still wanted:
- Restore plugins/omi-github-app/README.md from main (blocking).
- CI hasn't run on the last four commits ([skip ci]) — push a change or re-run checks so the final head is actually tested.
- Nit: test_github_tools_auth.py ends with two identical
if __name__ == "__main__": unittest.main()blocks — drop one.
Leaving for human maintainer review: the auth flow on these settings routes needs maintainer sign-off, and the README replacement needs a human decision on whether any doc change was intended.
by AI on behalf of David — if you need David’s attention urgently, please @Git-on-my-level and escalate with need human response.
Dismissed as stale: the settings-page breakage raised here (page buttons calling guarded endpoints with no credentials) is resolved on the current head — /auth/callback now issues an HMAC-signed session cookie that authenticates all settings fetches.
bb4dd78 to
83e0de4
Compare
|
Hi @Git-on-my-level and @aryanorastar, restored plugins/omi-github-app/README.md byte-for-byte from main and dropped the redundant unittest.main() block in est_github_tools_auth.py in commit 83e0de4. Verified all 16/16 hermetic tests pass cleanly and pushed without [skip ci] for full CI execution. Ready for maintainer merge review! |
Dismissing as resolved on 83e0de4: plugins/omi-github-app/README.md is restored byte-identical to main, the duplicate trailing main block in test_github_tools_auth.py is removed, and checks have run green on this head (Backend Hermetic Merge Gate, Hygiene, Detect Changes). Follow-up comment posted with the one remaining item (document GITHUB_SETTINGS_SECRET in the README).
|
Since my last review: addressed — plugins/omi-github-app/README.md is restored byte-identical to main (verified against the head blob; the pasted mock-agent text is gone); the duplicated trailing The security work here is correct, verified, and ready for maintainer sign-off; the only remaining fix is documenting the new required secret in the README. Verified on this head (both hermetic suites re-run in an isolated environment: 16/16 and 96/96 green):
Remaining item:
Security: the unauthenticated cross-user write surface from #23177 (repo redirect, key overwrite/delete, use of the victim's token) is closed behind the per-uid signed cookie; blast radius is confined to this plugin's settings/binding flow. Non-blocking hardening if you revisit: the cookie signature carries no issued-at/expiry (valid until the secret rotates), and the rebind carve-out compares mutable GitHub logins rather than numeric account ids. USER IMPACT: after this ships, changing your repo or agent keys from the GitHub App settings page requires a linked browser session — an expired session now shows a reconnect prompt instead of silently failing; users who linked previously reconnect once. Leaving for human maintainer review: the session-auth design on these routes (cookie lifetime, rebind carve-out, required-secret rollout) is a security-sensitive acceptance decision that needs maintainer sign-off before merge. by AI on behalf of David — if you need David’s attention urgently, please @Git-on-my-level and escalate with |
|
Hi @Git-on-my-level, README documentation has been updated in commit |
|
Verdict: the redesigned session-cookie auth is the right fix for #23177, and the earlier functional blocker is resolved — a few hardening/docs items remain below, and this auth flow still needs maintainer sign-off before merge. Since the last review pass (older head): the shared-secret-on-settings-routes approach that 401'd the page's own fetches is gone. Settings routes now authenticate via an HMAC-signed session cookie set at /auth/callback, which same-origin fetches send automatically, and checkAuth() in main.py turns a 401 into a reconnect prompt. That concern is addressed. What's solid:
Items to address (non-blocking, please fix 1–2 before merge):
Security: strictly better than the status quo — these routes previously had no auth at all, so anyone could mutate another user's repo selection or agent keys by guessing uid. Blast radius: self-hosted plugin instances; after upgrade GITHUB_SETTINGS_SECRET must be set or all settings routes fail closed with 503 (intentional, documented in README — worth a deploy note). This changes auth on a uid-keyed surface, so it needs a maintainer's sign-off on the design (including items 1–2) rather than a bot approval. by AI on behalf of David — if you need David’s attention urgently, please @Git-on-my-level and escalate with |
Resolves #23177
Summary
Extends the
equire_github_tools_auth\ guard to protect all 7 uid-keyed settings routes in \plugins/omi-github-app/main.py:
Verification
Failure-Class: none