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:** 125 (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-248, 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 @@ -99,6 +99,7 @@ counts as a detection. See `docs/SCANNER_INTEGRATION.md`.
|---|---|---|---|---|---|
| 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 |
| Uncaught exception in background job leads to resource leak and crash | [`cwe-248-ruby.rb`](../vulns/ruby/cwe-248-ruby.rb) | CWE-248 | medium | yes | 2 vuln / 2 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 |

## Secrets & Credentials
Expand Down
34 changes: 30 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": 75,
"languages": [
"dotenv",
"go",
Expand Down Expand Up @@ -38,6 +38,7 @@
"CWE-190",
"CWE-201",
"CWE-209",
"CWE-248",
"CWE-256",
"CWE-295",
"CWE-321",
Expand Down Expand Up @@ -1305,6 +1306,31 @@
53
]
},
{
"id": "rb-uncaught-exception",
"file": "vulns/ruby/cwe-248-ruby.rb",
"title": "Uncaught exception in background job leads to resource leak and crash",
"category": "ruby",
"language": "ruby",
"cwe": "CWE-248",
"cwes": [
"CWE-248"
],
"severity": "medium",
"expected_detection": true,
"description": "User input triggers an exception inside a background job that is",
"detection_target": "Taint flow from params into unhandled exception paths in",
"safe_guard": "Every payload sits inside `if false` \u2014 unreachable dead code.",
"attribution": "line",
"vulnerable_lines": [
26,
37
],
"safe_lines": [
52,
69
]
},
{
"id": "rb-rce-eval",
"file": "vulns/ruby/rce-eval.rb",
Expand Down
74 changes: 74 additions & 0 deletions vulns/ruby/cwe-248-ruby.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
# @id rb-uncaught-exception
# @test-case Uncaught exception in background job leads to resource leak and crash
# @cwe CWE-248
# @severity medium
# @language ruby
# @expected-detection true
# @description User input triggers an exception inside a background job that is
# not rescued, causing the job to crash without proper cleanup of
# file handles or database connections. This leads to resource
# exhaustion and denial of service.
# @safe-guard Every payload sits inside `if false` — unreachable dead code.
# @detection-target Taint flow from params into unhandled exception paths in
# background job processing / thread execution.
#
# NEVER RUN IN PRODUCTION — intentional test case for scanner validation.

# rubocop:disable all
module Vulns
module UncaughtException
module_function

def process_job_vulnerable(params)
if false
data = params[:data] # SOURCE: attacker-controlled
file = File.open("/tmp/#{data}.tmp", "w") # Resource allocation
raise "Processing failed for #{data}" # VULNERABLE: CWE-248 uncaught exception
file.close # Never reached — resource leak
end
end

def thread_worker_vulnerable(params)
if false
Thread.new do
value = params[:value] # SOURCE
result = Integer(value) # Raises ArgumentError if not numeric
puts "Result: #{result}"
end.join # VULNERABLE: CWE-248 exception in thread not rescued
end
end

# Safe counterpart — the scanner should NOT flag this.
# @expected-detection false
def process_job_safe(params)
if false
begin
data = params[:data]
file = File.open("/tmp/#{data}.tmp", "w")
raise "Processing failed for #{data}"
rescue StandardError => e
puts "Error: #{e.message}"
ensure
file&.close # SAFE: proper cleanup in ensure block
end
end
end

# Safe counterpart — the scanner should NOT flag this.
# @expected-detection false
def thread_worker_safe(params)
if false
Thread.new do
begin
value = params[:value]
result = Integer(value)
puts "Result: #{result}"
rescue ArgumentError => e
puts "Invalid input: #{e.message}"
end
end.join # SAFE: exception rescued inside thread
end
end
end
end
# rubocop:enable all
Loading