CWE-bench: Defensive Audit-and-Patch Tasks
100 defensive security tasks covering 91 distinct CWE types across 8 languages. In each task an agent is given a codebase containing one security weakness and must find and fix it without breaking the code's normal behavior. A fix is accepted only when the weakness is closed and legitimate behavior is preserved. Grading is fully executable: the reward comes from running exploit inputs and legitimate cases against the agent's patched code.
Contents
README.md
tasks/
<language>-cwe<N>-<id>[-hardened-vK]/ # one directory per task (100 total)
Each task is a standard, self-describing Harbor task:
task.toml: task metadata (language, CWE, difficulty) plus agent, verifier and environment settings.instruction.md: the brief given to the agent.environment/Dockerfile: builds the vulnerable codebase (environment/repo.tar.gz) into/app, with its dependencies pre-installed for offline use.solution/solve.sh: the reference fix.tests/test.sh: the verifier entry point; it runstests/verify_programmatic.py(withtests/probes/where present), the deterministic verifier that executes the exploit and legitimate cases.
Task names follow <language>-cwe<N>-<id>; a -hardened-vK suffix marks a hardened revision of a base task.
Languages
| Language | Tasks |
|---|---|
| go | 27 |
| java | 15 |
| javascript | 15 |
| cpp | 14 |
| c | 10 |
| python | 10 |
| rust | 5 |
| typescript | 4 |
The reward
reward = 1 iff the deterministic verifier finds every exploit input closed and every legitimate case working;
any failing check yields 0. If the verifier cannot evaluate (for example, the environment fails to build), no
reward is written and the trial is void rather than scored 0. Each trial writes reward.txt, reward.json,
scores.json and the verifier log programmatic.log under /logs/verifier/.
solution/solve.sh is supplied for package verification and must not be exposed to an evaluated agent.
Running the tasks
Run the full benchmark straight from this repo: Harbor resolves the cwe-bench@2.0 dataset from registry.json,
so there is nothing to clone:
harbor run --repo "https://huggingface.co/datasets/collinear-ai/cwe-bench" -d cwe-bench@2.0 -k 4 \
--agent <agent> --model <model> --env docker \
--allow-agent-host <model API host>
Run 4 attempts per task (-k 4); the reported score is the mean reward over all 400 trials.
Add -i <task-name> to run selected tasks, or -l <n> to cap the task count. The repo is gated, so accept its
access conditions first and make sure git can authenticate to huggingface.co with an HF token that can read gated repos.
Each task can also be run from a local copy of the repo, e.g.:
harbor run --path tasks/c-cwe191-be1d924f-hardened-v2 \
--agent <agent> --model <model> --env docker \
--allow-agent-host <model API host>
- Network. The agent phase runs with
network_mode = "no-network";--allow-agent-hostadmits only the model API host the agent needs. Image build and the verifier keep public network access. - Timeouts. Agent 3600 s per task; verifier and build timeouts are set per task in
task.toml. - Resources. 2 CPUs, 2 GB memory and 4 GB storage per task unless the task's
task.tomlsays otherwise. - Reference check. To confirm a task's environment and verifier, run Harbor's oracle agent, which applies
solution/solve.sh; it should score1.
CWE coverage
91 distinct CWEs. Names are from the MITRE CWE catalog (v5.0).
| CWE | Name | Tasks |
|---|---|---|
| CWE-73 | External Control of File Name or Path | java-cwe73-292db358-hardened-v3 |
| CWE-79 | Improper Neutralization of Input During Web Page Generation | java-cwe79-5bb67926 |
| CWE-87 | Improper Neutralization of Alternate XSS Syntax | javascript-cwe87-8dbb5ab4-hardened-v1 |
| CWE-88 | Improper Neutralization of Argument Delimiters in a Command | rust-cwe88-2a880b48 |
| CWE-89 | Improper Neutralization of Special Elements used in an SQL Command | javascript-cwe89-5aed96f6 |
| CWE-91 | XML Injection | go-cwe91-a2c4ff31-hardened-v1 |
| CWE-94 | Improper Control of Generation of Code | javascript-cwe94-b9de1c40 |
| CWE-113 | Improper Neutralization of CRLF Sequences in HTTP Headers | go-cwe113-462f8e50-hardened-v1, python-cwe113-e52d9cf1-hardened-v2 |
| CWE-117 | Improper Output Neutralization for Logs | go-cwe117-0a4eef03-hardened-v1, javascript-cwe117-b5dd5865-hardened-v2 |
| CWE-125 | Out-of-bounds Read | cpp-cwe125-03b39721 |
| CWE-185 | Incorrect Regular Expression | python-cwe185-43fe3cb0-hardened-v3 |
| CWE-191 | Integer Underflow (Wrap or Wraparound) | c-cwe191-be1d924f-hardened-v2 |
| CWE-195 | Signed to Unsigned Conversion Error | cpp-cwe195-05238f5d-hardened-v3 |
| CWE-200 | Exposure of Sensitive Information to an Unauthorized Actor | python-cwe200-fa968a47 |
| CWE-201 | Insertion of Sensitive Information Into Sent Data | go-cwe201-b675d782-hardened-v1 |
| CWE-219 | Storage of File with Sensitive Data Under Web Root | javascript-cwe219-bedf9af6-hardened-v3 |
| CWE-248 | Uncaught Exception | go-cwe248-13dcbadf-hardened-v3 |
| CWE-257 | Storing Passwords in a Recoverable Format | javascript-cwe257-5bc1fe89-hardened-v3 |
| CWE-272 | Least Privilege Violation | go-cwe272-cb670134 |
| CWE-273 | Improper Check for Dropped Privileges | go-cwe273-35cd46d2-hardened-v3 |
| CWE-289 | Authentication Bypass by Alternate Name | python-cwe289-7fd5d869-hardened-v3 |
| CWE-290 | Authentication Bypass by Spoofing | c-cwe290-e0ad1617 |
| CWE-291 | Reliance on IP Address for Authentication | java-cwe291-c861dc98-hardened-v2 |
| CWE-295 | Improper Certificate Validation | go-cwe295-558d2730 |
| CWE-299 | Improper Check for Certificate Revocation | go-cwe299-7f1983ae-hardened-v2 |
| CWE-303 | Incorrect Implementation of Authentication Algorithm | java-cwe303-300d0aed-hardened-v1 |
| CWE-306 | Missing Authentication for Critical Functionality | typescript-cwe306-43fe6624 |
| CWE-311 | Missing Encryption of Sensitive Data | rust-cwe311-7563813b |
| CWE-315 | Cleartext Storage of Sensitive Information in a Cookie | java-cwe315-08f1be04-hardened-v1 |
| CWE-319 | Cleartext Transmission of Sensitive Information | c-cwe319-dcf620e7 |
| CWE-321 | Use of Hard-coded Cryptographic Key | rust-cwe321-ad52f15b |
| CWE-323 | Reusing a Nonce, Key Pair in Encryption | python-cwe323-67f59113-hardened-v1 |
| CWE-324 | Use of a Key Past its Expiration Date | python-cwe324-4bfc7fb3-hardened-v3 |
| CWE-326 | Inadequate Encryption Strength | c-cwe326-608cfffc |
| CWE-328 | Use of Weak Hash | rust-cwe328-bd587348-hardened-v1 |
| CWE-329 | Generation of Predictable IV with CBC Mode | c-cwe329-fadca8b4 |
| CWE-337 | Predictable Seed in Pseudo-Random Number Generator (PRNG) | java-cwe337-99c3fc39-hardened-v3 |
| CWE-346 | Origin Validation Error | typescript-cwe346-1ebe99f5-hardened-v2 |
| CWE-347 | Improper Verification of Cryptographic Signature | javascript-cwe347-58e97811 |
| CWE-348 | Use of Less Trusted Source | go-cwe348-72cdc38f-hardened-v1 |
| CWE-350 | Reliance on Reverse DNS Resolution for a Security-Critical Action | java-cwe350-47963208-hardened-v3 |
| CWE-369 | Divide By Zero | cpp-cwe369-2b21bdf5 |
| CWE-404 | Improper Resource Shutdown or Release | c-cwe404-cf7e0aed |
| CWE-426 | Untrusted Search Path | python-cwe426-3d4ceea0 |
| CWE-427 | Uncontrolled Search Path Element | cpp-cwe427-3e09f355 |
| CWE-434 | Unrestricted Upload of File with Dangerous Type | cpp-cwe434-c7721a68 |
| CWE-444 | Inconsistent Interpretation of HTTP Requests | go-cwe444-dd94f3ab |
| CWE-457 | Use of Uninitialized Variable | c-cwe457-bb8b6c6d-hardened-v5 |
| CWE-460 | Improper Cleanup on Thrown Exception | go-cwe460-986f04e0-hardened-v3 |
| CWE-462 | Duplicate Key in Associative List (Alist) | go-cwe462-bc932d04-hardened-v3 |
| CWE-472 | External Control of Assumed-Immutable Web Parameter | java-cwe472-e606721d, javascript-cwe472-88bcb309 |
| CWE-494 | Download of Code Without Integrity Check | cpp-cwe494-30255b4f-hardened-v2 |
| CWE-522 | Insufficiently Protected Credentials | go-cwe522-c5b09fb6, java-cwe522-8914dc0a |
| CWE-532 | Insertion of Sensitive Information into Log File | cpp-cwe532-5ad1f2f4 |
| CWE-565 | Reliance on Cookies without Validation and Integrity Checking | java-cwe565-5fde8582 |
| CWE-598 | Use of HTTP Request With Sensitive Query String | javascript-cwe598-eb8d2633-hardened-v1 |
| CWE-601 | URL Redirection to Untrusted Site | go-cwe601-afd8f16e |
| CWE-609 | Double-Checked Locking | go-cwe609-725155b6-hardened-v3 |
| CWE-613 | DEPRECATED: Insufficient Session Expiration | go-cwe613-75fa8fbd |
| CWE-614 | Sensitive Cookie in HTTPS Session Without 'Secure' Attribute | javascript-cwe614-9244c34f |
| CWE-636 | Not Failing Securely | go-cwe636-eb8231a5-hardened-v3 |
| CWE-639 | Authorization Bypass Through User-Controlled Key | cpp-cwe639-a3203fa9 |
| CWE-640 | Weak Password Recovery Mechanism for Forgotten Password | javascript-cwe640-57aa7527-hardened-v1 |
| CWE-680 | Integer Overflow to Buffer Overflow | cpp-cwe680-8e08ffb0-hardened-v5 |
| CWE-693 | Protection Mechanism Failure | go-cwe693-0af33344, java-cwe693-9ae8dd00 |
| CWE-698 | Execution After Redirect (EAR) | go-cwe698-526715a4-hardened-v3, java-cwe698-e60c7cfa-hardened-v3, javascript-cwe698-b1e6d2ec-hardened-v4 |
| CWE-755 | Improper Handling of Exceptional Conditions | go-cwe755-1fba24f8, typescript-cwe755-a1f76692 |
| CWE-757 | Selection of Less-Secure Algorithm During Negotiation | java-cwe757-74910bd9-hardened-v4 |
| CWE-763 | Release of Invalid Pointer or Reference | c-cwe763-3a015046-hardened-v2 |
| CWE-772 | Missing Release of Resource after Effective Lifetime | java-cwe772-649f4522 |
| CWE-780 | Use of RSA Algorithm without OAEP | go-cwe780-7124da23-hardened-v3 |
| CWE-784 | Reliance on Cookies without Validation and Integrity Checking in a Security Decision | go-cwe784-42529572-hardened-v2 |
| CWE-789 | Memory Allocation with Excessive Size Value | c-cwe789-f31b6795-hardened-v5 |
| CWE-823 | Use of Out-of-range Pointer Offset | cpp-cwe823-326c6979-hardened-v3 |
| CWE-834 | Excessive Iteration | go-cwe834-6a872abb |
| CWE-836 | Use of Password Hash Instead of Password for Authentication | javascript-cwe836-0c737699-hardened-v4 |
| CWE-837 | Improper Enforcement of a Single, Unique Action | java-cwe837-19a32784-hardened-v3 |
| CWE-843 | Access of Resource Using Incompatible Type | c-cwe843-4dcfb606-hardened-v4 |
| CWE-862 | Missing Authorization | cpp-cwe862-574610fa |
| CWE-863 | Incorrect Authorization | cpp-cwe863-5f404e0c-hardened-v1, go-cwe863-f23c3492 |
| CWE-916 | Use of Password Hash With Insufficient Computational Effort | cpp-cwe916-c8e15f06 |
| CWE-917 | Improper Neutralization of Special Elements used in an Expression Language Statement | javascript-cwe917-8771362b |
| CWE-918 | Server-Side Request Forgery | cpp-cwe918-be2b6bbc |
| CWE-1004 | Sensitive Cookie Without 'HttpOnly' Flag | go-cwe1004-40781c18 |
| CWE-1021 | Improper Restriction of Rendered UI Layers or Frames | typescript-cwe1021-29e1197b |
| CWE-1188 | Initialization of a Resource with an Insecure Default | javascript-cwe1188-59539d7b-hardened-v2 |
| CWE-1287 | Improper Validation of Specified Type of Input | python-cwe1287-57ba5824-hardened-v3 |
| CWE-1288 | Improper Validation of Consistency within Input | go-cwe1288-fea394c4-hardened-v3 |
| CWE-1333 | Inefficient Regular Expression Complexity | python-cwe1333-d7b470ff |
| CWE-1395 | Dependency on Vulnerable Third-Party Component | rust-cwe1395-7e4f7d96 |
| CWE-1427 | Improper Neutralization of Input Used for LLM Prompting | python-cwe1427-fabfc974-hardened-v3 |
See each task's instruction.md for the full brief.
- Downloads last month
- 4