Back to skill

Security audit

Shell Script

Security checks for vulnerabilities and agentic risk

Overview

The skill is a shell-script helper, but its generated scripts can make high-impact system/deployment changes and unsafely embed user-provided values into executable Bash.

Review generated scripts carefully before running them, especially with sudo or deployment credentials. Do not pass untrusted or copied values into template parameters, and treat setup/deploy/monitor outputs as privileged operational scripts that may change servers, restart services, or delete/sync files.

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/shell.sh:25
Finding

Command Injection in Generated Shell Scripts Through Unescaped Template Parameters

Content
View full analysis
> /var/log/backup.log 2>&1 set -euo pipefail # ---- 配置 ---- BACKUP_SOURCE="${source}" BACKUP_DEST="${dest}" BACKUP_NAME="${name}" ``` Deployment template generation: ```bash gen_deploy() { local name="${NAME:-myapp}" local remote="${REMOTE:-user@server}" cat <
Remediation
View remediation
Vulnerability Patterns
  • Data ExfiltrationExternal Transmission, Env Variable Harvesting, File System Enumeration
  • Privilege EscalationExcessive Permissions, Sudo/Root Execution, Credential Access
  • Tool MisuseTool Parameter Abuse, Chaining Abuse, Unsafe Defaults
  • YARA SignaturesMalware Match, Webshell Match, Cryptominer Match
  • MCP Tool PoisoningHidden Instructions, Unicode Deception, Parameter Description Injection
Findings (16)

Credential Access

High
Category
Privilege Escalation
Confidence
60% confidence
Finding

Code accesses credential files (SSH keys, AWS credentials, etc.). This could indicate credential theft attempts.

Content

Scanner excerpt · scripts/shell.sh (reported line 185)May include surrounding context.

sh
rsync -avz --delete \
    --exclude='.git' \
    --exclude='node_modules' \
    --exclude='.env' \
    --exclude='__pycache__' \
    --exclude='.venv' \
    ./ "\${DEPLOY_USER}@\${DEPLOY_HOST}:\${DEPLOY_PATH}/" \

Tool Parameter Abuse

High
Category
Tool Misuse
Confidence
100% confidence
Finding

Tool parameters are crafted to achieve unintended or unsafe behavior. Parameter abuse can bypass intended safety checks (e.g. shell=True, --force, dangerous glob patterns).

Content

Scanner excerpt · scripts/shell.sh (reported line 383)May include surrounding context.

sh
fi

    # Check for common issues
    grep -nE 'rm -rf /' "$file" && echo "🚨 危险: 检测到 rm -rf / !" && ((issues++))
    grep -nE 'eval ' "$file" && echo "⚠️  使用了 eval,注意安全风险" && ((issues++))

    # Check executable permission

Tool Parameter Abuse

High
Category
Tool Misuse
Confidence
95% confidence
Finding

Tool parameters are crafted to achieve unintended or unsafe behavior. Parameter abuse can bypass intended safety checks (e.g. shell=True, --force, dangerous glob patterns).

Content

Scanner excerpt · scripts/shell.sh (reported line 383)May include surrounding context.

sh
fi

    # Check for common issues
    grep -nE 'rm -rf /' "$file" && echo "🚨 危险: 检测到 rm -rf / !" && ((issues++))
    grep -nE 'eval ' "$file" && echo "⚠️  使用了 eval,注意安全风险" && ((issues++))

    # Check executable permission

Tool Parameter Abuse

High
Category
Tool Misuse
Confidence
100% confidence
Finding

Tool parameters are crafted to achieve unintended or unsafe behavior. Parameter abuse can bypass intended safety checks (e.g. shell=True, --force, dangerous glob patterns).

Content

Scanner excerpt · scripts/shell.sh (reported line 383)May include surrounding context.

sh
fi

    # Check for common issues
    grep -nE 'rm -rf /' "$file" && echo "🚨 危险: 检测到 rm -rf / !" && ((issues++))
    grep -nE 'eval ' "$file" && echo "⚠️  使用了 eval,注意安全风险" && ((issues++))

    # Check executable permission

Tool Parameter Abuse

High
Category
Tool Misuse
Confidence
100% confidence
Finding

Tool parameters are crafted to achieve unintended or unsafe behavior. Parameter abuse can bypass intended safety checks (e.g. shell=True, --force, dangerous glob patterns).

Content

Scanner excerpt · scripts/shell.sh (reported line 383)May include surrounding context.

sh
fi

    # Check for common issues
    grep -nE 'rm -rf /' "$file" && echo "🚨 危险: 检测到 rm -rf / !" && ((issues++))
    grep -nE 'eval ' "$file" && echo "⚠️  使用了 eval,注意安全风险" && ((issues++))

    # Check executable permission

YARA rule 'agent_skill_destructive_autonomous_actions': Autonomous destructive filesystem, shell history, or repository actions in AI agent skills [agent_skills]

High
Category
YARA Match
Confidence
75% confidence
Finding

YARA rule matched a known malware signature (reverse shell, backdoor, ransomware, C2 framework, or info stealer).

Content

Scanner excerpt · scripts/shell.sh (reported line 383)May include surrounding context.

