Sanitize sys.argv in /system_stats to prevent exposing sensitive command-line arguments
- Dominant language
- Python
- Stars
- 133k
- Forks
- 15.7k
- Avg merge
- 1d 7h
- Merged PRs (30d)
- 158
Description
### Custom Node Testing
- [x] I have tried disabling custom nodes and the issue persists (see [how to disable custom nodes](https://docs.comfy.org/troubleshooting/custom-node-issues#step-1%3A-test-with-all-custom-nodes-disabled) if you need help)
### Expected Behavior
The telemetry and diagnostics endpoint `/system_stats` should report diagnostic metrics (OS, Python version, PyTorch version, VRAM) and only the main executable name, without exposing the full raw command-line arguments array (`sys.argv`) which may contain sensitive local directory paths or launch parameters.
### Actual Behavior
In `server.py` line 733, the endpoint returns the entire unmasked `sys.argv` list in the JSON response:
`"argv": sys.argv`
Any unauthenticated client querying `/system_stats` can view all startup flags (such as `--output-directory`, `--extra-model-paths-config`, or custom paths).
### Steps to Reproduce
1. Launch ComfyUI with command-line arguments, for example:
`python main.py --extra-model-paths-config /path/to/private/models.yaml --output-directory /path/to/renders`
2. Send a GET request to `http://127.0.0.1:8188/system_stats`.
3. Check the `system.argv` field in the JSON response.
4. Notice that all private paths and flags are returned in plaintext.
### Debug Logs
```powershell
[INFO] ComfyUI version: 0.33.0
[INFO] Python version: 3.11.9
[INFO] Starting server
[INFO] To see the GUI go to: http://127.0.0.1:8188
Sample JSON response from GET /system_stats:
{
"system": {
"os": "win32",
"comfyui_version": "0.33.0",
"python_version": "3.11.9",
"argv": [
"main.py",
"--extra-model-paths-config",
"D:\\Private\\models.yaml",
"--output-directory",
"D:\\Confidential\\Renders"
]
}
}
```
### Other
**Proposed Solution**
In `server.py` (line 733), sanitize the `argv` field to only expose the script name:
```diff
--- a/server.py
+++ b/server.py
@@ -730,7 +730,7 @@ class PromptServer():
"pytorch_version": comfy.model_management.torch_version,
"embedded_python": os.path.split(os.path.split(sys.executable)[0])[1] == "python_embeded",
"deploy_environment": get_deploy_environment(),
- "argv": sys.argv
+ "argv": [sys.argv[0]] if len(sys.argv) > 0 else []
},
"devices": device_entries
}
Contributor guide
Research direction
Start in server.py around the /system_stats endpoint and inspect how the system JSON is assembled. Run ComfyUI with sample command-line paths, query /system_stats, and verify that the response contains only the main executable name in argv and no other flags or private paths.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- api, security
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Active
- Clarity
- Clearly specified
- Newbie friendliness
- 84/100