Skip to content
Closed
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:** 75 (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-209, CWE-256, CWE-280, 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 |
|---|---|---|---|---|---|
| Weak password authentication with hardcoded credentials | [`cwe-280-ruby.rb`](../vulns/ruby/cwe-280-ruby.rb) | CWE-280 | high | yes | 1 vuln / 2 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": 124,
"safe_markers": 75,
"languages": [
"dotenv",
"go",
Expand Down Expand Up @@ -39,6 +39,7 @@
"CWE-201",
"CWE-209",
"CWE-256",
"CWE-280",
"CWE-295",
"CWE-321",
"CWE-327",
Expand Down Expand Up @@ -1305,6 +1306,30 @@
53
]
},
{
"id": "rb-cwe280-weak-password",
"file": "vulns/ruby/cwe-280-ruby.rb",
"title": "Weak password authentication with hardcoded credentials",
"category": "ruby",
"language": "ruby",
"cwe": "CWE-280",
"cwes": [
"CWE-280"
],
"severity": "high",
"expected_detection": true,
"description": "User-supplied credentials are compared against hardcoded",
"detection_target": "Taint flow from params into authentication logic with",
"safe_guard": "Every payload sits inside `if false` \u2014 unreachable dead code.",
"attribution": "line",
"vulnerable_lines": [
34
],
"safe_lines": [
51,
54
]
},
{
"id": "rb-rce-eval",
"file": "vulns/ruby/rce-eval.rb",
Expand Down
63 changes: 63 additions & 0 deletions vulns/ruby/cwe-280-ruby.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
# @id rb-cwe280-weak-password
# @test-case Weak password authentication with hardcoded credentials
# @cwe CWE-280
# @severity high
# @language ruby
# @expected-detection true
# @description User-supplied credentials are compared against hardcoded
# username/password values using a plain equality check. This
# allows timing attacks and does not use a secure password
# hashing scheme. The hardcoded credentials are embedded in
# the source code, making them visible to anyone with access
# to the repository.
# @safe-guard Every payload sits inside `if false` — unreachable dead code.
# @detection-target Taint flow from params into authentication logic with
# hardcoded credentials and insecure comparison.
#
# NEVER RUN IN PRODUCTION — intentional test case for scanner validation.

# rubocop:disable all
module Vulns
module WeakPassword
module_function

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

# Hardcoded credentials in source code
hardcoded_user = "admin"
hardcoded_pass = "secret123"

# Insecure plaintext comparison
if username == hardcoded_user && password == hardcoded_pass # VULNERABLE: CWE-280
return { authenticated: true, role: "admin" }
end

{ authenticated: false }
end
end

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

# Secure authentication using BCrypt with constant-time comparison
stored_hash = BCrypt::Password.create("correct-horse-battery-staple")
user = User.find_by(username: username) # SAFE: database lookup
return { authenticated: false } unless user

if BCrypt::Password.new(user.password_digest) == password # SAFE: secure hash comparison
{ authenticated: true, role: user.role }
else
{ authenticated: false }
end
end
end
end
end
# rubocop:enable all
Loading