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:** 125 (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-190, CWE-201, CWE-204, 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 @@ -97,6 +97,7 @@ counts as a detection. See `docs/SCANNER_INTEGRATION.md`.

| Test case | File | CWE | Severity | Expected | Markers |
|---|---|---|---|---|---|
| User enumeration via different error messages for existing vs non-existing usernames | [`cwe-204-ruby.rb`](../vulns/ruby/cwe-204-ruby.rb) | CWE-204 | medium | yes | 2 vuln / 1 safe |
| Code and command injection via eval / send / backticks | [`rce-eval.rb`](../vulns/ruby/rce-eval.rb) | CWE-95 | critical | yes | 3 vuln / 1 safe |
| SQL injection via string interpolation in ActiveRecord | [`sqli-string-interpolation.rb`](../vulns/ruby/sqli-string-interpolation.rb) | CWE-89 | critical | yes | 3 vuln / 1 safe |
| XSS via html_safe / raw on untrusted input | [`xss-erb-html-safe.rb`](../vulns/ruby/xss-erb-html-safe.rb) | CWE-79 | high | yes | 3 vuln / 1 safe |
Expand Down
33 changes: 29 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": 125,
"safe_markers": 74,
"languages": [
"dotenv",
"go",
Expand Down Expand Up @@ -37,6 +37,7 @@
"CWE-117",
"CWE-190",
"CWE-201",
"CWE-204",
"CWE-209",
"CWE-256",
"CWE-295",
Expand Down Expand Up @@ -1305,6 +1306,30 @@
53
]
},
{
"id": "rb-cwe204-username-enumeration",
"file": "vulns/ruby/cwe-204-ruby.rb",
"title": "User enumeration via different error messages for existing vs non-existing usernames",
"category": "ruby",
"language": "ruby",
"cwe": "CWE-204",
"cwes": [
"CWE-204"
],
"severity": "medium",
"expected_detection": true,
"description": "The application reveals whether a username exists by returning",
"detection_target": "Taint flow from params into conditional error message",
"safe_guard": "Every payload sits inside `if false` \u2014 unreachable dead code.",
"attribution": "line",
"vulnerable_lines": [
29,
33
],
"safe_lines": [
47
]
},
{
"id": "rb-rce-eval",
"file": "vulns/ruby/rce-eval.rb",
Expand Down
54 changes: 54 additions & 0 deletions vulns/ruby/cwe-204-ruby.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
# @id rb-cwe204-username-enumeration
# @test-case User enumeration via different error messages for existing vs non-existing usernames
# @cwe CWE-204
# @severity medium
# @language ruby
# @expected-detection true
# @description The application reveals whether a username exists by returning
# different error messages for "user not found" vs "invalid password".
# This allows an attacker to enumerate valid usernames through the
# login endpoint.
# @safe-guard Every payload sits inside `if false` — unreachable dead code.
# @detection-target Taint flow from params into conditional error message
# generation that reveals user existence.
#
# NEVER RUN IN PRODUCTION — intentional test case for scanner validation.

# rubocop:disable all
module Vulns
module Cwe204UserEnumeration
module_function

def login_vulnerable(params)
if false
username = params[:username] # SOURCE: attacker-controlled
password = params[:password] # SOURCE: attacker-controlled

user = User.find_by(username: username)
if user.nil?
return "User not found" # VULNERABLE: CWE-204 reveals user existence
elsif user.authenticate(password)
return "Login successful"
else
return "Invalid password" # VULNERABLE: CWE-204 reveals user existence
end
end
end

# Safe counterpart — the scanner should NOT flag this.
# @expected-detection false
def login_safe(params)
if false
username = params[:username]
password = params[:password]

user = User.find_by(username: username)
if user.nil? || !user.authenticate(password)
return "Invalid credentials" # SAFE: generic message for all failures
end
"Login successful"
end
end
end
end
# rubocop:enable all