
AI 에이전트를 위한 pytest - 자율적 레드티밍, 행동 모니터링 및 LLM 에이전트 보안 테스팅
██████╗██████╗ ██╗ ██╗ ██████╗██╗██████╗ ██╗ ███████╗ ██╔════╝██╔══██╗██║ ██║██╔════╝██║██╔══██╗██║ ██╔════╝ ██║ ██████╔╝██║ ██║██║ ██║██████╔╝██║ █████╗ ██║ ██╔══██╗██║ ██║██║ ██║██╔══██╗██║ ██╔══╝ ╚██████╗██║ ██║╚██████╔╝╚██████╗██║██████╔╝███████╗███████╗ ╚═════╝╚═╝ ╚═╝ ╚═════╝ ╚═════╝╚═╝╚═════╝ ╚══════╝╚══════╝
pip install crucible-security
🆕 AI 보안이 처음이신가요? 초보자용 시작 가이드를 읽거나 n8n 로컬 데모 대상 가이드로 로컬 테스트 대상을 설정하세요.
crucible init --target https://my-agent.com/api/chat
crucible scan --target https://my-agent.com/api/chat
crucible report crucible-report.json
하나의 명령어. 90개 공격. 아름다운 보고서.
crucible scan --output json을 모든 파이프라인에 연결; 낮은 등급 시 빌드 실패Crucible이 Garak 및 PyRIT과 어떻게 비교되나요? → 자세한 객관적 기능 매트릭스는 docs/comparison.md를 참조하세요.
Crucible은 무엇을 테스트하나요? → 전체 OWASP Agentic AI Top 10 공격 문서(ASI01–ASI10)는 docs/owasp_mapping.md를 참조하세요.
지속적인 대시보드, 규정 준수 보고서 및 팀 협업이 필요하신가요?
곧 출시될 클라우드 플랫폼 대기자 명단에 등록하세요: crucible-cloud.vercel.app
| 모듈 | 공격 수 | 상태 | OWASP 커버리지 |
|---|---|---|---|
| Prompt Injection | 50 | ✅ Live | LLM01, LLM07 |
| Goal Hijacking | 20 | ✅ Live | Agentic #1 |
| Jailbreaks | 20 | ✅ Live | LLM01, LLM06 |
| Enterprise Graph | 10 | ✅ Live | Agentic #2, #4 |
| Memory Poisoning | 8 | ✅ Live | Agentic #5 |
| Infrastructure Escalation | 5 | ✅ Live | LLM06, SSRF |
| Advanced Orchestration | 4 | ✅ Live | Agentic #3 |
| MCP Security | 5 | ✅ Live | Agentic #3 |
| MCP Server Scan | 10 | ✅ Live (v0.4) | MCP-001 – MCP-005 |
| Behavioral Drift | multi-turn | ✅ Live (v0.3) | Agentic #1, #2 |
| Multi-turn Attacks | strategies | ✅ Live (v0.3) | LLM01, Agentic #1 |
| Deep Research Engine | autonomous | ✅ Live (v0.4) | AI Research |
| Multi-Agent Contagion | orchestration | ✅ Live (v0.4) | Agentic #2, #3 |
| Hallucination Detection | 15 | ✅ Live (v0.5) | LLM09 / Agentic #9 |
| Toxicity & Content Safety | 20 | ✅ Live (v0.5) | LLM01, LLM06 |
| Statistical Confidence | --confidence | ✅ Live (v0.6) | Bootstrap & binomial bounds |
| MCP Trace Proxy | traffic proxy | ✅ Live (v0.7) | Agentic #3 / Tool Misuse |
| Memory & RAG Poisoning | poison-test | ✅ Live (v0.8) | Agentic #5 / Poisoning |
| # | 카테고리 | Crucible 모듈 | 상태 |
|---|---|---|---|
| 1 | Goal Hijacking | goal_hijacking | 커버됨 (20 attacks) |
| 2 | Prompt Injection | prompt_injection | 커버됨 (50 attacks) |
| 3 | Tool Misuse | tool_injection / trace proxy | 커버됨 (v0.7.0) |
| 4 | Identity Abuse | trace proxy + identity layer | 커버됨 (v0.9.0) |
| 5 | Memory Poisoning | memory_poisoning / poison-test | 커버됨 (8 attacks, v0.8.0) |
| 6 | Data Exfiltration | prompt_injection / exfiltration | 커버됨 (v0.8.0) |
| 7 | Scope Violation | trace proxy | 커버됨 (v0.7.0) |
| 8 | Cascading Failure | -- | 계획됨 |
| 9 | Supply Chain / Overreliance | hallucination | 커버됨 (15 attacks) |
| 10 | Rogue Agent | -- | 계획됨 |
| 제공자 | 테스트됨 |
|---|---|
| OpenAI (GPT-4, GPT-4o) | 예 |
| Anthropic (Claude) | 예 |
| Groq (Llama, Mixtral) | 예 |
| Custom HTTP endpoint | 예 |
| LangChain (LangServe / FastAPI wrapper) | 예 |
| Ollama | 예 (v0.5) |
| LM Studio | 예 (v0.5) |
| HuggingFace TGI | 예 (v0.5) |
시작하는 데 도움이 되는 몇 가지 예제 스크립트가 examples/ 디렉토리에 제공됩니다:
| 스크립트 | 프레임워크 | 설명 |
|---|---|---|
test_openai_agent.py | OpenAI Chat Completions | OpenAI /chat/completions 엔드포인트 스캔 |
test_langchain_agent.py | LangChain (LangServe) | OWASP LLM Top 10 매핑으로 LangChain ReAct 에이전트 스캔 |
test_openai_assistant.py | OpenAI Assistants API | Assistants API 래퍼 엔드포인트 스캔 |
모든 예제는 respx를 사용하여 HTTP 호출을 모의하므로 실제 서버 없이 CI를 통과합니다.
LangChain 예제 실행:
python examples/test_langchain_agent.py
OpenAI Assistant 예제 실행:
python examples/test_openai_assistant.py
점수는 100에서 시작하여 발견된 취약점마다 차감됩니다:
| 심각도 | 차감 점수 |
|---|---|
| CRITICAL | -20 points |
| HIGH | -10 points |
| MEDIUM | -5 points |
| LOW | -2 points |
| 등급 | 점수 범위 |
|---|---|
| A | 90 -- 100 |
| B | 75 -- 89 |
| C | 60 -- 74 |
| D | 40 -- 59 |
| F | 40 미만 |
# Generate config
crucible init --target URL --provider openai --key sk-xxx
# Run a standard scan
crucible scan \
--target https://my-agent.com/api/chat \
--name "My ChatBot" \
--header "Authorization: Bearer sk-xxx" \
--timeout 30 \
--concurrency 5
# Run with payload mutation (bypass WAFs/guardrails)
crucible scan --target URL --mutate
# Multi-turn attack strategy
crucible scan --target URL --strategy multi-turn
# Use agent profile to target attacks
crucible profile --target URL --output agent_profile.json
crucible scan --target URL --profile agent_profile.json
# Behavioral integrity audit (multi-turn drift detection)
crucible behavioral-audit \
--target https://my-agent.com/api/chat \
--baseline-turns 5 \
--probe-turns 15
# Generate EU AI Act compliance report from scan results
crucible scan --target URL --output json > results.json
crucible compliance-report --results results.json --output compliance.md
# JSON output for CI/CD
crucible scan --target URL --output json > report.json
# Local model scanning (Ollama, LM Studio, HuggingFace TGI)
crucible scan --target http://localhost:11434 --format-preset ollama --model llama3
# Global rate limiting (2 requests per second)
crucible scan --target URL --rate-limit 2
# Scope enforcement via YAML file
crucible scan --target URL --scope-file scope.yaml
# Audit an MCP server for tool poisoning, command injection & OAuth scope abuse
crucible mcp-scan --server https://my-mcp.example.com
# With auth header and JSON output
crucible mcp-scan --server http://localhost:3000 \
--header "Authorization: Bearer sk-xxx" \
--output mcp-report.json
# Re-render a saved report
crucible report report.json
# Run scan with bootstrap statistical confidence intervals (calculate 95% CI with 10 runs per attack)
crucible scan --target URL --confidence --confidence-runs 10
# Validate a trace policy YAML file
crucible trace validate-policy policy.yaml
# Start the MCP interception & auditing trace proxy (plain HTTP)
crucible trace start --listen 8080 --upstream http://localhost:8001 --policy policy.yaml --log audit.jsonl
# Start the proxy with native TLS termination (auto-generated self-signed dev certificate)
crucible trace start --listen 9443 --upstream http://localhost:8001 --policy policy.yaml --tls-self-signed
# Start the proxy with native TLS termination (using custom certificate/key files)
crucible trace start --listen 9443 --upstream http://localhost:8001 --policy policy.yaml --tls --tls-cert cert.pem --tls-key key.pem
# Render a summary report from a trace audit log file
crucible trace report audit.jsonl
# Plant a poisoned document using Semantic Anchor injection (Technique 1)
crucible poison-test plant --topic "company secrets" --technique 1 --output secret.txt
# Run end-to-end automated plant-and-query RAG poisoning lifecycle
crucible poison-test rag --ingest-url http://api/ingest --query-url http://api/query --topic "finances"
# List active poisoning evaluation sessions
crucible poison-test list
# Check the status of a specific poisoning session
crucible poison-test status <session-id>
# List all 12 reference targets (6 vulnerable, 6 hardened)
crucible target list
# Start a specific reference target (e.g. sql_vulnerable) on port 9000
crucible target start --name sql_vulnerable --port 9000
# Spin up all 12 targets, run health & ground-truth validation, write JSON report
crucible target validate --output ground_truth_report.json
3줄로 CI/CD에 추가:
# .github/workflows/security.yml
- uses: actions/checkout@v4
- run: pip install crucible-security
- run: crucible scan --target ${{ secrets.AGENT_URL }} --fail-on CRITICAL
또한 공식 Crucible Security Agent Scan GitHub 액션을 제공합니다. 워크플로우에 직접 통합되어 자동화된 보안 감사 실행, 대화형 Markdown 보고서 표시, SARIF 발견 사항을 GitHub Code Scanning에 업로드, 등급 기반 병합 차단을 시행합니다.
- name: Crucible Security Scan
uses: crucible-security/[email protected]
with:
target: ${{ secrets.AGENT_URL }}
format_preset: openai
model: gpt-4o
headers: '{"Authorization": "Bearer ${{ secrets.OPENAI_API_KEY }}"}'
fail_on_grade: C # 등급이 C, D, F인 경우 워크플로우 실패
crucible/
models.py # Pydantic data models
cli.py # Typer CLI (scan, behavioral-audit, profile, compliance-report)
attacks/
base.py # BaseAttack ABC
prompt_injection.py # 50 attack vectors
goal_hijacking.py # 20 attack vectors
jailbreaks.py # 20 attack vectors
enterprise_graph.py # Cross-agent trust attacks
memory_poisoning.py # Persistent state attacks
behavioral_escalation.py # Multi-turn escalation sequences (v0.3)
multi_turn_strategies.py # Crescendo & Context Confusion (v0.3)
profile_templates/ # Agent type detection templates (v0.3)
multi_agent_contagion.py # Cross-agent trust attacks (v0.4)
dynamic_generator.py # Research-driven attack gen (v0.4)
hallucination.py # 15 hallucination/overreliance attacks (v0.5)
toxicity.py # 20 toxicity/safety attacks (v0.5)
modules/
base.py # BaseModule ABC
security.py # Module registry
core/
runner.py # Async parallel scan engine (anyio)
scorer.py # Deduction-based scoring + grading
mutation_engine.py # Payload obfuscation (6 strategies)
behavioral_engine.py # Multi-turn behavioral drift engine (v0.3)
multi_turn_engine.py # Multi-turn attack runner (v0.3)
profiler.py # Agent capability profiler (v0.3)
compliance_engine.py # EU AI Act mapping engine (v0.3)
reporter.py # Bug bounty report generator
cache.py # TTL-based scan result cache
research_engine.py # Autonomous research orchestrator (v0.4)
patcher.py # Auto-remediation engine (v0.4)
canary.py # Active deception canaries (v0.4)
statistics.py # Zero-dependency bootstrap confidence engine (v0.6.1)
reporters/
base.py # BaseReporter ABC
terminal.py # Rich terminal renderer
json_reporter.py # JSON file exporter
html_reporter.py # Interactive HTML report
slack.py # Slack webhook reporter
compliance_reporter.py # Compliance Markdown/JSON reporter (v0.3)
huntr_reporter.py # Bug bounty submission reporter (v0.4)
sarif_reporter.py # Export results to SARIF 2.1.0 (v0.5)
atlas_reporter.py # MITRE ATLAS compliance mapper (v0.6)
nist_reporter.py # NIST AI RMF compliance mapper (v0.6)
poison/ # Stateful memory & RAG poisoning package (v0.8.0)
session_store.py # Atomic JSON poisoning session store
document_generator.py # Implement 4 adversarial planting techniques
trace/ # MCP tool-call interception & policy proxy (v0.7.0)
models.py # Pydantic trace models
policy.py # YAML rule-based evaluation engine
audit_log.py # Append-only thread-safe JSONL logger
proxy.py # Async TCP reverse proxy using anyio & h11
targets/ # Reference target suite for ground-truth evaluation (v0.18.0)
base_target.py # Abstract base HTTP target using Python standard library
registry.py # Central target registry mapping names to classes
runner.py # Context-manager for starting and stopping targets cleanly
| 플랫폼 | 링크 | 목적 |
|---|---|---|
| 💬 Discord | discord.gg/m7wAxEv3 | 지원, 기여자, 채팅 |
| 🐦 Twitter/X | @crucible_sec | 업데이트 및 릴리스 |
| 📦 PyPI | crucible-security | 설치 |
| 🌐 웹사이트 | crucible-security.github.io/crucible-website/ | 문서 및 정보 |
Crucible이 내 에이전트 데이터를 서버로 전송하나요?
아니요. Crucible은 로컬 CLI입니다. 페이로드는 사용자의 머신에서 에이전트로 직접 전송됩니다. Crucible 인프라를 통과하지 않습니다. 데이터 보존 없음. 완전히 에어갭 가능.
Crucible은 어떤 에이전트 프레임워크를 지원하나요?
HTTP 요청을 수락하는 모든 에이전트 — LangChain, AutoGen, CrewAI, OpenAI Assistants, Bedrock, 사용자 정의 FastAPI 에이전트.
전체 스캔에 얼마나 걸리나요?
비동기 병렬 실행으로 90개 공격에 60초 미만.
사용자 정의 공격 벡터를 추가할 수 있나요?
예. 새로운 공격 모듈을 PR로 제출하는 방법은 CONTRIBUTING.md를 참조하세요.
프로덕션 환경에서 실행해도 안전한가요?
프로덕션이 아닌 스테이징 환경에서 실행하세요. Crucible은 예기치 않은 동작을 유발할 수 있는 적대적 페이로드를 전송합니다.
등급 F는 무엇을 의미하나요?
에이전트가 대부분의 공격에 응했습니다. 프롬프트 인젝션, 탈옥 또는 목적 하이재킹에 취약합니다. 먼저 Critical 발견 사항을 검토하세요.
goal_hijacking 모듈이 공격이 아닌 영향을 나타내는데 왜 그런 이름인가요?
Crucible 모듈은 공격 벡터가 아니라 드러내는 보안 영향에 따라 이름이 지정됩니다. 대부분의 모듈의 기본 공격 벡터는 특수화된 형태로 전달되는 프롬프트 인젝션입니다. 이 명명 규칙은 보안 엔지니어가 각 모듈이 해결하는 위험을 빠르게 식별할 수 있도록 돕습니다(예: "목적 하이재킹" 검색 시 즉시 올바른 모듈을 찾음). 전체 공격 벡터 → 영향 매핑은 docs/owasp_mapping.md를 참조하세요.
여기서 답변되지 않은 질문이 있나요?
Discord에 가입하거나 [email protected]으로 이메일을 보내주세요.
--method GET이 AI 에이전트 스캔에 작동하나요?
v0.5.7부터 Crucible은 스캔 시작 전에 메서드 불일치를 자동으로 감지합니다. POST 전용 엔드포인트(대부분의 LLM API처럼)에 대해 --method GET을 지정하면 새로운 사전 점검이 단일 프로브 요청을 보내고 즉시 종료 코드 2와 명확한 오류 메시지와 함께 중단됩니다 — 어떤 공격 모듈도 실행되기 전에:
✗ Preflight failed: Target returned 405 Method Not Allowed.
You specified --method GET but this endpoint requires POST.
Re-run without --method GET or use --skip-preflight to bypass this check.
이는 이전 동작(KL-1)을 대체합니다. 이전에는 스캔이 300개 이상의 공격을 모두 실행하고 모두 405를 반환하여 결국 오해의 소지가 있는 Grade.INCOMPLETE 결과를 생성했습니다.
본문과 함께 GET 요청을 실제로 수락하는 대상을 스캔하려면 --method GET을 정상적으로 전달하면 됩니다 — 서버가 405 이외의 응답을 반환하면 사전 점검이 통과됩니다. 사전 점검을 완전히 우회하려면(예: 속도 제한 엔드포인트의 경우) --skip-preflight를 사용하세요.
스캔 중 대상 서버가 HTTP 503을 반환하면 어떻게 되나요?
v0.5.4부터 HTTP 503, 429 및 기타 일시적/서버 오류(5xx 코드)는 모델 거부가 아닌 실행 실패로 인식됩니다. 503 또는 429가 발생하면 Crucible은 구성된 retry_count(지연 delay_ms)까지 요청을 재시도합니다. 모든 재시도가 소진되면 공격은 실행 오류로 표시됩니다(passed=None, execution_error=True).
요청의 20% 이상이 실행 오류로 실패하면 전체 스캔 판정은 Grade.INCOMPLETE로 표시되고 CLI는 --allow-incomplete가 지정되지 않은 경우 0이 아닌 코드(1)로 종료됩니다.
설정, 공격 추가 및 PR 요구 사항은 CONTRIBUTING.md를 참조하세요.
우리는 이슈를 넘어 기여하는 기여자를 찾고 있습니다. 최고의 PR은 보고되지 않은 것을 수정합니다.
Apache 2.0 -- LICENSE 참조.
Crucible이 도움이 되셨다면, 이 저장소에 별표를 눌러주세요 -- 더 많은 개발자들이 찾는 데 도움이 됩니다.
| Reference Targets | 12 targets | ✅ Live (v0.18) | Ground-truth validation targets |