T09 · Insecure Skill Coding Practices
- Location
scripts/mock_server.py:33- Finding
Mock Server Listens on All Network Interfaces by Default
- Content
View full analysis
Vulnerability Details
File Location:
scripts/mock_server.py:33-39,scripts/mock_server.py:140-143, andscripts/mock_server.py:167-177
Vulnerability Type: Unsafe default network exposure
Risk Level: MediumVulnerable Code
python def __init__(self, port=3000, host="0.0.0.0", latency=0): self.port = port self.host = host self.latency = latency self.app = Flask(__name__) self._routes = {} self.fake = Faker()python server = cls( port=config.get("port", 3000), host=config.get("host", "0.0.0.0"), latency=config.get("latency", 0) )python parser = argparse.ArgumentParser(description="API Mock Server") parser.add_argument("--config", help="Path to routes JSON config") parser.add_argument("--port", type=int, default=3000, help="Server port") parser.add_argument("--host", default="0.0.0.0", help="Server host") parser.add_argument("--latency", type=int, default=0, help="Artificial latency in ms") args = parser.parse_args() if args.config: server = MockServer.from_config(args.config) else: server = MockServer(port=args.port, host=args.host, latency=args.latency)Technical Analysis
Every supported initialization path uses
0.0.0.0as the default listening address. This binds the Flask server to all available network interfaces rather than limiting access to the local machine.The mock server implements no authentication or authorization. Consequently, any system that can route traffic to the selected port can invoke the configured mock endpoints. The exposure may include a local network, a shared development environment, a container network, or an externally reachable interface, depending on host firewall and network configuration.
Safe development-server behavior should follow a deny-by-default model. A service intended primarily for local prototyping should bind to
127.0.0.1unless the operator exp ...[truncated 1134 chars]- Remediation
View remediation
Remediation Suggestions
- Change every default listening address from
0.0.0.0to127.0.0.1, including the constructor, configuration loader, and command-line parser. - Require an explicit
--host 0.0.0.0or equivalent configuration property when external access is genuinely required. - Display a prominent warning when the selected address is not a loopback address.
- Document that externally exposed instances require network-level access controls or application authentication.
- Consider an explicit option such as
--allow-remotebefore accepting a non-loopback binding. - Add tests confirming that constructor, CLI, and configuration-file defaults all resolve to
127.0.0.1.
- Change every default listening address from
