Fix OAuth callback server to bind to localhost only #190
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.
📋 Summary
Fixed issue where OAuth callback server was binding to
0.0.0.0(all network interfaces) instead of127.0.0.1(localhost only), exposing the OAuth authorization endpoint to the local network during authentication flows.🐛 Problem
The OAuth callback server in
setupOAuthCallbackServer()was listening on all interfaces, contradicting its own log message:Despite the log claiming
http://127.0.0.1:${options.port}, the server was actually binding to0.0.0.0:PORT, making it accessible from the network rather than localhost only.Express 4.21.2 delegates to http.Server.listen():
https://github.com/expressjs/express/blob/4.21.2/lib/application.js#L633-L636
http.Server inherits from net.Server:
https://github.com/nodejs/node/blob/6c9a7cd61ef4be527da9cfa86e42edb17c3ec123/lib/_http_server.js#L574-L575
net.Server.listen() defaults to 0.0.0.0 when hostname omitted:
https://github.com/nodejs/node/blob/6c9a7cd61ef4be527da9cfa86e42edb17c3ec123/lib/net.js#L149-L150
✅ Solution
Explicitly bind the Express server to
127.0.0.1:📝 Changes
File:
src/lib/utils.ts'127.0.0.1'as second parameter toapp.listen()🔍 Impact
localhost/127.0.0.1in OAuth registration