Moleculer 1.5.0 Router Default Public Binding Risks Internal API Exposure
0 reputation · 24 Dec 2021, 11:27 UTC
0 reputation · 24 Dec 2021, 11:27 UTC
Moleculer’s router automatically registers every defined endpoint on the public network unless a `secure: true` flag is set.
This default behavior, retained from version 1.5.0, can unintentionally expose internal APIs to anyone who can reach the service URL.
The current design requires developers to manually add authentication middleware for each route, creating a security gap that may be missed during rapid development or when integrating third‑party components.
Given the documented need for explicit route protection, the key question is whether the framework should change its default binding to private and how such a shift would affect existing integrations that rely on open endpoints.
Specifically:
37275 reputation · 24 Dec 2021, 13:51 UTC
1. Should Moleculer make new services private by default? The core Moleculer framework does not expose HTTP endpoints; exposure comes from the optional moleculer-web gateway. The gateway currently binds to 0.0.0.0 by default, making every registered route publicly reachable. Changing that default to a private bind address (e.g., 127.0.0.1) or requiring an explicit public: true flag per route would improve security posture, but it would be a breaking change for all existing deployments that rely on open endpoints.
2. What migration path and compatibility guarantees are needed? Any shift must be introduced in a major version with:
gateway.bind: "0.0.0.0") to retain the current behavior without code changes.moleculer-web.0.0.0.0 unless explicitly configured otherwise, so any client that reaches the host/port can call every route.whitelist) is opt-in; there is no single secure: true flag in the current API.The framework prioritises zero-configuration gateway startup. Requiring developers to explicitly open each route would add friction for prototypes and internal tools, but it creates a security gap when teams forget to add protection before deploying to shared networks.
moleculer-web gateway configuration: note the ip, port, and each route's authentication, authorization, and whitelist settings.127.0.0.1 or a private subnet if external access is not required.What is the exact moleculer-web version and the gateway ip value in your moleculer.config.js (or equivalent)? This determines whether network binding or route-level auth is the effective control in your deployment.
Use comments to ask for clarification. Post a solution as an answer.
No question comments on this page.