T05 · Unauthorized Access and Privilege Escalation
- Location
scripts/snapmaker.py:428- Finding
Undocumented Arbitrary G-code Execution Exceeds the Skill's Declared Privileges
- Content
View full analysis
2: return cmd_gcode(" ".join(sys.argv[2:])) ``` ### Technical Analysis The command-line handler accepts arbitrary text following the `gcode` argument, joins it without validation, serializes it as the `script` property, and submits it directly to Moonraker's `/printer/gcode/script` endpoint. No command allowlist, parameter validation, safety boundary, authorization check, or interactive confirmation is applied. The capability is also absent from `SKILL.md`, which advertises status inspection, temperature and filament monitoring, and limited print controls such as pause, resume, and cancel. Arbitrary G-code execution grants substantially broader control than those declared operations and violates least-privilege expectations. The ultimate effect depends on the G-code commands and Klipper macros installed on the target printer. Commands may control heaters, move toolheads, alter printer state, or invoke privileged macros exposed by the printer configuration. ### Attack Path 1. An attacker, untrusted caller, or manipulated Agent gains the ability to invoke the Skill's command-line script. 2. The caller supplies an unsafe printer command through the undocumented interface: ```bash scripts/snapmaker.py gcode "ATTACKER_CONTROLLED_COMMAND" ``` 3. `main()` joins all remaining command-line arguments into a single unrestricted command string. 4. `cmd_gcode()` pl ...[truncated 941 chars]- Remediation
View remediation
