Back to skill

Security audit

Shell Scripting

Security checks for vulnerabilities and agentic risk

Overview

The skill is a shell-scripting reference, but several examples teach unsafe shell patterns that could lead to command execution or unintended file deletion.

Review this skill before installing. It is not malicious, but it may cause an agent to suggest insecure shell scripts. Be especially careful with generated snippets that process filenames, source configuration files, download URLs, or delete files recursively.

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
SKILL.md:235
Finding

Shell Command Injection Through Unsafe Filename Interpolation

Content
View full analysis

Vulnerability Details

File Location: SKILL.md, line 235
Vulnerability Type: Shell command injection and unsafe filename handling
Risk Level: High

Vulnerable Code:

bash
find . -name "*.jpg" | xargs -P 8 -I {} sh -c 'convert {} -resize 800x600 resized/{} && echo "Done: {}"'

Technical Analysis

The example substitutes filenames directly into a command string evaluated by sh -c. Because the substituted value is interpreted as shell syntax rather than passed exclusively as a command argument, a crafted filename containing quotes, command substitutions, separators, redirections, or other shell metacharacters can change the command's structure and execute unintended commands.

The pipeline also uses newline-delimited find output rather than NUL-delimited records. Consequently, valid filenames containing newlines can be split into separate inputs, while spaces and quoting characters can produce incorrect or dangerous command interpretation.

Although this is documentation rather than an executable script, the Skill explicitly recommends the pattern for generated shell code. Copying or generating this example in a directory containing attacker-controlled filenames creates an exploitable command-execution path.

Attack Path

  1. An attacker gains the ability to create or extract a .jpg file in a directory processed by the generated command.
  2. The attacker gives the file a name containing shell syntax that breaks out of the intended convert argument context.
  3. find emits the crafted filename.
  4. xargs -I {} inserts the filename directly into the single-quoted command template.
  5. sh -c parses the resulting text as shell code.
  6. The injected command executes with the privileges of the user or service running the script.

Impact Assessment

Successful exploitation permits arbitrary command execution under the script runner's account. The attacker could read or modify any files a ...[truncated 282 chars]

Remediation
View remediation

Remediation Suggestions

Do not interpolate filenames into shell source. Use NUL-delimited records and pass each filename as a positional parameter:

bash
find . -name '*.jpg' -print0 |
  xargs -0 -P 8 -I {} sh -c '
    input=$1
    output="resized/$(basename "$input")"
    convert "$input" -resize 800x600 "$output" &&
      printf "Done: %s\n" "$input"
  ' sh '{}'

Prefer invoking a dedicated processing script directly so no additional shell parser is required:

bash
find . -name '*.jpg' -print0 |
  xargs -0 -P 8 -n 1 ./process-image.sh

Inside process-image.sh, quote every expansion, derive output paths safely, reject unexpected path structures where appropriate, and use -- before operands for tools that support it.

T09 · Insecure Skill Coding Practices

Error
Location
SKILL.md:387
Finding

Arbitrary Code Execution Through Inadequately Validated Sourced Configuration

Content
View full analysis

Vulnerability Details

File Location: SKILL.md, lines 387–390
Vulnerability Type: Unsafe configuration evaluation
Risk Level: High

Vulnerable Code:

bash
if grep -qP '^[A-Z_]+=.*[;\`\$\(]' config.env; then
    die "Config file contains unsafe characters"
fi
source config.env

Technical Analysis

The source builtin interprets the entire configuration file as shell code in the current process. The preceding regular-expression check is a denylist rather than a complete parser and only detects a limited set of characters on lines beginning with an uppercase-style assignment.

It does not require every non-comment line to be a valid assignment. Standalone commands, function definitions, redirections, shell keywords, and other executable constructs can therefore avoid the check while remaining valid shell syntax. Denylists are also fragile because shell grammar provides many execution mechanisms and context-dependent forms that are difficult to enumerate safely.

Sourcing the file also allows it to modify shell options, functions, variables, traps, and positional state in the caller, creating effects beyond simple configuration loading. The example is exploitable whenever an attacker can create or modify config.env, including through an untrusted archive, writable working directory, deployment artifact, or compromised configuration pipeline.

Attack Path

  1. An attacker obtains write access to the config.env consumed by a script based on this guidance.
  2. The attacker adds executable shell syntax on a line that does not match the denylist, such as a standalone command without the checked assignment prefix.
  3. The grep condition finds no forbidden match and permits processing to continue.
  4. source config.env evaluates the entire file in the current shell.
  5. The attacker's command runs with the privileges and environment of the script runner.
  6. Because execution occurs in the curre ...[truncated 678 chars]
