kurtpayne/skillscan-fuzzer

GitHub: kurtpayne/skillscan-fuzzer

基于 LLM 的对抗性 AI 技能文件模糊测试工具,通过语义突变生成变体以压力测试 skillscan 扫描器的检测能力。

Stars: 0 | Forks: 0

# ⚠️ 已停止维护 —— 不再继续维护 # skillscan-fuzzer [![CI](https://static.pigsec.cn/wp-content/uploads/repos/cas/39/39faa54be350a1dab8afd3b2fb8c1c83e4d9cff84abfef2374d19a18053687c4.svg)](https://github.com/kurtpayne/skillscan-fuzzer/actions/workflows/ci.yml) [![PyPI version](https://img.shields.io/pypi/v/skillscan-fuzzer.svg)](https://pypi.org/project/skillscan-fuzzer/) [![Python](https://img.shields.io/pypi/pyversions/skillscan-fuzzer.svg)](https://pypi.org/project/skillscan-fuzzer/) [![License](https://img.shields.io/badge/License-Apache_2.0-blue.svg)](LICENSE) **M19 — 基于 LLM 的对抗性 SKILL.md 变体生成器** `skillscan-fuzzer` 生成 AI 技能文件的对抗性变体,以探测 `skillscan` 的检测边界。它使用兼容 OpenAI 的 LLM API(默认为 GPT-4.1-mini,或任何本地 Ollama 模型)对种子技能文件应用语义突变,生成带有统一 diff 和可选扫描结果的变体。 该 fuzzer 是公开扫描流(M14)的受控输入补充:它不是扫描野外发现的技能,而是生成旨在对扫描器的静态规则和 ML 模型进行压力测试的技能。其输出直接馈送到 `skillscan-trace`(M18)以进行行为验证。 ## 安装 ``` # 从 PyPI pip install skillscan-fuzzer # 或者作为主软件包的额外依赖 pip install skillscan-security[fuzzer] # 从源码安装开发版本 git clone https://github.com/kurtpayne/skillscan-fuzzer cd skillscan-fuzzer pip install -e ".[dev]" ``` ## 快速开始 ``` # 使用 evasion 策略对每个恶意 seed 进行 5 个变体的 Fuzz skillscan-fuzzer --strategy evasion --variants 5 --seed-dir path/to/corpus/adversarial # 使用 injection 策略对特定 seed 进行 Fuzz,并对每个变体运行 skillscan skillscan-fuzzer --strategy injection \ --seed-file path/to/corpus/benign/gh_example.md \ --scan # 使用本地 Ollama 端点(无需 API key) skillscan-fuzzer --strategy obfuscation \ --model llama3.1:8b \ --base-url http://localhost:11434/v1 \ --api-key ollama \ --seed-dir path/to/seeds # Dry run 以验证输出结构,而不进行 LLM 调用 skillscan-fuzzer --strategy evasion --dry-run --variants 2 --seed-dir path/to/seeds ``` 种子文件不包含在内 —— 请使用 [skillscan-corpus](https://github.com/kurtpayne/skillscan-corpus) 或提供您自己的。 ## 突变策略 | 策略 | 种子类型 | 目标 | |---|---|---| | `evasion` | 恶意 | 在改变表面特征以规避规则匹配的同时,保留恶意意图 | | `injection` | 良性 | 向原本干净的 skill 中添加一个微妙的攻击向量 | | `benign_drift` | 良性 | 添加与安全相关的词汇,但不含实际恶意(误报压力测试) | | `obfuscation` | 恶意 | 应用编码/同形字/零宽混淆来隐藏攻击特征 | | `authority` | 任意 | 注入伪造的系统标头、厂商冒充或角色越权声明 | ## 输出结构 ``` fuzz-output/ evasion/ ah01_goal_substitution_calendar/ variant_001.md ← complete mutated SKILL.md variant_001.diff ← unified diff against original variant_001.scan.json ← skillscan SARIF result (if --scan) variant_002.md variant_002.diff ... summary.json ← evasion rate, detection rate, per-seed results ``` `summary.json` 包含: ``` { "strategy": "evasion", "total_seeds": 10, "total_variants": 50, "errors": 0, "scanned": 50, "evasion_rate": 0.34, "false_positive_rate": null, "per_seed": [...] } ``` ## CLI 参考 ``` Usage: skillscan-fuzzer [OPTIONS] Options: -s, --strategy [evasion|injection|benign_drift|obfuscation|authority] Mutation strategy [default: evasion] -n, --variants INTEGER Variants per seed [default: 5] --seed-dir DIRECTORY Directory of seed SKILL.md files --seed-file PATH Specific seed file (repeatable) -o, --output-dir DIRECTORY Output root [default: fuzz-output] -m, --model TEXT LLM model [default: gpt-4.1-mini] --base-url TEXT OpenAI-compatible API base URL --api-key TEXT API key (reads OPENAI_API_KEY env var) --temperature FLOAT Sampling temperature [default: 0.9] --max-tokens INTEGER Max response tokens [default: 4096] --scan / --no-scan Run skillscan on each variant [default: no-scan] --dry-run Skip LLM calls; write placeholder variants --max-seeds INTEGER Limit number of seeds processed -v, --verbose Enable debug logging -h, --help Show this message and exit ``` ## API Key 配置 fuzzer 按以下优先级顺序读取 `OPENAI_API_KEY`: 1. `--api-key` CLI 标志 2. `OPENAI_API_KEY` 环境变量 3. `~/.skillscan-secrets`(所有 skillscan 工具共享的凭证存储) 对于 Ollama,请使用 `--base-url http://localhost:11434/v1 --api-key ollama`。 ## 语料库集成 生成的变体旨在供人工审查,如果它们代表了真正的规避漏洞或新的攻击模式,则应将其作为带标签的训练样本提交到 `skillscan-corpus`。推荐的工作流程: 1. 使用 `--scan` 运行 fuzzer,以识别能够规避检测的变体。 2. 手动审查规避了检测的变体的质量(攻击意图是否依然存在?)。 3. 将确认的规避变体提交到 `skillscan-corpus/adversarial/`,并标记为 `malicious`。 4. 更新静态规则或重新训练 ML 模型以填补漏洞。 5. 重复上述步骤。 对于行为验证(而非静态规则验证),请使用内置的 pipeline 脚本将变体通过管道输入到 `skillscan-trace`(M18): ``` python scripts/fuzzer_tracer_pipeline.py \ --seeds path/to/skillscan-corpus/adversarial/agent_hijacker \ --dry-run ``` ## 运行测试 ``` pip install -e ".[dev]" pytest tests/ -v ``` 所有测试均使用 `--dry-run` 模式,不需要 API Key 或网络访问。
标签:AI安全, AI风险缓解, Chat Copilot, DLL 劫持, Petitpotam, Python, 域名收集, 大语言模型, 安全规则引擎, 对抗样本生成, 无后门, 逆向工具, 配置审计