AppSecBench — Benchmark Methodology
1. Objective
Produce an original, reproducible, broadly-covered benchmark that measures whether an LLM or security tool can detect, classify, explain, score, and remediate application-security weaknesses across languages, frameworks, and difficulty levels.
2. Design Principles
- Originality. No record is copied from another dataset or from proprietary source. Each vulnerable/secure pair is authored from scratch, inspired by public secure-coding knowledge (OWASP Top 10 2021, OWASP API Security Top 10 2023, OWASP LLM Top 10 2025, CWE, ASVS).
- Realism over trivia. Every snippet reflects a realistic, idiomatic anti-pattern and its idiomatic fix for the target language/framework — not a toy example.
- Reproducibility. Generation is deterministic (
seed=42).scripts/build.pyyields byte-identical records on re-run. - Gradability. Each record ships the "ground truth" a grader needs: CWE, OWASP (and API/LLM mappings where relevant), expected severity, a CVSS 3.1 vector + computed base score, an explanation, a fix description, secure code, and false-positive / false-negative priors.
3. Construction Pipeline
- Catalog (
vuln_catalog.py): 34 vulnerability archetypes × canonical CWE, OWASP 2021, OWASP API 2023, OWASP LLM 2025, category, and public references. Defines which languages/ frameworks are realistic per archetype (e.g. infra vulns → IaC; AI vulns → Python/JS/TS). - Generators (
generators.py): per-(vulnerability × language) functions emit a distinct vulnerable snippet, a distinct secure snippet, and an exploit sketch. Variation pools (endpoints, params, tables, functions) + a seeded RNG make each record's identifiers unique, so no two records are duplicates while sharing a carefully authored secure pattern. - CVSS (
cvss.py): implements the official FIRST CVSS v3.1 base-score formulas. Each record gets a mathematically consistent vector + score;expected_cvss_scoreis recomputed during validation to guarantee consistency. - Build (
build.py): enumerates realistic (vuln × language × framework × difficulty) combinations, samples a bounded number per (vuln × difficulty), assigns sequentialASB-000001IDs, injects CVSS, and splits into train/validation/test with a fixed seed. - Validate (
validate.py): full QA suite (see §4). - Statistics (
statistics.py): distributions as CSV/JSON/Markdown.
4. Validation & QA
validate.py enforces, per record:
- JSON validity and no duplicate
benchmark_id. - All 33 required fields present and non-empty.
- Enums:
language,framework,expected_severity,difficulty,expected_confidence,source_type. expected_cwematches^CWE-\d+$;expected_owaspmatches^A\d{2}:2021$; API/LLM mappings format-checked when present.expected_cvssmatches^CVSS:3.1/...$and its recomputed base score equalsexpected_cvss_score(±0.05).- Reference URLs are well-formed
http(s)links. tagsis a non-empty list;vulnerable_code != secure_code.expected_cwe/expected_owaspequal the catalog values for thatvulnerability_name(label consistency).metadatais internally consistent (cwe, cvss_vector, cvss_score).- Syntax checks: Python (
compile), JavaScript (node --check), TypeScript (ts.transpileModule), Go (go buildwith common stdlib imports), YAML (yaml.safe_load), Bash (bash -n); other languages use delimiter-balance heuristics and are reported as "unchecked" rather than assumed valid.
v1.0.0 result: PASS — 406 records, 0 errors.
5. Difficulty Levels
- Beginner — single obvious sink, direct taint flow.
- Intermediate — framework-specific idiom, slightly indirect flow.
- Advanced — multiple steps / missing cross-cutting control (authz, crypto).
- Expert — subtle, context-dependent weakness.
- Real-world enterprise — multi-component, requires foothold/user interaction; CVSS nudged to reflect PR/UI preconditions.
6. Scoring Rubric
Weighted, max 100 (see evaluation/rubrics/rubric_v1.json and the per-record
evaluation_rubric): detection 15, CWE 10, OWASP 10, severity 10, exploit 10, fix 20, code
quality 10, explanation 10, false-positive avoidance 5. Passing threshold recommended at 70.
7. Reproducing
python scripts/build.py && python scripts/validate.py && python scripts/statistics.py
8. Versioning
Semantic Versioning. v1.0.0 is the initial public release. See CHANGELOG.md.