BarakMozesPro/secureflow-benchmark
GitHub: BarakMozesPro/secureflow-benchmark
模块化的 LLM 安全评估框架,通过攻击探测和安全检测器系统性发现语言模型部署中的安全漏洞。
Stars: 0 | Forks: 0
# SecureFlow Benchmark — LLM 安全评估与红队测试框架



SecureFlow Benchmark 是一个模块化的 LLM 安全评估框架,专为语言模型红队测试而构建。它利用基于插件的攻击探测、提示词转换增强和自动化安全检测器,系统性地发现 LLM 部署中的漏洞。
## 架构
```
graph LR
A[Attack Probes] --> B[Prompt Buffs]
B --> C[LLM Generator]
C --> D[Response]
D --> E[Safety Detectors]
E --> F[Evaluator]
F --> G[Safety Report]
```
## 功能特性
- **基于插件的架构**,包含 4 个扩展点:探测、生成器、检测器和增强
- 用于越狱(DAN、TAP)、编码攻击和提示词注入的**攻击探测**
- 适用于 OpenAI、HuggingFace 和 REST API 的 **LLM 后端**
- 用于内容分析和包幻觉检测的**安全检测器**
- 具有结构化尝试数据模型的**可配置评估框架**
- **报告生成**和分析可视化
## 快速开始
```
pip install secureflow-benchmark
```
## 使用说明
```
import secureflow_benchmark
from secureflow_benchmark.probes import dan
from secureflow_benchmark.generators import openai as openai_gen
from secureflow_benchmark.evaluators import base as base_eval
# 设置 generator
generator = openai_gen.OpenAIGenerator(name="gpt-4o")
# 运行 DAN jailbreak probes
probe = dan.Dan_11_0()
attempts = probe.probe(generator)
# 评估结果
evaluator = base_eval.Evaluator()
results = evaluator.evaluate(attempts)
print(f"Pass rate: {results.pass_rate:.2%}")
```
## 项目结构
```
secureflow_benchmark/
├── __init__.py # Package init and version
├── _config.py # Configuration management
├── _plugins.py # Plugin discovery system
├── configurable.py # Base configurable class
├── attempt.py # Attempt data model
├── cli.py # Command-line interface
├── command.py # Run orchestration commands
├── report.py # Report generation
├── payloads.py # Payload management
├── probes/ # Attack probes
│ ├── base.py # Base probe class
│ ├── dan.py # DAN jailbreak probes
│ ├── tap.py # TAP jailbreak probes
│ ├── encoding.py # Encoding attack probes
│ ├── latentinjection.py # Latent injection probes
│ ├── promptinject.py # Prompt injection probes
│ ├── continuation.py # Continuation probes
│ ├── grandma.py # Grandma exploit probes
│ └── lmrc.py # LMRC benchmark probes
├── generators/ # LLM backends
│ ├── base.py # Base generator class
│ ├── openai.py # OpenAI API backend
│ ├── huggingface.py # HuggingFace backend
│ └── rest.py # Generic REST API backend
├── detectors/ # Safety detectors
│ ├── base.py # Base detector class
│ ├── unsafe_content.py # Unsafe content detection
│ ├── packagehallucination.py # Package hallucination
│ ├── mitigation.py # Mitigation detection
│ └── always.py # Always-pass/fail detectors
├── buffs/ # Prompt transformations
│ ├── base.py # Base buff class
│ ├── encoding.py # Encoding transformations
│ ├── lowercase.py # Lowercase transformation
│ ├── paraphrase.py # Paraphrase transformation
│ └── low_resource_languages.py # Language transforms
├── harnesses/ # Evaluation harnesses
├── evaluators/ # Result evaluators
└── analyze/ # Report analysis tools
```
## 我的收获
构建该框架加深了我对 **LLM 红队测试方法论**的理解——特别是越狱攻击的分类(DAN 提示词、基于编码的绕过、潜在注入)、自动化安全基准测试流水线的工作原理,以及使此类系统能够跨不同模型后端和攻击策略进行扩展所需的设计模式。
## 致谢
基于 NVIDIA 的 **[garak](https://github.com/NVIDIA/garak)** 构建(Apache 2.0 许可证)。SecureFlow Benchmark 是 garak 的一个专注子集和分支,适配于基准测试和教育用途。
## 许可证
[Apache 2.0](LICENSE) — 详见 LICENSE。
标签:AI安全, Chat Copilot, DAN, LLM安全评估, Petitpotam, 内容安全检测, 域名收集, 大语言模型安全, 安全基准测试, 机密管理, 生成式AI安全, 自动化攻击框架, 自动化红队, 虚拟机, 误配置预防