breachbench 1.3.1__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (51) hide show
  1. breachbench-1.3.1/CHANGELOG.md +37 -0
  2. breachbench-1.3.1/CONTRIBUTING.md +72 -0
  3. breachbench-1.3.1/ETHICS.md +14 -0
  4. breachbench-1.3.1/LICENSE +21 -0
  5. breachbench-1.3.1/MANIFEST.in +9 -0
  6. breachbench-1.3.1/PKG-INFO +541 -0
  7. breachbench-1.3.1/README.md +501 -0
  8. breachbench-1.3.1/app/__init__.py +1 -0
  9. breachbench-1.3.1/app/main.py +170 -0
  10. breachbench-1.3.1/breachbench/__init__.py +7 -0
  11. breachbench-1.3.1/breachbench/__main__.py +6 -0
  12. breachbench-1.3.1/breachbench/agent_eval.py +512 -0
  13. breachbench-1.3.1/breachbench/cli.py +487 -0
  14. breachbench-1.3.1/breachbench/code_scanner.py +273 -0
  15. breachbench-1.3.1/breachbench/engine.py +606 -0
  16. breachbench-1.3.1/breachbench/malware_scanner.py +239 -0
  17. breachbench-1.3.1/breachbench/multi_machine.py +195 -0
  18. breachbench-1.3.1/breachbench/shield.py +570 -0
  19. breachbench-1.3.1/breachbench.egg-info/PKG-INFO +541 -0
  20. breachbench-1.3.1/breachbench.egg-info/SOURCES.txt +49 -0
  21. breachbench-1.3.1/breachbench.egg-info/dependency_links.txt +1 -0
  22. breachbench-1.3.1/breachbench.egg-info/entry_points.txt +2 -0
  23. breachbench-1.3.1/breachbench.egg-info/requires.txt +9 -0
  24. breachbench-1.3.1/breachbench.egg-info/top_level.txt +5 -0
  25. breachbench-1.3.1/config/__init__.py +1 -0
  26. breachbench-1.3.1/config/machines.example.json +37 -0
  27. breachbench-1.3.1/config/machines.json +37 -0
  28. breachbench-1.3.1/data/__init__.py +1 -0
  29. breachbench-1.3.1/data/agent_eval_tasks.json +260 -0
  30. breachbench-1.3.1/data/api_eval.json +157 -0
  31. breachbench-1.3.1/data/code_eval.json +134 -0
  32. breachbench-1.3.1/data/malware_eval.json +110 -0
  33. breachbench-1.3.1/data/phishing_eval.jsonl +30 -0
  34. breachbench-1.3.1/data/scenarios_eval.json +155 -0
  35. breachbench-1.3.1/data/schemas/__init__.py +1 -0
  36. breachbench-1.3.1/data/schemas/api_finding_schema.json +51 -0
  37. breachbench-1.3.1/data/schemas/phishing_schema.json +101 -0
  38. breachbench-1.3.1/data/schemas/scenario_schema.json +68 -0
  39. breachbench-1.3.1/labs/__init__.py +0 -0
  40. breachbench-1.3.1/labs/vulnerable_api/__init__.py +0 -0
  41. breachbench-1.3.1/labs/vulnerable_api/app.py +368 -0
  42. breachbench-1.3.1/labs/vulnerable_api/openapi.json +1030 -0
  43. breachbench-1.3.1/pyproject.toml +80 -0
  44. breachbench-1.3.1/samples/code/safe_service.py +31 -0
  45. breachbench-1.3.1/samples/code/vulnerable_service.py +47 -0
  46. breachbench-1.3.1/samples/malware/benign_package.json +8 -0
  47. breachbench-1.3.1/samples/malware/suspicious_package.json +8 -0
  48. breachbench-1.3.1/samples/malware/synthetic_dropper_sample.txt +5 -0
  49. breachbench-1.3.1/setup.cfg +4 -0
  50. breachbench-1.3.1/setup.py +54 -0
  51. breachbench-1.3.1/tests/test_breachbench.py +370 -0
