GuardBench / README.md
Soaperloafidksum's picture
Make runs resumable: append per generation, skip completed
aa831cb verified
|
Raw
History Blame Contribute Delete
4.63 kB
metadata
license: apache-2.0
task_categories:
  - text-classification
language:
  - en
tags:
  - security
  - code-review
  - benchmark
  - vulnerability-analysis
  - evaluation
pretty_name: GuardBench
size_categories:
  - n<1K
configs:
  - config_name: default
    data_files: items.jsonl

GuardBench

A benchmark for one question: can the model follow a guard?

Every failure worth caring about that we measured on real code in August 2026 was a guard question, in one direction or the other:

  • the base and LOREA Pilot announced disabled TLS in code that passes its SSL context correctly, a symlink escape in code with realpath+commonpath confinement ten lines above the call, and a spoofable forwarded header behind a loopback gate. Guard present, guard unread.
  • Ginko v1 cleared a real timing attack because startswith("Bearer ") sat on the tainted path. Guard present, guard irrelevant, cleared anyway.

FBE cannot see either. In a 50-token snippet the guard and the sink are adjacent and the example is too short to miss one, so FBE-safe reports about 3 percent false alarms while the same model gets three of four wrong on a 1,500-line file. GuardBench puts distance between the guard and the sink, because distance is what the failure needs.

The six shapes

120 items: 20 patterns across 19 vulnerability classes, six shapes each.

shape guard correct verdict what it catches
none absent VULNERABLE baseline: can it find anything
covers present, applied, sufficient SAFE false alarms on defended code
covers_alt a second correct implementation, defended differently SAFE as above, so one wrong answer does not move the rate 12 points
wrong_value present, applied to a sibling value VULNERABLE the tainted value slipped past
irrelevant present, applied to the right value, does not address the weakness VULNERABLE mistaking a format check for a control
elsewhere defined and used in this file, not on this path VULNERABLE helper exists, call site skips it

irrelevant is the shape no existing corpus has and the one Ginko fails. covers is the shape the base and Pilot fail.

Rules that make it scoreable

Distance is required. In every item the guard is a helper defined above, a decorator, a branch several lines up, or a constant declared at module scope. Never the line before the sink.

Verdicts are parsed, never matched. Every item requires a final VERDICT: VULNERABLE <class> or VERDICT: SAFE line. A missing line is a scored failure, not a guess. The FBE grader counted "does not contain any vulnerabilities" as claiming a vulnerability, and no benchmark here will repeat that.

Three prompt phrasings per item. Ginko dropped its verdict line on 48 of 65 FBE items purely because the harness said "Analyze this code for security issues" where its training said "Review this code for security problems". A model that only works on one phrasing is not working, and the benchmark should show that rather than reward it.

Ground truth by construction. Each item is written as a base plus a delta that defines the label. Nothing here is labelled by a model or by judgement.

No overlap with anything a model here was trained or selected on. Checked by 7-gram shingle overlap against all 459 Cyber training seeds and all 169 FBE items: worst overlap 0 percent. One pattern was rewritten when its HMAC helper measured 29 percent against a training seed.

Scoring

Report four numbers, and never one alone:

accuracy        over all items
false alarms    on `covers` only        - the base/Pilot failure
missed          on `irrelevant`         - the Ginko failure
no-verdict rate over all prompt variants - brittleness

Verified against degenerate strategies: always-VULNERABLE scores 67 percent raw and 50 percent balanced; always-SAFE scores 33 percent raw and 50 percent balanced. Raw accuracy is printed but should never be quoted alone.

Running it

python3 guardbench/run.py --tag <name> [--model <path>] [--adapter <path>] [--prompts 1|2|3]

Generations are appended to results/partial_<tag>.jsonl as they complete, and a re-run skips what is already there. An interrupted run resumes rather than starting over. --prompts 1 drops the brittleness measurement and cuts the run to a third.

To score a partial or finished run without generating anything:

python3 -c "import json,sys; sys.path.insert(0,'guardbench'); import run; \
  rows=[json.loads(l) for l in open('guardbench/results/partial_<tag>.jsonl')]; \
  run.report(rows,'<tag>')"