Back to skill

Security audit

Switchgear

Security checks for vulnerabilities and agentic risk

Overview

This skill is a local switchgear record manager, but its shell script has input-handling flaws that can lead to command execution or corrupted exports.

Install only if you are comfortable reviewing or fixing the shell script first. Avoid passing untrusted values to config, avoid opening exported CSV files from untrusted entries in spreadsheet software, and treat remove/export/config as actions that should require explicit user direction.

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

T09 · Insecure Skill Coding Practices

Error
Location
scripts/script.sh:143
Finding

Arbitrary Command Execution Through Sed Injection in Configuration Updates

Content
View full analysis
/dev/null; then sed -i "s|^${key}=.*|${key}=${val}|" "$cfg" ``` ### Technical Analysis The configuration key and value are inserted directly into a GNU `sed` program. Shell quoting prevents ordinary shell metacharacters from being interpreted by the shell that invokes `sed`, but it does not make the generated `sed` expression safe. An attacker can include the `|` delimiter in `val`, terminate the replacement section, and append GNU sed's `e` flag. The `e` flag executes the resulting replacement text as a shell command. The vulnerable branch is reached when the specified key already exists in `config.txt`. Neither `key` nor `val` is validated or escaped for use as `sed` syntax. ### Attack Path 1. Create a configuration entry so the update branch is used: ```bash scripts/script.sh config X safe ``` 2. Update the existing key with a malicious value: ```bash scripts/script.sh config X '1; touch /tmp/pwned|e;#' ``` 3. The script constructs an expression equivalent to: ```bash sed -i 's|^X=.*|X=1; touch /tmp/pwned|e;#|' "$cfg" ``` 4. On GNU sed, the `e` flag executes the replacement as a shell command, resulting in the creation of `/tmp/pwned`. The same technique can execute other commands available to the account running the skill. ### Impact Assessment Successful exploitation provides arbitrary command execution with the privileges of the user or AI agent process invoking the script. The attacker can read or modify accessible files, destroy local data, execute additional programs, access user-level credentials, or perform other actions permitted to that account. The vulnerability does not independently elevate privileges beyond the invok ...[truncated 112 chars]
Remediation
View remediation
&2 return 1 fi ``` - Replace the dynamic `sed` operation with a non-evaluating update mechanism. For example, pass data to `awk` as variables and compare fields as data rather than source code. - Write the updated configuration to a securely created temporary file and atomically replace the original file only after successful processing. - If `sed` must be retained, escape every delimiter, backslash, ampersand, newline, and regular-expression metacharacter. A parser-based implementation is strongly preferred because incomplete escaping can reintroduce command execution. - Add regression tests using values containing `|`, `&`, backslashes, newlines, and strings resembling sed flags or commands. ]]>

T09 · Insecure Skill Coding Practices

Warning
Location
scripts/script.sh:11
Finding

JSON Record Injection Through Unescaped Entry Data

Content
View full analysis
> "$DATA_DIR/data.jsonl" } ``` ### Technical Analysis The script builds JSON by interpolating strings into a format template without JSON encoding them. User-controlled entry values can contain double quotes, backslashes, control characters, and literal newlines. A double quote can terminate the intended `val` string, while a newline can terminate the current JSONL record and introduce additional apparent records. The resulting file may therefore contain malformed JSON or attacker-forged entries. Downstream commands do not use a JSON parser. They extract fields with `grep` and `cut`, which makes them unable to distinguish legitimate serialized data from injected syntax. ### Attack Path 1. Supply an entry containing a closing JSON sequence, a newline, and a forged record: ```bash scripts/script.sh add $'legitimate"}\n{"ts":"2026-01-01 00:00:00","cmd":"add","val":"forged' ``` 2. `_save_entry` writes the value directly into `data.jsonl`. 3. The embedded newline creates an additional physical line that subsequent commands treat as another entry. 4. Run commands such as: ```bash scripts/script.sh list scripts/script.sh stats scripts/script.sh export json ``` 5. The forged line affects displayed records, line-based statistics, and exported data. Other crafted quotes or backslashes can instead make the JSON invalid. ### Impact Assessment An attacker able to control entry arguments can corrupt the local data store, forge records, alter entry counts, produce invalid JSON exports, and mislead users who rely on list or status output. The im ...[truncated 229 chars]
Remediation
View remediation
> "$DATA_DIR/data.jsonl" ``` - Parse stored records with a JSON parser such as `jq` instead of regular expressions and `cut`. - Reject invalid existing records and report corruption rather than silently processing them. - Apply reasonable entry-length limits to reduce storage abuse. - Add tests covering quotes, backslashes, tabs, carriage returns, Unicode, and embedded newlines. - Consider validating the complete JSONL file before replacing or exporting it. ]]>

T09 · Insecure Skill Coding Practices

Warning
Location
scripts/script.sh:114
Finding

CSV Formula Injection and Invalid CSV Serialization

Content
View full analysis
"$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 CSV fields are concatenated with commas without applying CSV quoting or escaping. Values containing commas, double quotes, carriage returns, or newlines can alter the row and column structure. In addition, values beginning with characters such as `=`, `+`, `-`, or `@` may be interpreted as formulas when the exported file is opened in spreadsheet software. Depending on the spreadsheet product, version, security settings, and formula payload, this can trigger calculations, external requests, links, or legacy command-execution mechanisms. The script also extracts JSON fields using regular expressions rather than a JSON parser, compounding serialization errors when stored values contain quotes. ### Attack Path 1. Add a value that begins with a spreadsheet formula marker: ```bash scripts/script.sh add '=1+1' ``` 2. Export the data as CSV: ```bash scripts/script.sh export csv ``` 3. The output contains an unescaped cell similar to: ```csv 2026-01-01 00:00:00,add,=1+1 ``` 4. Open the generated `switchgear-export.csv` in a formula-capable spreadsheet application. 5. The spreadsheet interprets the attacker-controlled cell as a formula rather than literal text. More dangerous formulas may produce external interactions or other effects where supported by the application and permitted by its security policy. Separately, supplying commas or lin ...[truncated 696 chars]
Remediation
View remediation
Vulnerability Patterns
  • Data ExfiltrationExternal Transmission, Env Variable Harvesting, File System Enumeration
  • Trigger AbuseOverly Broad Trigger, Shadow Command Trigger, Keyword Baiting Trigger
  • Prompt InjectionInstruction Override, Hidden Instructions, Exfiltration Commands
  • Privilege EscalationExcessive Permissions, Sudo/Root Execution, Credential Access
  • Supply ChainUnpinned Dependencies, External Script Fetching, Obfuscated Code
Findings (2)

Vague Triggers

Medium
Category
Not specified by scanner
Confidence
95% confidence
Finding

The skill description and usage guidance are broad and underspecified, which can cause an agent to invoke the skill in loosely related contexts without clear user intent or safety checks. Because the skill includes state-changing operations such as add, remove, export, and config, ambiguous activation increases the chance of unintended file or data modifications.

Content

No source excerpt is available for this finding.

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
88% confidence
Finding

The documentation presents remove and export as routine commands without warning about deletion, overwrite, or data exfiltration risks. In an agent setting, lack of explicit cautions can lead to irreversible record deletion or writing sensitive operational data to unintended locations, especially when combined with configurable directories.

Content

No source excerpt is available for this finding.

Static analysis

No suspicious patterns detected.