T09 · Insecure Skill Coding Practices
- Location
bare.py:4- Finding
Service Listens on Multiple Undeclared Network Ports
- Content
View full analysis
Vulnerability Details
File Location:
bare.py:4, 49-57
Vulnerability Type: Excessive network exposure and insecure service configuration
Risk Level: LowVulnerable Code:
python host = os.environ.get("HOST") or "0.0.0.0"python if __name__ == "__main__": ports = [port] if port else [] for candidate in [8080, 8000, 3000, 80]: if candidate not in ports: ports.append(candidate) started = False for p in ports: try: t = threading.Thread(target=run_on, args=(p,), daemon=True) t.start()Technical Analysis
The service defaults to binding on
0.0.0.0, making it reachable through every available network interface. It then starts listener threads for the configured port and every fallback port in the list:8080,8000,3000, and80.This behavior exceeds the interface declared in
skill.yaml, which identifies only port8080. Attempting to listen on several undeclared ports unnecessarily increases the network attack surface. Port80is also commonly privileged on Unix-like systems, although whether this process can bind to it depends on its runtime privileges and capabilities.Binding failures are suppressed by the broad exception handler in
run_on, so operators receive no indication of which ports were successfully exposed. The current endpoints return static demonstration data and do not directly expose credentials or privileged operations, which limits the immediate severity.Attack Path
- An operator starts the skill in a container or host that permits inbound network access.
- The process binds to all interfaces and attempts to open ports
8080,8000,3000, and80. - An attacker with network access scans the host for open ports.
- The attacker discovers one or more listeners beyond the port declared by the skill configuration.
- The attacker sends unauthenticated reques ...[truncated 901 chars]
- Remediation
View remediation
Remediation Suggestions
- Bind only to the single validated port supplied by the deployment environment or declared in
skill.yaml. - Remove automatic probing of ports
8000,3000, and80. - Default to
127.0.0.1when external network access is unnecessary; otherwise require an explicit host configuration before binding to0.0.0.0. - Validate that the selected port is in the range
1through65535. - Avoid privileged ports unless they are explicitly required and the process uses a narrowly scoped capability.
- Replace silent exception suppression with structured error logging and terminate startup if the intended listener cannot be created.
- Apply authentication and authorization before adding sensitive functionality to
/invoke. - Restrict inbound access using container network policies, host firewalls, or platform-level service configuration.
- Bind only to the single validated port supplied by the deployment environment or declared in
