Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 6 additions & 5 deletions docs/VULNERABILITY_CATALOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@ from each file's header comment, so this page cannot drift from the source.

## Totals

- **Test cases:** 62
- **Expected detections:** 62
- **`VULNERABLE:` markers:** 123 (individual lines a scanner should flag)
- **`SAFE:` markers:** 73 (lines a scanner must not flag — the false-positive control group)
- **Test cases:** 63
- **Expected detections:** 63
- **`VULNERABLE:` markers:** 124 (individual lines a scanner should flag)
- **`SAFE:` markers:** 74 (lines a scanner must not flag — the false-positive control group)
- **Languages:** 8 — dotenv, go, java, javascript, json, python, ruby, text
- **CWE categories:** 46 — CWE-20, CWE-22, CWE-78, CWE-79, CWE-89, CWE-90, CWE-95, CWE-113, CWE-117, CWE-190, CWE-201, CWE-209, CWE-256, CWE-295, CWE-321, CWE-327, CWE-330, CWE-338, CWE-346, CWE-347, CWE-352, CWE-362, CWE-377, CWE-384, CWE-489, CWE-502, CWE-506, CWE-532, CWE-601, CWE-611, CWE-614, CWE-639, CWE-643, CWE-681, CWE-759, CWE-798, CWE-862, CWE-915, CWE-918, CWE-942, CWE-943, CWE-1236, CWE-1321, CWE-1333, CWE-1336, CWE-1357
- **CWE categories:** 47 — CWE-20, CWE-22, CWE-78, CWE-79, CWE-89, CWE-90, CWE-95, CWE-113, CWE-117, CWE-170, CWE-190, CWE-201, CWE-209, CWE-256, CWE-295, CWE-321, CWE-327, CWE-330, CWE-338, CWE-346, CWE-347, CWE-352, CWE-362, CWE-377, CWE-384, CWE-489, CWE-502, CWE-506, CWE-532, CWE-601, CWE-611, CWE-614, CWE-639, CWE-643, CWE-681, CWE-759, CWE-798, CWE-862, CWE-915, CWE-918, CWE-942, CWE-943, CWE-1236, CWE-1321, CWE-1333, CWE-1336, CWE-1357

## How coverage is scored

Expand Down Expand Up @@ -71,6 +71,7 @@ counts as a detection. See `docs/SCANNER_INTEGRATION.md`.
| Test case | File | CWE | Severity | Expected | Markers |
|---|---|---|---|---|---|
| CSV formula injection from untrusted spreadsheet cells | [`csv-formula-injection.py`](../vulns/python/csv-formula-injection.py) | CWE-1236 | medium | yes | 1 vuln / 1 safe |
| Format string injection via user-controlled format specifier | [`cwe-170-python.py`](../vulns/python/cwe-170-python.py) | CWE-170 | medium | yes | 1 vuln / 1 safe |
| Excessive user-record exposure in an API response | [`excessive-data-exposure.py`](../vulns/python/excessive-data-exposure.py) | CWE-201 | high | yes | 1 vuln / 1 safe |
| Flask debug mode enabled in application configuration | [`flask-debug-enabled.py`](../vulns/python/flask-debug-enabled.py) | CWE-489 | high | yes | 1 vuln / 1 safe |
| Hardcoded secret used to configure session signing | [`hardcoded-session-secret.py`](../vulns/python/hardcoded-session-secret.py) | CWE-798 | high | yes | 1 vuln / 1 safe |
Expand Down
32 changes: 28 additions & 4 deletions vulns/VULNERABILITY_CATALOG.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
"schema": "threatcrush-testbed-catalog/1",
"note": "Generated by scripts/generate-catalog.py \u2014 do not edit by hand.",
"totals": {
"test_cases": 62,
"expected_detections": 62,
"vulnerable_markers": 123,
"safe_markers": 73,
"test_cases": 63,
"expected_detections": 63,
"vulnerable_markers": 124,
"safe_markers": 74,
"languages": [
"dotenv",
"go",
Expand Down Expand Up @@ -35,6 +35,7 @@
"CWE-95",
"CWE-113",
"CWE-117",
"CWE-170",
"CWE-190",
"CWE-201",
"CWE-209",
Expand Down Expand Up @@ -791,6 +792,29 @@
40
]
},
{
"id": "py-cwe-170-format-string-injection",
"file": "vulns/python/cwe-170-python.py",
"title": "Format string injection via user-controlled format specifier",
"category": "python",
"language": "python",
"cwe": "CWE-170",
"cwes": [
"CWE-170"
],
"severity": "medium",
"expected_detection": true,
"description": "User-controlled input is used directly as a format string in",
"detection_target": "Taint flow from request input into str.format() as the",
"safe_guard": "The entire fixture is wrapped in `if False:` and cannot execute. It",
"attribution": "line",
"vulnerable_lines": [
23
],
"safe_lines": [
32
]
},
{
"id": "py-excessive-data-exposure",
"file": "vulns/python/excessive-data-exposure.py",
Expand Down
33 changes: 33 additions & 0 deletions vulns/python/cwe-170-python.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
"""
@id py-cwe-170-format-string-injection
@test-case Format string injection via user-controlled format specifier
@cwe CWE-170
@severity medium
@language python
@expected-detection true
@description User-controlled input is used directly as a format string in
str.format(), allowing an attacker to access internal object
attributes or cause unexpected behavior through format specifiers.
@safe-guard The entire fixture is wrapped in `if False:` and cannot execute. It
uses only local variables and never performs I/O operations.
@detection-target Taint flow from request input into str.format() as the
format string argument without sanitization.

NEVER RUN IN PRODUCTION - intentional test case for scanner validation.
"""


if False:
def format_message_vulnerable(request):
user_input = request.form["user_input"] # SOURCE: attacker-controlled
template = "User message: {}".format(user_input) # VULNERABLE: CWE-170
return template

def sanitize_format_string(value):
# Remove format specifiers that could access object attributes
return value.replace("{", "{{").replace("}", "}}")

def format_message_safe(request):
user_input = sanitize_format_string(request.form["user_input"])
template = "User message: {}".format(user_input) # SAFE: format specifiers are escaped
return template