fix(auth): bind OAuth callback listener to loopback only - #6238
Open
SashaMIT wants to merge 1 commit into
Open
Conversation
The interactive login callback server bound ":port" (all interfaces) while advertising a localhost redirect URL. For the lifetime of a login, any host on the LAN could probe the listener and abort the flow by hitting /callback?error=... (no state needed on the error path). Login-code theft is not possible: the 128-bit state is validated before token exchange, so the impact is login DoS only. Bind 127.0.0.1 explicitly, matching the redirect URL host and the loopback address the port-availability probe already uses. Added TestListenAddrLoopback asserting the listener address is loopback. Signed-off-by: Sasha Mitchell <sash.t.mitchell@gmail.com>
SashaMIT
requested review from
ChrisJBurns,
JAORMX,
jhrozek,
rdimitrov and
tgrunnagle
as code owners
August 7, 2026 20:09
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Anyone on the local network can cancel your ToolHive login while you are signing in.
Problem
The OAuth callback server used during interactive login binds
:port(all interfaces) for the whole login flow, while the redirect URL it advertises ishttp://localhost:<port>/callback:Any host on the LAN can therefore reach the callback endpoint while a login is in progress and:
/callback?error=access_denied(the error path does not require thestateparameter) or by sending a wrongstate.Login-code theft is not possible: the 128-bit random state is validated before any token exchange, so an attacker cannot inject their own authorization code. The impact is an unauthenticated remote denial of service of interactive logins, plus an HTTP surface on every interface that has no reason to be reachable off-host.
Fix
Bind the listener to
127.0.0.1explicitly via a smalllistenAddr()helper. This matches the redirect URL's localhost semantics and the loopback address the port-availability probe (networking.IsAvailable) already uses when selecting the callback port.Tests
Added
TestListenAddrLoopback, which asserts the listener address parses to a loopback IP on the flow's callback port. Thepkg/auth/oauth,pkg/auth/tokensource, andpkg/auth/discoverysuites pass.Made with Cursor