T09 · Insecure Skill Coding Practices
- Location
rules/02-截图流程.md:18- Finding
Temporary HTTP Server Exposes the Output Directory on All Network Interfaces
- Content
View full analysis
& Then open http://localhost:8899/filename.html ``` The security-relevant command in the original file is: ```bash python3 -m http.server 8899 --directory & ``` ### Technical Analysis Python's `http.server` binds to all available network interfaces by default. Although the documented browser URL uses `localhost`, the listening socket is not restricted to the loopback interface. The command serves the entire selected directory rather than only the intended HTML file. Every readable file under that directory can consequently be requested by another host that can reach TCP port 8899. The process is also placed in the background without PID tracking or guaranteed cleanup, increasing the chance that the service remains available after screenshot generation. No authentication, authorization, transport encryption, or directory isolation is applied. ### Attack Path 1. A user supplies an article or note containing sensitive information. 2. The Agent generates HTML in a working directory that may also contain other files. 3. The screenshot workflow starts `python3 -m http.server 8899 --directory ... &`. 4. Python listens on all interfaces, including a LAN or container-facing interface. 5. An attacker with network access discovers or predicts port 8899. 6. The attacker requests the generated HTML or another known file beneath the served directory. 7. The service may remain available because the workflow does not retain and terminate its PID. ### Impact Assessment This issue does not provide operating-system privilege escalation or arbitrary code execution. It can, however, gr ...[truncated 381 chars]- Remediation
View remediation
/dev/null; then kill "$SERVER_PID" wait "$SERVER_PID" 2>/dev/null || true fi rm -rf "$TEMP_OUTPUT_DIRECTORY" } trap cleanup EXIT INT TERM ``` 5. Use a randomly selected free port to reduce collisions. 6. Disable directory listings through a minimal custom handler or serve only an explicitly selected file. 7. Confirm that the browser navigates only to `127.0.0.1`, not a non-loopback hostname. ]]>
