# SPDX-License-Identifier: Apache-2.0 """Write the static leaderboard Space from results/eval_results.json.""" from __future__ import annotations import json from pathlib import Path ROOT = Path(__file__).resolve().parents[1] RESULTS = ROOT / "results" / "eval_results.json" SPACE = ROOT / "space" HTML = """ Tool-output injection leaderboard

Tool-output injection leaderboard

Do open prompt-injection classifiers catch instructions hidden in tool results — concealment, extra tool calls, exfiltration, JSON fields, markdown comments, unicode — without flagging ordinary “run npm install” docs?

Scores

Argmax decision. No threshold was fit on this set. F1 is on the pooled labels. FPR is the share of that negative category flagged as injection. Latency is the mean of 32 single-example CPU calls after 4 warmup calls.

Recall by category

Injection categories only. Benign false-positive rates are in the table above.

Public split versus held-out style

Examples

Picked by a fixed rule, not by hand: the most confident public concealment catch, the lowest-probability miss in each injection category, and the most confident benign false positives. Zero-width and bidi marks are shown in brackets. The gloss is the sentence before unicode tricks; the model did not see the gloss.

Not scored

""" def main() -> None: doc = json.loads(RESULTS.read_text(encoding="utf-8")) payload = json.dumps(doc, ensure_ascii=False).replace("<", "\\u003c") SPACE.mkdir(parents=True, exist_ok=True) (SPACE / "index.html").write_text(HTML.replace("__PAYLOAD__", payload), encoding="utf-8") (SPACE / "results.json").write_text( json.dumps(doc, indent=2, ensure_ascii=False) + "\n", encoding="utf-8" ) ok = [m for m in doc["models"] if m["status"] == "ok"] lines = [ "---", "title: Tool Output Injection Leaderboard", 'emoji: "🔍"', "colorFrom: yellow", "colorTo: red", "sdk: static", "pinned: false", "license: apache-2.0", "short_description: CPU guards on hidden instructions in tool output", "---", "", "# Tool-output injection leaderboard", "", "Static page. Scores are baked in from `results/eval_results.json` in the source repo.", "Suggested Space id: `SamJoshua/tool-output-injection-leaderboard`.", "Suggested dataset id: `SamJoshua/tool-output-injection-bench`.", "", f"Rows: {doc['n_rows']}. Positives: {doc['n_positive']}. Fingerprint: `{doc['dataset_fingerprint']}`.", "", "Models with scores:", "", ] for m in ok: lines.append( f"- `{m['name']}` — F1 {m['metrics']['all']['f1']:.3f}, " f"recall {m['metrics']['all']['recall']:.3f}, " f"benign-imperative FPR {m['metrics']['per_category']['benign_imperative']['fpr']:.3f}" ) skipped = [m for m in doc["models"] if m["status"] != "ok"] lines += ["", "Not scored:", ""] for m in skipped: lines.append(f"- `{m['name']}` — {m['status']}: {m['error']}") lines.append("") (SPACE / "README.md").write_text("\n".join(lines), encoding="utf-8") print(f"wrote {SPACE / 'index.html'}") if __name__ == "__main__": main()