Back to skill

Security audit

Mes

Security checks for vulnerabilities and agentic risk

Overview

This skill is a simple local entry tracker presented as an MES tool, but it needs review because it can delete stored records without confirmation and contains unsafe shell/data handling.

Review this before installing in an agent workflow. It is not a full MES integration, stores operational notes locally in ~/.mes, can permanently remove records by line number, and should not be given untrusted config or entry text until the shell quoting, JSON/CSV encoding, and deletion safeguards are fixed.

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:141
Finding

GNU sed Program Injection Through Configuration Values

Content
View full analysis
/dev/null; then sed -i "s|^${key}=.*|${key}=${val}|" "$cfg" else echo "${key}=${val}" >> "$cfg" fi ``` ### Technical Analysis The user-controlled `key` and `val` arguments are interpolated directly into a GNU `sed` program. Shell quoting protects the arguments from immediate shell word splitting and expansion, but it does not make them safe as `sed` syntax. An attacker can include delimiter characters, newlines, regular-expression metacharacters, replacement metacharacters, or GNU `sed` commands in these arguments. In environments using GNU `sed`, injection of the `e` substitution flag can cause the resulting replacement text to be passed to a shell for execution. The preceding `grep` operation is also built from the unescaped key: ```bash grep -q "^${key}=" "$cfg" ``` Consequently, the key is treated as a regular expression rather than a literal configuration key. This can cause an attacker-controlled key to match an unintended existing record and reach the vulnerable update branch. ### Attack Path A representative exploitation sequence is: 1. The attacker gains control over arguments passed to `scripts/script.sh config`, such as through an application wrapper, automation service, or agent action that accepts untrusted configuration values. 2. The attacker creates a normal configuration record so that the configuration file and target key exist: ```bash scripts/script.sh config target initial ``` 3. The attacker invokes the update operation with a value containing `sed` delimiters, an `e` flag, and a newline that comments out or otherwise neutralizes the script's generated trailing delimiter. A payload can make the generated replacement resemble: ```sed s|^ ...[truncated 1139 chars]
Remediation
View remediation
&2 return 1 fi ``` 3. Reject carriage returns, newlines, NUL-equivalent input, and other control characters in values. 4. Replace the dynamic `sed` expression with a safe configuration writer that performs literal key comparisons. For example, use a temporary file and an `awk -v` variable, while ensuring output values cannot create extra records. 5. Create temporary files using `mktemp` inside a trusted directory, set restrictive permissions, and atomically rename the completed file. 6. If arbitrary values must be supported, use a structured format such as JSON and manipulate it with a proper serializer rather than regular-expression substitutions. 7. Add regression tests covering values containing `|`, `&`, backslashes, newlines, regular-expression syntax, and strings resembling `sed` flags or commands. ]]>

T09 · Insecure Skill Coding Practices

Warning
Location
scripts/script.sh:11
Finding

Unescaped Entry Data Produces Invalid JSONL and Unsafe CSV Exports

Content
View full analysis
> "$DATA_DIR/data.jsonl" } ``` The CSV exporter also writes parsed values without CSV quoting or spreadsheet-safety handling: ```bash csv) echo "timestamp,command,value" > "$out" while IFS= read -r line; do ts=$(echo "$line" | grep -o '"ts":"[^"]*' | cut -d'"' -f4) c2=$(echo "$line" | grep -o '"cmd":"[^"]*' | cut -d'"' -f4) vl=$(echo "$line" | grep -o '"val":"[^"]*' | cut -d'"' -f4) echo "$ts,$c2,$vl" >> "$out" done < "$DATA_DIR/data.jsonl" ;; ``` ### Technical Analysis `cmd_add` ultimately passes user-provided entry text to `_save_entry`. The value is embedded inside a JSON string without escaping quotation marks, backslashes, carriage returns, newlines, or other control characters. As a result, crafted input can: - Terminate the intended JSON string. - Add apparent fields or records. - Introduce physical newline-delimited records. - Produce malformed JSON that downstream consumers cannot safely parse. - Manipulate line-based counts and removal behavior. The application later attempts to parse JSON with `grep` and `cut`. These tools do not implement JSON parsing and truncate values at embedded quotation marks, producing inconsistent behavior even when escape sequences are present. The CSV exporter concatenates fields with commas without RFC 4180 quoting. Commas, quotation marks, carriage returns, and newlines therefore alter CSV structure. In addition, values beginning with spreadsheet formula indicators such as `=`, `+`, `-`, or `@` may be in ...[truncated 1781 chars]
Remediation
View remediation
> "$DATA_DIR/data.jsonl" ``` 2. Parse stored records with a JSON parser such as `jq`, not `grep` and `cut`. 3. Reject or normalize invalid control characters if multiline entries are not a supported feature. 4. Generate CSV using a library or utility that implements RFC 4180 escaping. Every field containing commas, quotation marks, carriage returns, or newlines must be quoted, and embedded quotation marks must be doubled. 5. If exports are intended for spreadsheets, neutralize formula-leading values. A common strategy is to prefix cells beginning with `=`, `+`, `-`, or `@` with an apostrophe, while documenting that transformation. 6. Test round-trip behavior with quotation marks, backslashes, Unicode, commas, carriage returns, newlines, and spreadsheet formula prefixes. 7. Consider setting restrictive permissions on the data directory and files because manufacturing records may contain operationally sensitive information. ]]>
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 (4)

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
92% confidence
Finding

This markdown file describes a remove operation that deletes an entry, but it provides no warning about data loss, reversibility, or whether confirmation is required. For markdown files, destructive behaviors that may affect user data should be accompanied by an explicit warning.

Content

No source excerpt is available for this finding.

Description-Behavior Mismatch

Medium
Category
Not specified by scanner
Confidence
98% confidence
Finding

The manifest and help text present the tool as a manufacturing execution system tracker, which implies tracking manufacturing execution data such as work orders, machine states, jobs, or production events. In practice, the script only stores arbitrary free-form strings in a local JSONL file and offers generic add/list/search/remove/export/config commands, with no manufacturing-domain logic or MES integration.

Content

No source excerpt is available for this finding.

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
94% confidence
Finding

The remove command deletes records immediately based only on a line number, with no confirmation, preview, undo, or backup. In an agent or automation context, a mistaken argument, prompt injection, or accidental invocation could irreversibly destroy user data, making this more dangerous than in a purely manual CLI workflow.

Content

No source excerpt is available for this finding.

Missing User Warnings

Low
Category
Not specified by scanner
Confidence
84% confidence
Finding

The skill documentation states that data can be exported to a file, but it does not warn users that the command writes data to disk or clarify overwrite/location behavior. Markdown skill descriptions should disclose behaviors that affect user data or the filesystem.

Content

No source excerpt is available for this finding.

Static analysis

No suspicious patterns detected.