AppSecBench / docs /methodology.md
ismailtasdelen's picture
Upload folder using huggingface_hub
8df6aa0 verified
|
Raw
History Blame Contribute Delete
4.6 kB

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.py yields 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

  1. 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).
  2. 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.
  3. CVSS (cvss.py): implements the official FIRST CVSS v3.1 base-score formulas. Each record gets a mathematically consistent vector + score; expected_cvss_score is recomputed during validation to guarantee consistency.
  4. Build (build.py): enumerates realistic (vuln × language × framework × difficulty) combinations, samples a bounded number per (vuln × difficulty), assigns sequential ASB-000001 IDs, injects CVSS, and splits into train/validation/test with a fixed seed.
  5. Validate (validate.py): full QA suite (see §4).
  6. 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_cwe matches ^CWE-\d+$; expected_owasp matches ^A\d{2}:2021$; API/LLM mappings format-checked when present.
  • expected_cvss matches ^CVSS:3.1/...$ and its recomputed base score equals expected_cvss_score (±0.05).
  • Reference URLs are well-formed http(s) links.
  • tags is a non-empty list; vulnerable_code != secure_code.
  • expected_cwe / expected_owasp equal the catalog values for that vulnerability_name (label consistency).
  • metadata is internally consistent (cwe, cvss_vector, cvss_score).
  • Syntax checks: Python (compile), JavaScript (node --check), TypeScript (ts.transpileModule), Go (go build with 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.