Remediation
View remediation

Remediation Suggestions

Do not use source, ., or eval for configuration that is not fully trusted. Treat the file as data and implement an allowlist parser that:

  1. Accepts only blank lines, comments, and a strict KEY=VALUE grammar.
  2. Rejects every malformed line rather than merely searching for selected metacharacters.
  3. Permits only explicitly expected keys.
  4. Assigns parsed values without evaluating them as shell syntax.
  5. Validates each value according to its expected type and range.
  6. Verifies file ownership and permissions when the trust model requires it.

For example:

bash
while IFS= read -r line || [[ -n "$line" ]]; do
    [[ -z "$line" || "$line" == \#* ]] && continue

    case "$line" in
        DB_HOST=*) DB_HOST=${line#DB_HOST=} ;;
        DB_PORT=*) DB_PORT=${line#DB_PORT=} ;;
        *) die "Invalid or unsupported configuration entry" ;;
    esac
done < config.env

[[ "$DB_PORT" =~ ^[0-9]+$ ]] || die "DB_PORT must be numeric"

For more complex configuration, use a non-executable format such as JSON and a trusted parser, while still validating allowed keys and value types.

Vulnerability Patterns
  • Data ExfiltrationExternal Transmission, Env Variable Harvesting, File System Enumeration
  • Tool MisuseTool Parameter Abuse, Chaining Abuse, Unsafe Defaults
  • Prompt InjectionInstruction Override, Hidden Instructions, Exfiltration Commands
  • Privilege EscalationExcessive Permissions, Sudo/Root Execution, Credential Access
  • Supply ChainUnpinned Dependencies, External Script Fetching, Obfuscated Code
Findings (5)

Chaining Abuse

High
Category
Tool Misuse
Confidence
75% confidence
Finding

Tool calls are chained to bypass individual safety checks or escalate capabilities beyond what any single tool call would allow.

Content

Scanner excerpt · SKILL.md (reported line 114)May include surrounding context.

md
# Cleanup on exit (any exit: success, failure, or signal)
TMPDIR=""
cleanup() {
    [[ -n "$TMPDIR" ]] && rm -rf "$TMPDIR"
}
trap cleanup EXIT

Chaining Abuse

High
Category
Tool Misuse
Confidence
75% confidence
Finding

Tool calls are chained to bypass individual safety checks or escalate capabilities beyond what any single tool call would allow.

Content

Scanner excerpt · SKILL.md (reported line 229)May include surrounding context.

bash
# Run 4 commands in parallel
cat urls.txt | xargs -P 4 -I {} curl -sO {}

# Process files in parallel (4 at a time)
find . -name "*.csv" | xargs -P 4 -I {} ./process.sh {}

Tool Parameter Abuse

High
Category
Tool Misuse
Confidence
90% confidence
Finding

The example includes a destructive wildcard deletion command, 'rm -rf /tmp/data/*'. In instructional content, such patterns are dangerous because users may adapt them with variable substitution or different paths, and small mistakes can broaden the deletion scope significantly.

Content

Scanner excerpt · SKILL.md (reported line 434)May include surrounding context.

}

confirm "Delete all files in /tmp/data?" || die "Aborted" rm -rf /tmp/data/*

text

### Progress indicator

Tool Parameter Abuse

High
Category
Tool Misuse
Confidence
90% confidence
Finding

The example includes a destructive wildcard deletion command, 'rm -rf /tmp/data/*'. In instructional content, such patterns are dangerous because users may adapt them with variable substitution or different paths, and small mistakes can broaden the deletion scope significantly.

Content

Scanner excerpt · SKILL.md (reported line 434)May include surrounding context.

}

confirm "Delete all files in /tmp/data?" || die "Aborted" rm -rf /tmp/data/*

text

### Progress indicator

External Transmission

Medium
Category
Data Exfiltration
Confidence
50% confidence
Finding

Data is being sent to an external URL. This could be legitimate telemetry or data exfiltration. Manual review is recommended.

Content

Scanner excerpt · SKILL.md (reported line 152)May include surrounding context.

die "Command failed after $max_attempts attempts: $*" }

retry 3 curl -sf https://api.example.com/health

text

## Argument Parsing

Static analysis

No suspicious patterns detected.