sh
k unquoted variables
    local unquoted
    unquoted=$(grep -nE '\$[A-Za-z_]+[^"'"'"']' "$file" | grep -v '^#' | head -10 || true)
    if [[ -n "$unquoted" ]]; then
        echo "⚠️  可能有未引号包裹的变量:"
        echo "$unquoted" | head -5 | sed 's/^/   /'
        ((issues++))
    fi

    # Check for common issues
    grep -nE 'rm -rf /' "$file" && echo "🚨 危险: 检测到 rm -rf / !" && ((issues++))
    grep -nE 'eval ' "$file" && echo "⚠️  使用了 eval,注意安全风险" && ((issues++))

    # Check executable permission
    if [[ ! -x "$file" ]]; then
        echo "ℹ️  文件没有执行权限,运行: chmod +x $file"
    fi

    # Try bash syntax check
    if bash -n "$file" 2>/dev/null; then
        echo "✅ 语法检查通过(bash -n)"
    else
        echo "❌ 语法错误:"
        bash -n "$file" 2>&1 | sed 's/^/   /'
        ((issues++))
    fi

    echo ""
    if [[ $issues -eq 0 ]]; then
        echo "✅ 未发现明显问题

Intent-Code Divergence

Medium
Category
Not specified by scanner
Confidence
96% confidence
Finding

The script presents itself as a developer workflow tool with commands like init, check, build, test, and deploy, but the implementation only prints reassuring status messages and logs invocations. In an agent or automation context, this can mislead users or higher-level systems into believing important validation, build, or deployment steps actually occurred, creating a security-relevant integrity gap and enabling skipped checks or unsafe releases.

Content

No source excerpt is available for this finding.

Intent-Code Divergence

Medium
Category
Not specified by scanner
Confidence
82% confidence
Finding

The header frames the skill as a generator/checker, which implies producing or inspecting scripts rather than carrying out administrative changes itself. However, the generated setup template includes commands to upgrade packages, alter firewall rules, modify SSH configuration, and create swap, which is materially stronger operational behavior than the neutral 'checks' wording suggests.

Content

No source excerpt is available for this finding.

External Transmission

Medium
Category
Data Exfiltration
Confidence
70% 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 · scripts/shell.sh (reported line 94)May include surrounding context.

sh
log "📊 当前备份数: \$TOTAL, 总大小: \$TOTAL_SIZE"

# ---- 可选:通知 ----
# curl -s -X POST "https://hooks.slack.com/services/YOUR/WEBHOOK" \\
#   -H 'Content-type: application/json' \\
#   -d "{\"text\": \"✅ 备份完成: \$BACKUP_FILE (\$SIZE)\"}"

External Transmission

Medium
Category
Data Exfiltration
Confidence
70% 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 · scripts/shell.sh (reported line 255)May include surrounding context.

sh
\$RESTART_CMD
    log "🔄 已执行重启命令"
    # 通知(可选)
    # curl -s -X POST "\$ALERT_WEBHOOK" -d "{\"text\": \"⚠️ \$APP_NAME 健康检查失败,已自动重启\"}"
else
    log "✅ 健康检查通过"
fi

Sudo/Root Execution

Medium
Category
Privilege Escalation
Confidence
70% confidence
Finding

Commands invoke sudo or root privileges. Verify this elevated access is necessary and justified.

Content

Scanner excerpt · scripts/shell.sh (reported line 285)May include surrounding context.

sh
NC='\033[0m'

log() { echo -e "${GREEN}[设置]${NC} $*"; }
need_root() { [[ $EUID -eq 0 ]] || { echo "请用 sudo 运行"; exit 1; }; }

need_root

Sudo/Root Execution

Medium
Category
Privilege Escalation
Confidence
80% confidence
Finding

Commands invoke sudo or root privileges. Verify this elevated access is necessary and justified.

Content

Scanner excerpt · scripts/shell.sh (reported line 326)May include surrounding context.

sh
log "创建交换空间 (2GB)..."
if [[ ! -f /swapfile ]]; then
    fallocate -l 2G /swapfile
    chmod 600 /swapfile
    mkswap /swapfile
    swapon /swapfile
    echo '/swapfile none swap sw 0 0' >> /etc/fstab

Natural-Language Policy Violations

Medium
Category
Not specified by scanner
Confidence
95% confidence
Finding

The setup template hard-codes timedatectl set-timezone Asia/Shanghai, which imposes a specific locale-related configuration on any server where the generated script is run. This is a natural-language/policy concern because the skill does not offer an alternative, prompt the user, or document that it is intended only for a China-specific deployment context.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Low
Category
Not specified by scanner
Confidence
93% confidence
Finding

The manifest description presents the skill in both Chinese and English, and the body repeats the same mixed-language presentation. This can violate a language/locale policy when the skill forces a specific language experience without explicitly letting the user choose their preferred language.

Content

No source excerpt is available for this finding.

Intent-Code Divergence

Low
Category
Not specified by scanner
Confidence
95% confidence
Finding

The comment labels the output as a 'service monitoring script', which suggests observation and logging. In practice, the script not only checks health but also executes a restart command automatically when the HTTP check fails, so the documentation understates that it is a remediation script as well as a monitor.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Low
Category
Not specified by scanner
Confidence
95% confidence
Finding

The markdown content is presented in Chinese ("Bash最佳实践") with no indication that the user can choose another language or that the skill is intentionally limited to a Chinese-speaking audience. This is a natural-language policy concern because it imposes a specific language without opt-in or justification.

Content

No source excerpt is available for this finding.

Static analysis

No suspicious patterns detected.