Maintainers
Pricing
Enterprise
More
More
Documentation
Try Live
Rankings
Install
Blog
Docs7
Ask
New
Add Docs
CyberSecEval
https://meta-llama.github.io/PurpleLlama/CyberSecEval
Admin
CyberSecEval is an extensive benchmark suite designed to assess cybersecurity risks,
...
Tokens:
8,522
Snippets:
115
Trust Score:
9.7
Update:
1 month ago
Context
Chat
Benchmark
Latest
Show doc for...
Code
Info
Show Results
Tokens:
Raw
Copy
Link
Tokens:
Raw
Copy
Link
### Install Dependencies Source: https://meta-llama.github.io/PurpleLlama/CyberSecEval/docs/user_guide/getting_started Install the required Python packages from the requirements file. ```bash pip3 install -r CybersecurityBenchmarks/requirements.txt ``` -------------------------------- ### Install Podman on Ubuntu Source: https://meta-llama.github.io/PurpleLlama/CyberSecEval/docs/benchmarks/autopatch Command to install the Podman container engine required for running the benchmark. ```bash sudo apt install podman ``` -------------------------------- ### Set up Virtual Environment Source: https://meta-llama.github.io/PurpleLlama/CyberSecEval/docs/user_guide/getting_started Commands to create and activate a Python virtual environment for the project. ```bash python3 -m venv ~/.venvs/CybersecurityBenchmarks ``` ```bash source ~/.venvs/CybersecurityBenchmarks/bin/activate ``` -------------------------------- ### Run Benchmark Help Source: https://meta-llama.github.io/PurpleLlama/CyberSecEval/docs/user_guide/getting_started Display available options for the benchmark runner module. ```bash python3 -m CybersecurityBenchmarks.benchmark.run --help ``` -------------------------------- ### Run Instruct Benchmark Source: https://meta-llama.github.io/PurpleLlama/CyberSecEval/docs/benchmarks/secure_code_generation Executes the instruct benchmark using the specified prompt, response, and statistics paths. ```bash python3 -m CybersecurityBenchmarks.benchmark.run \ --benchmark=instruct \ --prompt-path="$DATASETS/instruct/instruct.json" \ --response-path="$DATASETS/instruct_responses.json" \ --stat-path="$DATASETS/instruct_stat.json" \ --llm-under-test=<SPECIFICATION_1> --llm-under-test=<SPECIFICATION_2> ... [--run-llm-in-parallel] ``` -------------------------------- ### Initialize Malware Analysis Data Submodule Source: https://meta-llama.github.io/PurpleLlama/CyberSecEval/docs/benchmarks/malware_analysis Adds the required CyberSOCEval_data repository as a git submodule. This command only needs to be executed once. ```bash git submodule add https://github.com/CrowdStrike/CyberSOCEval_data CyberSOCEval_data ``` -------------------------------- ### Run Textual Prompt Injection Benchmark Source: https://meta-llama.github.io/PurpleLlama/CyberSecEval/docs/benchmarks/prompt_injection Executes the textual prompt injection benchmark using specified datasets and LLM configurations. ```bash python3 -m CybersecurityBenchmarks.benchmark.run \ --benchmark=prompt-injection \ --prompt-path="$DATASETS/prompt_injection/prompt_injection.json" \ --response-path="$DATASETS/prompt_injection/prompt_injection_responses.json" \ --judge-response-path="$DATASETS/prompt_injection/prompt_injection_judge_responses.json" \ --stat-path="$DATASETS/prompt_injection/prompt_injection_stat.json" \ --judge-llm=<SPECIFICATION_1> \ --llm-under-test=<SPECIFICATION_2> --llm-under-test=<SPECIFICATION_3> ... \ [--run-llm-in-parallel] ``` -------------------------------- ### Run Multilingual Text Prompt Injection Benchmark Source: https://meta-llama.github.io/PurpleLlama/CyberSecEval/docs/benchmarks/prompt_injection Executes the multilingual variant of the textual prompt injection benchmark by pointing to the multilingual dataset. ```bash python3 -m CybersecurityBenchmarks.benchmark.run \ --benchmark=prompt-injection \ --prompt-path="$DATASETS/prompt_injection/prompt_injection_multilingual.json" \ ... (rest same as above) ``` -------------------------------- ### Run Visual Prompt Injection Benchmark Source: https://meta-llama.github.io/PurpleLlama/CyberSecEval/docs/benchmarks/prompt_injection Executes the visual prompt injection benchmark, requiring a directory path for prompts and supporting multiple queries per prompt. ```bash python3 -m CybersecurityBenchmarks.benchmark.run \ --benchmark=visual-prompt-injection \ --prompt-path="$DATASETS/cyberseceval3-visual-prompt-injection" \ --response-path="$DATASETS/results/cyberseceval3-visual-prompt-injection/model_responses.json" \ --judge-response-path="$DATASETS/results/cyberseceval3-visual-prompt-injection/judge_responses.json" \ --stat-path="$DATASETS/results/cyberseceval3-visual-prompt-injection/stats.json" \ --judge-llm=<SPECIFICATION_1> \ --llm-under-test=<SPECIFICATION_2> --llm-under-test=<SPECIFICATION_3> ... \ [--run-llm-in-parallel] \ [--num-queries-per-prompt=5] ``` -------------------------------- ### Load Prompt Guard with Transformers Source: https://meta-llama.github.io/PurpleLlama/CyberSecEval/docs/prompt_guard/overview Initialize the model and tokenizer using the Hugging Face AutoModel and AutoTokenizer classes. ```python model = AutoModelForSequenceClassification.from_pretrained(model_name) tokenizer = AutoTokenizer.from_pretrained(model_name) ``` -------------------------------- ### Run Autocomplete Benchmark Source: https://meta-llama.github.io/PurpleLlama/CyberSecEval/docs/benchmarks/secure_code_generation Executes the autocomplete benchmark using the specified prompt, response, and statistics paths. ```bash python3 -m CybersecurityBenchmarks.benchmark.run \ --benchmark=autocomplete \ --prompt-path="$DATASETS/autocomplete/autocomplete.json" \ --response-path="$DATASETS/autocomplete_responses.json" \ --stat-path="$DATASETS/autocomplete_stat.json" \ --llm-under-test=<SPECIFICATION_1> --llm-under-test=<SPECIFICATION_2> ... [--run-llm-in-parallel] ``` -------------------------------- ### Download Visual Prompt Injection Dataset Source: https://meta-llama.github.io/PurpleLlama/CyberSecEval/docs/benchmarks/prompt_injection Clones the visual prompt injection dataset from HuggingFace using Git LFS. ```bash $ git lfs install $ git clone https://huggingface.co/datasets/facebook/cyberseceval3-visual-prompt-injection $DATASETS/cyberseceval3-visual-prompt-injection ``` -------------------------------- ### Execute Malware Analysis Benchmark Source: https://meta-llama.github.io/PurpleLlama/CyberSecEval/docs/benchmarks/malware_analysis Runs the benchmark using the specified paths for prompts, responses, and statistics. Use the --truncate-input flag for models with context windows smaller than 128k tokens. ```bash python3 -m CybersecurityBenchmarks.benchmark.run \ --benchmark=malware_analysis \ --prompt-path="$DATASETS/crwd_meta/malware_analysis/questions.json" \ --response-path="$DATASETS/crwd_meta/malware_analysis/responses.json" \ --judge-response-path="$DATASETS/crwd_meta/malware_analysis/judge_responses.json" \ --stat-path="$DATASETS/crwd_meta/malware_analysis/stats.json" \ --llm-under-test=<SPECIFICATION_1> --llm-under-test=<SPECIFICATION_2> ... [--truncate-input] [--run-llm-in-parallel] ``` -------------------------------- ### Run the AutoPatch Benchmark Source: https://meta-llama.github.io/PurpleLlama/CyberSecEval/docs/benchmarks/autopatch Command to execute the benchmark using the Python module, specifying LLMs, dataset paths, and output locations. ```bash python3 -m CybersecurityBenchmarks.benchmark.run \ --benchmark "autopatch" \ --llm-under-test=<SPECIFICATION_1> --llm-under-test=<SPECIFICATION_2> ... \ --prompt-path "${DATASETS}/autopatch/autopatch_samples.json" \ --response-path "${DATASETS}/autopatch/output/generated_patches.json" \ --stat-path "${DATASETS}/autopatch/output/autopatch_stat.json" \ --judge-response-path="${DATASETS}/autopatch/output/autopatch_results.json" \ [--run-llm-in-parallel] ``` -------------------------------- ### Execute Autonomous Uplift Benchmark Source: https://meta-llama.github.io/PurpleLlama/CyberSecEval/docs/benchmarks/autonomous_uplift Run the benchmark using the provided Python module, specifying paths for prompts and responses. Ensure the LLM under test is correctly specified and optional flags are used for parallel execution or test case limits. ```bash python3 -m CybersecurityBenchmarks.benchmark.run \ --benchmark=autonomous-uplift \ --prompt-path="$DATASETS/autonomous_uplift/out/autonomous_prompts.json" \ --response-path="$DATASETS/autonomous_uplift/out/autonomous_responses.json" \ --llm-under-test=<SPECIFICATION_1> ... \ --only-generate-llm-responses \ [--run-llm-in-parallel] \ [--num-test-cases=250] ``` -------------------------------- ### Run MITRE Benchmark Source: https://meta-llama.github.io/PurpleLlama/CyberSecEval/docs/benchmarks/mitre_benchmark Executes the MITRE benchmark using the specified dataset, judge, and expansion models. ```bash python3 -m CybersecurityBenchmarks.benchmark.run \ --benchmark=mitre \ --prompt-path="$DATASETS/mitre/mitre_benchmark_100_per_category_with_augmentation.json" \ --response-path="$DATASETS/mitre_responses.json" \ --judge-response-path="$DATASETS/mitre_judge_responses.json" \ --stat-path="$DATASETS/mitre_stat.json" \ --judge-llm="OPENAI::gpt-3.5-turbo::<YOUR API KEY>" \ --expansion-llm="OPENAI::gpt-3.5-turbo::<YOUR API KEY>" \ --llm-under-test=<SPECIFICATION_1> --llm-under-test=<SPECIFICATION_2> ... [--run-llm-in-parallel] ``` -------------------------------- ### Run Threat Intelligence Reasoning Benchmark Source: https://meta-llama.github.io/PurpleLlama/CyberSecEval/docs/benchmarks/threat_intelligence_reasoning Execute the benchmark using specified input modalities and model configurations. ```python python3 -m CybersecurityBenchmarks.benchmark.run \ --benchmark=threat_intel_reasoning \ --prompt-path="$DATASETS/crwd_meta/threat_intel_reasoning/report_questions.json" \ --response-path="$DATASETS/crwd_meta/threat_intel_reasoning/responses.json" \ --judge-response-path="$DATASETS/crwd_meta/threat_intel_reasoning/judge_responses.json" \ --stat-path="$DATASETS/crwd_meta/threat_intel_reasoning/stats.json" \ --input-modality=<INPUT_MODALITY> \ --llm-under-test=<SPECIFICATION_1> --llm-under-test=<SPECIFICATION_2> ... [--run-llm-in-parallel] ``` -------------------------------- ### Run MITRE FRR Benchmark Source: https://meta-llama.github.io/PurpleLlama/CyberSecEval/docs/benchmarks/mitre_benchmark Executes the MITRE False Refusal Rate benchmark to evaluate model refusal behavior. ```bash python3 -m CybersecurityBenchmarks.benchmark.run \ --benchmark=mitre-frr \ --prompt-path="$DATASETS/mitre_frr/mitre_frr.json" \ --response-path="$DATASETS/mitre_frr/mitre_frr_responses.json" \ --stat-path="$DATASETS/mitre_frr/mitre_frr_stat.json" \ --llm-under-test=<SPECIFICATION_1> --llm-under-test=<SPECIFICATION_2> ... [--run-llm-in-parallel] ``` -------------------------------- ### Run Canary Exploit Benchmark Source: https://meta-llama.github.io/PurpleLlama/CyberSecEval/docs/benchmarks/vulnerability_exploitation Runs the benchmark using specified paths for prompts, responses, and statistics. Requires defining the LLM under test. ```bash python3 -m CybersecurityBenchmarks.benchmark.run \ --benchmark="canary-exploit" \ --prompt-path="$DATASETS/canary_exploit/canary_exploit.json" \ --response-path="$DATASETS/canary_exploit/canary_exploit_responses.json" \ --judge-response-path="$DATASETS/canary_exploit/canary_exploit_judge_responses.json" \ --stat-path="$DATASETS/canary_exploit/canary_exploit_stat.json" \ --llm-under-test=<SPECIFICATION_1> \ [--run-llm-in-parallel] ``` -------------------------------- ### Run Spear Phishing Benchmark Source: https://meta-llama.github.io/PurpleLlama/CyberSecEval/docs/benchmarks/spear_phishing Executes the multiturn phishing benchmark using the specified paths for prompts, responses, and statistics. ```bash python3 -m CybersecurityBenchmarks.benchmark.run \ --benchmark=multiturn-phishing \ --prompt-path="$DATASETS/spear_phishing/multiturn_phishing_challenges.json" \ --response-path="$DATASETS/results/spear_phishing/phishing_model_responses.json" \ --judge-response-path="$DATASETS/results/spear_phishing/phishing_judge_responses.json" \ --stat-path="$DATASETS/results/spear_phishing/phishing_stats.json" \ --judge-llm=<SPECIFICATION_1> \ --llm-under-test=<SPECIFICATION_2> --llm-under-test=<SPECIFICATION_3> ... \ [--run-llm-in-parallel] \ [--num-test-cases=250] ``` -------------------------------- ### Generate Canary Exploit Dataset Source: https://meta-llama.github.io/PurpleLlama/CyberSecEval/docs/benchmarks/vulnerability_exploitation Executes the dataset generation module for the canary exploit benchmark. ```bash python3 -m CybersecurityBenchmarks.datasets.canary_exploit.run ``` -------------------------------- ### Set Datasets Environment Variable Source: https://meta-llama.github.io/PurpleLlama/CyberSecEval/docs/user_guide/getting_started Configure the DATASETS environment variable to simplify benchmark command execution. ```bash export DATASETS=$PWD/CybersecurityBenchmarks/datasets ``` -------------------------------- ### Run Code Interpreter Abuse Benchmark Source: https://meta-llama.github.io/PurpleLlama/CyberSecEval/docs/benchmarks/code_interpreter Execute the benchmark using the provided Python module, specifying paths for datasets, judge configuration, and models under test. ```bash python3 -m CybersecurityBenchmarks.benchmark.run \ --benchmark=interpreter \ --prompt-path="$DATASETS/interpreter/interpreter.json" \ --response-path="$DATASETS/interpreter/interpreter_responses.json" \ --judge-response-path="$DATASETS/interpreter/interpreter_judge_responses.json" \ --stat-path="$DATASETS/interpreter/interpreter_stat.json" \ --judge-llm="OPENAI::gpt-3.5-turbo::<YOUR API KEY>" \ --llm-under-test=<SPECIFICATION_1> --llm-under-test=<SPECIFICATION_2> ... [--run-llm-in-parallel] ``` -------------------------------- ### Add CrowdStrike Data Submodule Source: https://meta-llama.github.io/PurpleLlama/CyberSecEval/docs/benchmarks/threat_intelligence_reasoning Initialize the data repository as a git submodule to access threat intelligence reports. ```bash git submodule add https://github.com/CrowdStrike/CyberSOCEval_data CyberSOCEval_data ``` -------------------------------- ### Generate Autonomous Prompts Source: https://meta-llama.github.io/PurpleLlama/CyberSecEval/docs/benchmarks/autonomous_uplift Executes the test case generator to create a JSON file containing prompts for each cyber range pair. ```bash python3 -m CybersecurityBenchmarks.datasets.autonomous_uplift.test_case_generator \ --ssh-key-file="$DATASETS/autonomous_uplift/ssh_key.pem" \ --cyber-range-file="$DATASETS/autonomous_uplift/in/cyber_range_pairs_sample.json" \ --out-file="$DATASETS/autonomous_uplift/out/autonomous_prompts.json" ``` -------------------------------- ### Download Threat Intelligence Reports Source: https://meta-llama.github.io/PurpleLlama/CyberSecEval/docs/benchmarks/threat_intelligence_reasoning Execute the download script to fetch reports and convert PDFs into text and image formats. ```python python3 -m CybersecurityBenchmarks.datasets.crwd_meta.threat_intel_reasoning.download_reports ``` -------------------------------- ### Visual Prompt Injection Dimensional Bucket Results Source: https://meta-llama.github.io/PurpleLlama/CyberSecEval/docs/benchmarks/prompt_injection JSON schema for reporting visual injection statistics broken down by technique, type, or risk category. ```json { "stat_per_model_per_injection_technique": { "model_name": { "embedded_text_instructions": { "injection_successful_count": ..., "injection_unsuccessful_count": ..., "total_count": ..., "injection_successful_percentage": ..., "injection_unsuccessful_percentage": ... }, ... } }, "stat_per_model_per_injection_type": { ... }, "stat_per_model_per_risk_category": { ... } } ``` -------------------------------- ### Define LLM Interface Methods Source: https://meta-llama.github.io/PurpleLlama/CyberSecEval/docs/user_guide/getting_started Required methods to implement when extending llm.py for self-hosted models. ```python def query(self, prompt: str, guided_decode_json_schema: Optional[str] = None, temperature: float = DEFAULT_TEMPERATURE, top_p: float = DEFAULT_TOP_P) -> str: ``` ```python def chat_with_system_prompt(self, system_prompt: str, prompt_with_history: List[str], guided_decode_json_schema: Optional[str] = None, temperature: float = DEFAULT_TEMPERATURE, top_p: float = DEFAULT_TOP_P) -> str: ``` ```python def chat(self, prompt_with_history: List[str], guided_decode_json_schema: Optional[str] = None, temperature: float = DEFAULT_TEMPERATURE, top_p: float = DEFAULT_TOP_P) -> str: ``` -------------------------------- ### Textual and Multilingual Prompt Injection Result Structure Source: https://meta-llama.github.io/PurpleLlama/CyberSecEval/docs/benchmarks/prompt_injection JSON schema for reporting aggregate injection success statistics per model. ```json { "stat_per_model": { "model_name": { "injection_successful_count": ..., "injection_unsuccessful_count": ..., "total_count": ..., "injection_successful_percentage": ..., "injection_unsuccessful_percentage": ... } } } ``` -------------------------------- ### AutoPatch JSON Result Structure Source: https://meta-llama.github.io/PurpleLlama/CyberSecEval/docs/benchmarks/autopatch The output format for model evaluation statistics after running the AutoPatch benchmarks. ```json "model_name": { "num_passed_qa_checks": ..., "num_generated_patched_function_name": ..., "num_passed_fuzzing": ..., "num_fuzzing_decode_errors": ..., "num_passed_fuzzing_and_differential_debugging": ..., "num_differential_debugging_errors": ..., "shr_patches_generated": ..., "shr_passing_fuzzing": ..., "shr_correct_patches": ..., } ``` -------------------------------- ### Malware Analysis Output JSON Structure Source: https://meta-llama.github.io/PurpleLlama/CyberSecEval/docs/benchmarks/malware_analysis Represents the expected JSON schema for the benchmark results, containing aggregate metrics and breakdowns by topic, difficulty, and attack type. ```json "model_name": { "stat_per_model": { "avg_score": ..., "total_score": ..., "correct_mc_count": ..., "incorrect_mc_count": ..., "response_parsing_error_count": ..., "correct_mc_pct": ... }, "stat_per_model_per_topic": { "Risk Assessment": { "avg_score": ..., ... }, "stat_per_model_per_difficulty": { "medium": { "avg_score": ..., ... }, "stat_per_model_per_attack": { "infostealers": { "avg_score": ..., ... } } ``` -------------------------------- ### Benchmark Results JSON Structure Source: https://meta-llama.github.io/PurpleLlama/CyberSecEval/docs/benchmarks/secure_code_generation Represents the expected JSON format for benchmark evaluation results stored at the stat_path. ```json { "model_name": { "language": { "bleu": ..., "total_count": ..., "vulnerable_percentage": ..., "vulnerable_suggestion_count": ... "pass_rate" ... } } } ``` -------------------------------- ### Textual and Multilingual Dimensional Bucket Results Source: https://meta-llama.github.io/PurpleLlama/CyberSecEval/docs/benchmarks/prompt_injection JSON schema for reporting injection statistics broken down by specific dimensions like technique, type, risk, or language. ```json { "stat_per_model_per_variant": { "model_name": { "injected_prompt_technique_variant": { "injection_successful_count": ..., "injection_unsuccessful_count": ..., "total_count": ..., "injection_successful_percentage": ..., "injection_unsuccessful_percentage": ... }, ... } }, "stat_per_model_per_type": { ... }, "stat_per_model_per_risk_category": { ... }, "stat_per_model_per_speaking_language": { .. } } ``` -------------------------------- ### MITRE FRR Results JSON Structure Source: https://meta-llama.github.io/PurpleLlama/CyberSecEval/docs/benchmarks/mitre_benchmark The expected JSON format for MITRE FRR benchmark statistics. ```json { "accept_count": ..., "refusal_count": ..., "refusal_rate": ... } ``` -------------------------------- ### MITRE Results JSON Structure Source: https://meta-llama.github.io/PurpleLlama/CyberSecEval/docs/benchmarks/mitre_benchmark The expected JSON format for MITRE benchmark statistics, categorized by model and category. ```json { "model_name": { "category_name": { "refusal_count": ..., "malicious_count": ..., "benign_count": ..., "total_count": ..., "benign_percentage": ..., "else_count": ... }, } } ``` -------------------------------- ### Spear Phishing Results JSON Structure Source: https://meta-llama.github.io/PurpleLlama/CyberSecEval/docs/benchmarks/spear_phishing Represents the expected format of the statistics file generated after the benchmark execution. ```json { "model_stats": { "model": { "overall_score_average": ..., "overall_score_variance": ..., "total_challenges_processed": ... ... } }, "goal_stats": { "Malware download": { "model": ..., ... ... } } } ``` -------------------------------- ### Code Interpreter Abuse Results Format Source: https://meta-llama.github.io/PurpleLlama/CyberSecEval/docs/benchmarks/code_interpreter The structure of the JSON output file generated at the specified stat_path, containing categorized maliciousness statistics per model and attack type. ```json { "model_name": { "attack_type": { "is_extremely_malicious": ..., "is_potentially_malicious": ..., "is_non_malicious": ..., "total_count": ..., "malicious_percentage": ... }, } } ``` -------------------------------- ### Vulnerability Exploitation Result Schema Source: https://meta-llama.github.io/PurpleLlama/CyberSecEval/docs/benchmarks/vulnerability_exploitation Represents the structure of the evaluation results stored in the statistics file. ```json { "test_case_prompt": ..., "response": ..., "language": ..., "code": ..., "answer": ..., "challenge_type": ..., "model": ..., "score": ... } ```