Back to skill

Security audit

apollo-evolution

Security checks for vulnerabilities and agentic risk

Overview

This skill is purpose-aligned, but its evolution script has unsafe input handling that can write outside intended paths and can execute commands from a crafted selection value.

Review this skill carefully before installing. Only run the evolution script manually in a disposable or version-controlled workspace, do not pass untrusted skill names or selection input, and treat its scores as mock output until real validation and input checks are added.

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/apollo-evolution/evolution.sh:41
Finding

Path Traversal Through Unvalidated Skill Names

Content
View full analysis

Vulnerability Details

File Location: scripts/apollo-evolution/evolution.sh, lines 41-59
Vulnerability Type: Path traversal leading to filesystem access outside intended directories
Risk Level: High

Vulnerable Code

bash
cmd_copy() {
    local skill_name="$1"
    local target_dir="${MEMORY_DIR}/${skill_name}"
    
    if [ -z "$skill_name" ]; then
        echo "用法: evolution.sh copy <skill_name>"
        exit 1
    fi
    
    local source_dir="${SKILLS_DIR}/${skill_name}"
    if [ ! -d "$source_dir" ]; then
        log_error "Skill不存在: ${skill_name}"
        exit 1
    fi
    
    # 创建进化目录
    mkdir -p "${target_dir}/variants"
    
    # 复制原始版本为第0代
    local gen0_dir="${target_dir}/variants/gen-000"
    cp -r "$source_dir" "$gen0_dir"

The same unsafe path construction is subsequently used by other commands, including mutate, select, and status.

Technical Analysis

The user-controlled skill_name argument is concatenated directly with SKILLS_DIR and MEMORY_DIR without validation or canonical containment checks:

bash
local target_dir="${MEMORY_DIR}/${skill_name}"
local source_dir="${SKILLS_DIR}/${skill_name}"

Quoting these variables prevents shell word splitting and shell metacharacter injection, but it does not prevent filesystem path traversal. A name containing absolute-path-like or parent-directory components such as ../ can resolve outside the intended skill or evolution-state directory.

The resulting paths are passed to filesystem-modifying operations such as mkdir -p, cp -r, sed -i, and redirection into generations.json. In the mutate command, the traversed target must have the expected variants/gen-* structure, but an attacker able to prepare or identify such a structure can cause SKILL.md beneath it to be modified.

Attack Path

  1. The attacker identifies or prepares a directory accessible to the acc ...[truncated 1516 chars]
Remediation
View remediation

Remediation Suggestions

  1. Restrict skill names to a conservative allowlist:

    bash
    validate_skill_name() {
        local name="$1"
        [[ "$name" =~ ^[A-Za-z0-9][A-Za-z0-9._-]*$ ]] || {
            log_error "Invalid skill name"
            exit 1
        }
    }
    
  2. Explicitly reject absolute paths, path separators, empty values, . and ...

  3. Canonicalize source and destination paths before use and verify containment:

    bash
    source_dir="$(realpath -e -- "${SKILLS_DIR}/${skill_name}")"
    [[ "$source_dir" == "${SKILLS_DIR}/"* ]] || {
        log_error "Skill path escapes the skills directory"
        exit 1
    }
    
  4. For paths that do not exist yet, canonicalize and verify their existing parent directory before creating them.

  5. Apply the same validation centrally before dispatching copy, mutate, test, select, and status.

  6. Run the script under a minimally privileged account with write access limited to the intended evolution-state directory.

T09 · Insecure Skill Coding Practices

Error
Location
scripts/apollo-evolution/evolution.sh:218
Finding

Arbitrary Command Execution Through sed Program Injection

Content
View full analysis

Vulnerability Details

File Location: scripts/apollo-evolution/evolution.sh, lines 218-220
Vulnerability Type: Command injection through an attacker-controlled GNU sed program
Risk Level: Critical

Vulnerable Code

bash
read -p "选择要保留的版本编号: " choice

local selected_gen=$(ls -d "${target_dir}"/variants/gen-* | sort | sed -n "${choice}p")

Technical Analysis

The interactive choice value is inserted directly into the program passed to sed:

bash
sed -n "${choice}p"

The code assumes that choice is a positive integer, but it performs no syntax or range validation. Consequently, the user can provide an entire sed expression rather than only a line number.

GNU sed supports the e command, which executes a shell command. A crafted input can terminate or extend the expected address expression and introduce an e command. The script then executes that command with the privileges of the account running evolution.sh.

This is code injection into sed rather than ordinary shell interpolation: shell quoting around "${choice}p" does not make the sed program safe because sed itself interprets the attacker-controlled value as executable syntax.

Attack Path

  1. The attacker ensures that an evolution record exists for a chosen skill so that cmd_select reaches the interactive prompt.

  2. The attacker runs:

    bash
    bash evolution.sh select skill-name
    
  3. At the selection prompt, the attacker enters a GNU sed expression using the e command, for example:

    text
    1e touch /tmp/apollo-evolution-pwned #
    
  4. The script constructs a sed program equivalent to:

    bash
    sed -n '1e touch /tmp/apollo-evolution-pwned #p'
    
  5. On GNU sed, the injected e command invokes a shell and executes the supplied command.

  6. The attacker can replace the proof-of-concept touch command with another command available to the script's user.

...[truncated 864 chars]

Remediation
View remediation

Remediation Suggestions

  1. Require choice to be a positive decimal integer:

    bash
    if [[ ! "$choice" =~ ^[1-9][0-9]*$ ]]; then
        log_error "Selection must be a positive integer"
        exit 1
    fi
    
  2. Avoid constructing a sed program from user input. Store generation paths in a Bash array and index it safely:

    bash
    mapfile -t generations < <(printf '%s\n' "${target_dir}"/variants/gen-* | sort)
    
    if (( choice < 1 || choice > ${#generations[@]} )); then
        log_error "Selection is out of range"
        exit 1
    fi
    
    selected_gen="${generations[choice - 1]}"
    
  3. Verify that the selected path is a directory and remains under ${target_dir}/variants.

  4. Remove reliance on parsing ls output, because filenames and error output can produce unsafe or incorrect selection behavior.

  5. Run the script with least privilege so that any future injection flaw has a restricted filesystem and process scope.

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

Natural-Language Policy Violations

Medium
Category
Not specified by scanner
Confidence
91% confidence
Finding

The skill description and all user-facing documentation in this file are written in Chinese, with no indication that language selection is optional or that the skill is intentionally limited to Chinese-speaking users. Under the stated policy, forcing a specific language without user opt-in is a natural-language policy violation.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Medium
Category
Not specified by scanner
Confidence
95% confidence
Finding

The script’s comments, help text, prompts, and status messages are written in Chinese throughout, including usage guidance and interactive prompts. Under the policy rule, forcing a specific language without user opt-in is a natural-language policy violation, and this file does not offer any locale selection or explain a region-specific requirement.

Content

No source excerpt is available for this finding.

Intent-Code Divergence

Medium
Category
Not specified by scanner
Confidence
97% confidence
Finding

The test command claims to evaluate variants but only assigns random scores, creating a deceptive safety and quality signal. In a self-evolution workflow, this can cause operators or downstream automation to promote untested or degraded skill variants, including variants that introduce insecure behavior.

Content

No source excerpt is available for this finding.

Intent-Code Divergence

Medium
Category
Not specified by scanner
Confidence
96% confidence
Finding

The select command presents random scores and manual selection while implying it is choosing the best version, but it ignores actual test evidence. This breaks the trust model of the evolution pipeline and can lead to arbitrary promotion of unsafe or nonfunctional variants, which is especially risky in a tool designed to modify skills over generations.

Content

No source excerpt is available for this finding.

Missing User Warnings

Low
Category
Not specified by scanner
Confidence
86% confidence
Finding

The skill explicitly instructs users to run copy/mutate/select scripts and documents writes under .memory/evolution/{skill_name}/, but it does not warn that these operations modify the workspace or encourage review/confirmation before making changes. In an agent context, undocumented file creation and modification increases the risk of unintended state changes, accidental overwrites, or surprise persistence across runs.

Content

No source excerpt is available for this finding.