Back to skill

Security audit

Snapmaker U1

Security checks for vulnerabilities and agentic risk

Overview

This skill mostly matches a Snapmaker printer-control purpose, but it includes an under-documented raw G-code command path that can directly control physical printer behavior.

Review this skill before installing. It can monitor and control a Snapmaker printer, but the included script has a raw G-code command that could move hardware, heat components, invoke printer macros, or otherwise change printer state if an agent calls it. Install only if you are comfortable with that level of device control, and prefer removing or restricting the gcode command and adding explicit confirmation for cancel or other state-changing operations.

Vulnerability Patterns
  • Unauthorized Access and Privilege EscalationObtains permissions beyond the task's legitimate needs
  • Skill Instruction HijackingAlters the agent's session goals or safety constraints when the skill loads
  • Agent Memory PoisoningWrites attacker-controlled rules into memory that affect later sessions
  • Remote Payload Retrieval and ExecutionFetches external code whose behavior can change after review
  • Embedded Malicious CodeShips malicious scripts inside the skill and executes them locally
Findings (1)

T05 · Unauthorized Access and Privilege Escalation

Error
Location
scripts/snapmaker.py:428
Finding
Undocumented Arbitrary G-code Execution Exceeds the Skill's Declared Privileges<![CDATA[ ## Vulnerability Details **File Location**: `scripts/snapmaker.py:428-436` and `scripts/snapmaker.py:457-458` **Vulnerability Type**: Unrestricted printer command execution **Risk Level**: High ### Vulnerable Code ```python def cmd_gcode(command): """Send G-code command.""" print(f"📤 Sending: {command}") body = json.dumps({"script": command}) result = http_request("POST", "/printer/gcode/script", body) if result: print("✅ Command sent") return 0 print("❌ Failed to send command") return 1 ``` ```python if cmd == "gcode" and len(sys.argv) > 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
<![CDATA[ ## Remediation Suggestions 1. Remove the generic `gcode` command if arbitrary printer control is not an explicit requirement. 2. If command execution is necessary, replace unrestricted input with a strict allowlist of required commands. 3. Parse commands structurally and validate every parameter: - Reject unknown commands and custom macros. - Enforce safe numeric ranges. - Reject multiline input and command chaining. - Restrict heater temperatures, movement coordinates, speeds, and other safety-critical values. 4. Require explicit interactive confirmation for commands that move hardware, activate heaters, or alter persistent state. 5. Check the current printer state before executing a command and reject operations that are unsafe while printing, paused, faulted, or unhomed. 6. Separate read-only monitoring from write-capable control, using credentials and API permissions with the minimum necessary privileges where supported. 7. If the capability is intentionally retained, clearly document it in `SKILL.md`, including its physical risks and authorization requirements. 8. Add security tests confirming that unknown commands, custom macros, multiline payloads, and out-of-range parameters are rejected. ]]>
Vulnerability Patterns
  • Excessive AgencyUnrestricted Tool Access, Autonomous Decision Making, Scope Creep
  • Rogue AgentSelf-Modification, Session Persistence
  • MCP Least PrivilegeUnderdeclared Capability, Wildcard Permission, Missing Permission Declaration
  • MCP Tool PoisoningHidden Instructions, Unicode Deception, Parameter Description Injection
  • Prompt InjectionInstruction Override, Hidden Instructions, Exfiltration Commands
Findings (6)

Tp4

High
Category
MCP Tool Poisoning
Confidence
96% confidence
Finding
The declared description says the skill is for status, temperatures, progress, and basic print controls, but the analyzed behavior indicates additional capabilities such as listing files, sending arbitrary G-code, and reading detailed RFID/sensor data. This mismatch is dangerous because reviewers and users may authorize the skill under a narrower trust model than the implementation actually requires, enabling unexpected device control or data access.

Description-Behavior Mismatch

High
Confidence
98% confidence
Finding
The documented interface explicitly advertises a `gcode <CMD>` operation, which grants arbitrary command execution on the printer controller rather than limiting actions to status checks and basic pause/resume/cancel controls described in the skill metadata. In a Moonraker/Klipper environment, arbitrary G-code can change temperatures, move axes, disable safeguards, or alter printer state, making this a materially broader and more dangerous capability than declared.

Context-Inappropriate Capability

High
Confidence
99% confidence
Finding
The `cmd_gcode` function takes user-supplied input, concatenates it into a script payload, and submits it directly to Moonraker's `/printer/gcode/script` endpoint with no validation or restriction. Because G-code is effectively a device control language, this enables arbitrary physical actions on the printer, including unsafe heating, movement, and configuration changes, which is especially dangerous given the skill is presented as a basic monitoring/control tool.

Lp3

Medium
Category
MCP Least Privilege
Confidence
90% confidence
Finding
The skill documents use of environment variables and local configuration but does not declare an explicit tool/permission scope. That creates ambiguity about what runtime capabilities the skill expects and weakens least-privilege controls, making it easier for an agent to access local environment data without clear review boundaries.

Session Persistence

Medium
Category
Rogue Agent
Content
## Configuration

Create a config file at `~/clawd/config/snapmaker.json`:
```json
{
  "ip": "192.168.x.x",
Confidence
60% confidence
Finding
Skill establishes unauthorized persistence across sessions via cron jobs, startup scripts, or state files. Session persistence allows an attacker to maintain access beyond the current interaction.

Missing User Warnings

Medium
Confidence
92% confidence
Finding
The documentation exposes a cancel command for active prints without warning that cancellation can waste material, interrupt jobs irreversibly, or potentially leave hardware in an unexpected state. In a printer-control skill, undocumented destructive actions raise the risk of accidental operational disruption from a casual or ambiguous user request.

Static analysis

No suspicious patterns detected.