Back to skill

Security audit

Unitconv

Security checks for vulnerabilities and agentic risk

Overview

This unit converter is mostly coherent, but its calculator script lets a crafted conversion value run local shell commands through AWK, so it needs review before installation.

Do not install this version where conversion inputs may come from untrusted users or automated workflows. The publisher should validate numeric values and pass data to AWK with -v or fixed calculation functions before this is treated as a routine local utility.

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 (1)

T09 · Insecure Skill Coding Practices

Error
Location
scripts/script.sh:43
Finding
Arbitrary Command Execution Through AWK Program Injection## Vulnerability Details **File Location**: `scripts/script.sh`, lines 43-45 **Vulnerability Type**: AWK code injection leading to arbitrary command execution **Risk Level**: High ### Vulnerable Code ```bash calc() { awk "BEGIN { printf \"%.6g\", $1 }" } ``` User-controlled conversion values reach this function through calls such as: ```bash calc "${val} * ${from_m} / ${to_m}" ``` ### Technical Analysis The `calc` function interpolates its first argument directly into an AWK program enclosed in a double-quoted shell string. The conversion value is therefore treated as executable AWK source rather than numeric data. The conversion functions quote shell arguments while passing them to `calc`, which prevents ordinary shell word splitting at that stage but does not prevent AWK-language injection. An attacker can terminate the intended arithmetic expression with a semicolon and insert additional AWK statements. Because AWK provides the `system()` function, injected AWK code can invoke arbitrary operating-system commands. The issue affects every conversion command because all conversion functions eventually include the attacker-controlled `val` variable in a string passed to `calc`. ### Attack Path 1. An attacker supplies a crafted value as the numeric argument to any supported conversion command. 2. The selected conversion function embeds that value into an arithmetic expression. 3. `calc` inserts the entire expression directly into AWK source code. 4. The crafted value terminates the intended expression and adds an AWK `system()` call. 5. AWK executes the supplied operating-system command with the privileges of the user running UnitConv. Example proof of concept: ```bash ./scripts/script.sh length \ '0; system("id"); printf "%.6g", 0' \ m m ``` This produces an AWK program containing an injected `system("id")` statement. A real attacker could replace `id` with another command available to ...[truncated 640 chars]
Remediation
## Remediation Suggestions 1. Validate the conversion value against a strict numeric grammar before performing any calculation. Support only the required formats, such as integers, decimal numbers, and optionally scientific notation. ```bash validate_number() { local value="$1" [[ "$value" =~ ^[+-]?([0-9]+([.][0-9]*)?|[.][0-9]+)([eE][+-]?[0-9]+)?$ ]] || { err "Invalid numeric value: $value" exit 1 } } ``` 2. Never concatenate user-controlled values into AWK source. Pass all values as data through `awk -v` and use a fixed AWK program: ```bash calc_ratio() { local value="$1" local from_factor="$2" local to_factor="$3" validate_number "$value" awk -v value="$value" \ -v from_factor="$from_factor" \ -v to_factor="$to_factor" \ 'BEGIN { printf "%.6g", value * from_factor / to_factor }' } ``` 3. Use separate fixed calculation functions for special formulas such as temperature conversion, again passing values through `-v` rather than constructing executable AWK expressions. 4. Reject non-finite or unsupported inputs according to the utility's requirements, and add negative-temperature bounds where physical validity is expected. 5. Add regression tests containing AWK metacharacters and payloads such as semicolons, braces, quotes, and `system()` calls. Tests should verify that these inputs are rejected and never cause a subprocess to run. 6. Run the utility with the minimum required privileges and avoid exposing it through a privileged service until the injection flaw has been corrected.
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
98% confidence
Finding
The code largely matches the declared description: it is a local unit conversion utility covering length, weight, temperature, data, and speed. It does not access external resources or require permissions beyond local execution. However, it also implements a full time conversion feature (`time <value> <from> <to>`), which is a substantive additional capability not mentioned in the declared description. That undeclared capability makes the description incomplete, so this should be flagged as a mismatch.

Description-Behavior Mismatch

Medium
Confidence
98% confidence
Finding
The manifest scope lists five conversion categories and does not include time. The script's usage text and dispatcher explicitly expose a `time` command, expanding the skill beyond its declared behavior.

Description-Behavior Mismatch

Low
Confidence
98% confidence
Finding
The manifest description claims the skill converts units for length, weight, temperature, data, and speed, but the skill documentation also exposes a `time` conversion command and lists time among supported units. This is a scope mismatch between the stated purpose in the manifest and the actual documented behavior.

Static analysis

No suspicious patterns detected.