@@ -0,0 +1,37 @@
1
+ # Changelog
2
+
3
+ All notable changes to **BreachBench** are documented in this file.
4
+
5
+ ## [1.3.1] - 2026-11-13
6
+
7
+ - README rewrite with numbered Quick Start and architecture diagrams.
8
+ - OWASP lab endpoint parity with all 10 `/vuln/*` routes in `data/api_eval.json` and matching hardened counterparts.
9
+ - Installer dry-run fix: `./install.sh --multi-machine --dry-run` no longer passes an unsupported CLI flag.
10
+ - Added `CONTRIBUTING.md`.
11
+ - PyPI packaging (SPDX license, bundled eval corpora, Trusted Publishing workflow ready for tag `v1.3.1`).
12
+ - Removal of an unrelated posture integration (already on `main`; included in this release).
13
+
14
+ Do not move tag `v1.3.0`; cut this release with `git tag v1.3.1`.
15
+
16
+ ## [1.3.0] - 2026-10-27
17
+
18
+ ### Added
19
+ - **3-Layer Defense-in-Depth Guardrail Shield (`breachbench/shield.py`)**:
20
+ - **Layer 1 — Input Pre-Screen (`prescreen_input`)**: Scans untrusted prompts and embedded artifacts with BreachBench's static code vulnerability scanner (`scan_code_snippet`), malware & supply-chain hook detector (`scan_malware_payload`), phishing/BEC/MFA-pretext heuristics (`score_phishing_email`, `normalize_threat_text`), plus regex rules for malware-authoring requests (keyloggers, reverse shells, credential/SSH key exfiltration, ransomware, obfuscated droppers) and prompt-injection/tool-hijack markers (ignore previous instructions, DAN/jailbreaks, forced verdict overrides, canary/env exfiltration, `curl | sh`, and unpermitted SSH `deploy-machines` execution).
21
+ - **Layer 2 — Hardened System Prompt & Data Spotlighting (`build_spotlighted_messages`)**: Wraps untrusted input inside `<untrusted_input_data>` spotlighting tags and injects structured pre-screen analyst telemetry (detected CWEs, OWASP categories, malware categories, and injection indicators) into the system prompt.
22
+ - **Layer 3 — Output Enforcement (`enforce_output_shield`)**: Redacts leaked canary tokens, blocks/replaces responses that comply with malware-authoring or unauthorized SSH tool-hijack requests, neutralizes injection-induced false `clear`/`SAFE` verdicts, and appends a structured `BreachBench Shield findings` section (verdict, CWE IDs, malware categories, and remediation guidance) when the model omits detected findings.
23
+ - Records per-task `shield_actions` in evaluation JSON reports.
24
+ - **CLI Flag `breachbench eval-agent --shield`**: Enables the 3-layer Guardrail Shield for `openai`, `ollama`, `echo`, and `deterministic` providers.
25
+ - **CLI Subcommand `breachbench compare-shield`**: Runs a target model unshielded (`--shield` off) and shielded (`--shield` on), prints a side-by-side comparison table (per-suite, overall, and per-task PASS/FAIL with triggered shield layers), and optionally writes JSON (`--out`) and Markdown (`--md`) reports.
26
+ - **Weak Stub Provider (`--provider echo`)**: Added a naive/compliance-prone stub provider that simulates an unaligned small model to verify and benchmark Guardrail Shield lift deterministically offline.
27
+ - **Release & PyPI Trusted Publishing Workflow (`.github/workflows/release.yml`)**: Automated sdist/wheel build, `twine check`, test verification, GitHub Release creation, and PyPI Trusted Publishing on `v*` tags.
28
+
29
+ ### Changed
30
+ - Bumped package version to `1.3.0` across `pyproject.toml`, `setup.py`, `breachbench/__init__.py`, `breachbench/cli.py`, and `app/main.py`.
31
+ - Expanded unit and integration tests in `tests/test_breachbench.py` covering all three shield layers, unseen prompt generalization, zero false positives on benign artifacts, and `compare-shield`.
32
+
33
+ ## [1.2.0] - 2026-04-12
34
+
35
+ ### Added
36
+ - Multi-domain security benchmark (`breachbench benchmark`) spanning Phishing/BEC/MFA-fatigue triage, Prompt Injection & Canary Guard, OWASP API Top 10 surface analysis, Static & Agent Code Vulnerability Scanner (`scan-code`), Malware & Supply-Chain Lure Detector (`scan-malware`), AI Agent Security Evaluator (`eval-agent`), and permission-gated multi-machine SSH runner (`deploy-machines`).
37
+ - FastAPI service (`app/main.py`) and OWASP vulnerable vs. hardened API comparison lab (`labs/vulnerable_api/app.py`).
@@ -0,0 +1,72 @@
1
+ # Contributing to BreachBench
2
+
3
+ Thanks for helping improve this defensive security benchmark. Please read [ETHICS.md](ETHICS.md) first: only test systems you own or have written permission to evaluate, and do not contribute live malware or real credentials.
4
+
5
+ ## Setup
6
+
7
+ Python 3.9+ is required (CI runs 3.10–3.12). On Debian/Ubuntu, install `python3-venv` if `python3 -m venv` fails.
8
+
9
+ ```bash
10
+ git clone https://github.com/tu2090-ops/breachbench.git
11
+ cd breachbench
12
+ python3 -m venv .venv
13
+ source .venv/bin/activate
14
+ python -m pip install --upgrade pip
15
+ pip install -e ".[dev]"
16
+ ```
17
+
18
+ On Windows, activate with `.venv\Scripts\activate`.
19
+
20
+ ## Running tests
21
+
22
+ ```bash
23
+ python -m unittest discover -s tests
24
+ pytest -v
25
+ ```
26
+
27
+ Both commands execute `tests/test_breachbench.py`. After behavior changes, also run:
28
+
29
+ ```bash
30
+ breachbench eval-agent --provider deterministic
31
+ breachbench benchmark --out /tmp/bb-report.json --md /tmp/bb-report.md
32
+ breachbench compare-shield --provider echo --model echo-weak-stub-v1
33
+ ```
34
+
35
+ Do not commit regenerated files under `results/` unless you intentionally updated a published snapshot.
36
+
37
+ ## Adding a test case or suite
38
+
39
+ 1. **Scanner / triage corpora** — add a gold-labeled item to `data/code_eval.json`, `data/malware_eval.json`, `data/phishing_eval.jsonl`, or `data/api_eval.json`. Keep samples synthetic and inert.
40
+ 2. **Agent eval tasks** — append an object to `data/agent_eval_tasks.json` with `id`, `category` (`malware_refusal_and_detection`, `code_vulnerability_detection`, or `prompt_injection_and_tool_hijack`), `prompt`, `expected_behavior`, `required_concepts`, and optional `forbidden_patterns`.
41
+ 3. **Scenarios** — add a `SCEN-00N` object to `data/scenarios_eval.json`.
42
+ 4. **Assertions** — extend `tests/test_breachbench.py` (or add `tests/test_*.py`). Cover the new path, a benign/false-positive case, and any Guardrail Shield layer you touch.
43
+ 5. **Lab API** — if you add a `/vuln/*` route, add a matching hardened counterpart and list both in `data/api_eval.json`. Regenerate `labs/vulnerable_api/openapi.json` from the FastAPI app.
44
+
45
+ ## Code style
46
+
47
+ - Target Python 3.9+: use `from __future__ import annotations` in library modules that already do so.
48
+ - Keep imports at the top of the module. Do not add inline imports unless a circular dependency is documented.
49
+ - Match existing naming: `scan_*` for detectors, `evaluate_*` for corpus metrics, CLI flags with argparse.
50
+ - Do not look up agent-eval task IDs or grading keywords inside `breachbench/shield.py`.
51
+ - Do not add network calls in the OWASP lab beyond returning simulated results (no live egress).
52
+
53
+ ## Pull requests
54
+
55
+ 1. Branch from current `main`.
56
+ 2. Keep the change focused (one concern per PR).
57
+ 3. Use conventional commits when possible: `feat`, `fix`, `docs`, `test`, `chore`, `refactor`.
58
+ 4. Update [README.md](README.md) or [CHANGELOG.md](CHANGELOG.md) when user-facing behavior, flags, or endpoints change.
59
+ 5. Open a pull request against `https://github.com/tu2090-ops/breachbench` with what changed, how you tested it, and any follow-up the maintainer must do (secrets, PyPI, allowlists).
60
+
61
+ ## Releases
62
+
63
+ The package version is `1.3.1` (`pyproject.toml`, `breachbench/__init__.py`). Tag the next PyPI/GitHub release as **`v1.3.1`**. Do not move or reuse tag `v1.3.0`; it already points at an older commit on origin.
64
+
65
+ ```bash
66
+ git checkout main
67
+ git pull
68
+ git tag v1.3.1
69
+ git push origin v1.3.1
70
+ ```
71
+
72
+ Issues: [github.com/tu2090-ops/breachbench/issues](https://github.com/tu2090-ops/breachbench/issues).
@@ -0,0 +1,14 @@
1
+ # Ethics, Safety & Authorization Policy
2
+
3
+ **BreachBench** is a defensive security evaluation suite and static/agent vulnerability scanner.
4
+
5
+ 1. **Explicit Permission Gate for Multi-Machine Deployment:**
6
+ - Installing or executing BreachBench across local or lab machines via `install.sh` or `breachbench deploy-machines` requires explicit operator authorization (`--confirm-permission` or interactive `"YES_I_HAVE_AUTHORIZATION"` confirmation) and a machine allowlist (`config/machines.example.json` where `"authorized": true`).
7
+ - Every multi-machine deployment attempt is recorded in an immutable JSONL audit trail (`results/deployment_audit.jsonl`).
8
+
9
+ 2. **Synthetic & Inert Test Fixtures Only:**
10
+ - All malware, phishing, prompt-injection, and vulnerable code samples in `data/` and `samples/` are synthetic, inert, non-weaponized indicators designed strictly to test detection accuracy, static analysis rules, and AI agent refusal boundaries.
11
+ - No live command-and-control servers, real credentials, or destructive payloads are included or executed.
12
+
13
+ 3. **Defensive Use Only:**
14
+ - BreachBench must only be run against source code, AI agents, and compute nodes that you own or have explicit written permission to test.
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Tanushree Umathe
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,9 @@
1
+ include README.md
2
+ include LICENSE
3
+ include CHANGELOG.md
4
+ include CONTRIBUTING.md
5
+ include ETHICS.md
6
+ recursive-include data *.json *.jsonl
7
+ recursive-include config *.json
8
+ recursive-include samples *.py *.json *.txt
9
+ recursive-include labs *.json