Skip to content

fix(core): bind reflection server to loopback only#5573

Open
evilgensec wants to merge 1 commit into
genkit-ai:mainfrom
evilgensec:fix-reflection-server-loopback-bind
Open

fix(core): bind reflection server to loopback only#5573
evilgensec wants to merge 1 commit into
genkit-ai:mainfrom
evilgensec:fix-reflection-server-loopback-bind

Conversation

@evilgensec

Copy link
Copy Markdown

Summary

The JS reflection server (js/core/src/reflection.ts) starts with server.listen(this.port, ...) and no host argument, so Node binds it to all interfaces (0.0.0.0/::) even though it logs that it is "running on http://localhost" and it is an unauthenticated local development API (it exposes /api/runAction, /api/notify, and other endpoints).

The Go (go/genkit/reflection.go -> 127.0.0.1) and Python (py/.../_reflection.py -> host='localhost') runtimes already bind loopback. This change aligns the JS runtime with them.

Change

Pass 'localhost' as the host to server.listen(...) so the reflection dev server is reachable only from the local machine. This matches the existing log message and the Go/Python behavior, and is transparent to the local genkit CLI tooling which connects via http://localhost:${port}.

@google-cla

google-cla Bot commented Jun 17, 2026

Copy link
Copy Markdown

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request restricts the reflection server to bind only to the loopback interface, preventing the unauthenticated local development API from being exposed on all interfaces. Feedback suggests explicitly binding to '127.0.0.1' instead of 'localhost' to avoid potential dual-stack (IPv4/IPv6) connectivity issues in Node.js.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

Comment thread js/core/src/reflection.ts Outdated
@evilgensec

Copy link
Copy Markdown
Author

Thanks — applied. Switched the bind from 'localhost' to the explicit IPv4 loopback '127.0.0.1' so the listen is deterministic across Node versions (avoiding the Node 17+ case where localhost can bind ::1 only) and aligns with the Go runtime, which binds 127.0.0.1.

@evilgensec evilgensec force-pushed the fix-reflection-server-loopback-bind branch from 0a1bd7f to b84fc9d Compare June 17, 2026 15:51
The JS reflection server called server.listen(port, ...) with no host,
binding all interfaces (0.0.0.0) even though it logs "localhost" and is an
unauthenticated local development API. Bind the explicit IPv4 loopback
(127.0.0.1) so the dev server is reachable only from the local machine,
matching the Go runtime (the Python runtime binds localhost).
@evilgensec evilgensec force-pushed the fix-reflection-server-loopback-bind branch from b84fc9d to 4580442 Compare June 17, 2026 15:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant