Back to skill

Security audit

Cnc

Security checks for vulnerabilities and agentic risk

Overview

This skill is a local entry tracker mislabeled as a CNC manager, and its shell script has unsafe input handling that can corrupt stored data and may allow command execution through crafted config values.

Review before installing. This appears to be a small local data tracker rather than a CNC program manager. Do not pass untrusted text into its add or config commands, and avoid using it until the config command validates input and the data/export paths use proper JSON/CSV encoding. Expect it to create ~/.cnc, persist entries there, delete entries when remove is used, and write cnc-export.json or cnc-export.csv in the current directory.

Vulnerability Patterns
  • Insecure Skill Coding PracticesFinds exploitable flaws such as hardcoded secrets or command injection
  • 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 (2)

T09 · Insecure Skill Coding Practices

Error
Location
scripts/script.sh:130
Finding

Arbitrary Command Execution Through sed Script Injection

Content
View full analysis
)"; fi elif [ -z "$val" ]; then grep "^${key}=" "$cfg" 2>/dev/null | cut -d= -f2- || echo "(not set)" else if [ -f "$cfg" ] && grep -q "^${key}=" "$cfg" 2>/dev/null; then sed -i "s|^${key}=.*|${key}=${val}|" "$cfg" else echo "${key}=${val}" >> "$cfg" fi echo "Set: $key=$val" fi } ``` ### Technical Analysis The `key` and `val` command-line arguments are embedded directly into a `sed` program: ```bash sed -i "s|^${key}=.*|${key}=${val}|" "$cfg" ``` Neither value is escaped for use in a regular expression, replacement expression, or sed script. Shell quoting prevents a direct shell metacharacter injection at the initial expansion stage, but it does not prevent the expanded argument from introducing sed syntax. In particular, Bash command-line arguments can contain newline characters. On sed implementations that support command execution, such as GNU sed, an attacker can terminate the substitution command with the `|` delimiter and inject a new `e` command on the following line. GNU sed's `e` command executes a shell command. The unescaped `key` is also used as a regular expression in `grep` and `sed`, allowing unintended matching or configuration manipulation even when command execution is not available. ### Attack Path 1. The attacker must be able to invoke the skill or influence arguments passed to its `config` command. 2. The attacker first creates an ordinary c ...[truncated 1352 chars]
Remediation
View remediation
&2 return 1 } ``` - Reject carriage returns, newlines, NUL-equivalent input, and other control characters in configuration values. - Replace the dynamic sed expression with a parser that passes data separately from program text. For example, use `awk` variables with validation and write the result to a securely created temporary file. - Prefer a structured format such as JSON and update it through a serializer such as `jq`, rather than treating configuration data as executable regular-expression syntax. - Create temporary files inside the configured data directory with `mktemp`, set restrictive permissions, and atomically rename the completed file. - Add regression tests containing sed delimiters, backslashes, newlines, regular-expression metacharacters, and attempted `e` commands. ]]>

T09 · Insecure Skill Coding Practices

Warning
Location
scripts/script.sh:12
Finding

Unescaped Entry Data Causes Invalid JSONL and Persistent Terminal-Control Injection

Content
View full analysis
> "$DATA_DIR/data.jsonl" } ``` Stored values are subsequently extracted using regular expressions and printed directly to the terminal: ```bash cmd_list() { echo "=== Cnc Entries ===" if [ -f "$DATA_DIR/data.jsonl" ]; then local count=$(wc -l < "$DATA_DIR/data.jsonl") echo "Total: $count" echo "---" tail -20 "$DATA_DIR/data.jsonl" | while IFS= read -r line; do local ts=$(echo "$line" | grep -o '"ts":"[^"]*' | cut -d'"' -f4) local cmd=$(echo "$line" | grep -o '"cmd":"[^"]*' | cut -d'"' -f4) local val=$(echo "$line" | grep -o '"val":"[^"]*' | cut -d'"' -f4) echo " [$ts] $cmd: $val" done else echo "No entries yet." fi } ``` ### Technical Analysis The `_save_entry` function inserts the supplied entry into JSON syntax without JSON encoding. Characters with special meaning in JSON—including double quotes, backslashes, newlines, carriage returns, and control characters—are written verbatim. Consequently, a value containing a quote can terminate the intended JSON string, and a value containing a newline can split one logical entry across several physical lines. This violates the documented JSONL storage format and causes line counts, removal operations, searches, exports, and field extraction to operate on corrupted records. The listing and search functions use `grep` and `cut` rather than a JSON parser. They then emit extracted data directly to the terminal. An entry containing termina ...[truncated 1705 chars]
Remediation
View remediation
> "$DATA_DIR/data.jsonl" ``` - Parse records with a JSON parser such as `jq`, rather than extracting fields with `grep` and `cut`. - Reject malformed existing records and report their line numbers instead of silently processing them. - Escape non-printable characters before displaying stored content. Control characters should be rendered visibly, for example as hexadecimal or Unicode escape notation. - Avoid using physical JSONL line numbers as stable entry identifiers. Assign each entry a unique identifier and remove records by validated identifier. - Generate CSV exports with a CSV-aware encoder that correctly quotes commas, double quotes, and embedded newlines. - Add tests for quotes, backslashes, commas, newlines, Unicode, ANSI escape sequences, and malformed records. ]]>
Vulnerability Patterns
  • MCP Tool PoisoningHidden Instructions, Unicode Deception, Parameter Description Injection
  • Prompt InjectionInstruction Override, Hidden Instructions, Exfiltration Commands
  • Data ExfiltrationExternal Transmission, Env Variable Harvesting, File System Enumeration
  • Privilege EscalationExcessive Permissions, Sudo/Root Execution, Credential Access
  • Supply ChainUnpinned Dependencies, External Script Fetching, Obfuscated Code
Findings (3)

Tp4

High
Category
MCP Tool Poisoning
Confidence
97% confidence
Finding

The code does not manage CNC machining programs in any meaningful sense. It implements a generic local entry tracker: 'add' saves arbitrary text with timestamps, 'list' and 'search' read those entries, 'remove' deletes by line number, 'export' writes JSON/CSV, and 'config' stores key-value settings. There is no CNC-specific logic such as handling G-code, machine programs, tooling metadata, machining jobs, file validation, or machine integration. While the name and help text claim to be a CNC machining program manager, the actual behavior is a simple note/log manager, so the declared description materially misrepresents the skill's true purpose.

Content

No source excerpt is available for this finding.

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
94% confidence
Finding

This markdown file documents a remove command that deletes an entry, but it provides no warning about the destructive nature of the operation, whether it is reversible, or whether confirmation is required. For markdown files, commands that can affect user data should include a clear warning so users understand the risk before invoking them.

Content

No source excerpt is available for this finding.

Missing User Warnings

Low
Category
Not specified by scanner
Confidence
85% confidence
Finding

The skill description states that export will write data to a file, but it does not warn users that the operation creates or overwrites filesystem content. Markdown guidance should disclose file-affecting behavior so users understand its impact on local data and storage.

Content

No source excerpt is available for this finding.

Static analysis

No suspicious patterns detected.