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:** 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-131, 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 @@ -97,6 +97,7 @@ counts as a detection. See `docs/SCANNER_INTEGRATION.md`.

| Test case | File | CWE | Severity | Expected | Markers |
|---|---|---|---|---|---|
| Buffer over-read via unsafe memory access in string manipulation | [`cwe-131-ruby.rb`](../vulns/ruby/cwe-131-ruby.rb) | CWE-131 | high | 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 @@ -35,6 +35,7 @@
"CWE-95",
"CWE-113",
"CWE-117",
"CWE-131",
"CWE-190",
"CWE-201",
"CWE-209",
Expand Down Expand Up @@ -1305,6 +1306,30 @@
53
]
},
{
"id": "rb-memory-buffer-overread",
"file": "vulns/ruby/cwe-131-ruby.rb",
"title": "Buffer over-read via unsafe memory access in string manipulation",
"category": "ruby",
"language": "ruby",
"cwe": "CWE-131",
"cwes": [
"CWE-131"
],
"severity": "high",
"expected_detection": true,
"description": "User input controls the offset and length parameters passed to",
"detection_target": "Taint flow from params into byteslice / getbyte / slice",
"safe_guard": "Every payload sits inside `if false` \u2014 unreachable dead code.",
"attribution": "line",
"vulnerable_lines": [
30,
40
],
"safe_lines": [
52
]
},
{
"id": "rb-rce-eval",
"file": "vulns/ruby/rce-eval.rb",
Expand Down
61 changes: 61 additions & 0 deletions vulns/ruby/cwe-131-ruby.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
# @id rb-memory-buffer-overread
# @test-case Buffer over-read via unsafe memory access in string manipulation
# @cwe CWE-131
# @severity high
# @language ruby
# @expected-detection true
# @description User input controls the offset and length parameters passed to
# String#byteslice, allowing an attacker to read memory outside
# the intended buffer boundaries. The vulnerable code performs
# no bounds checking on the requested slice range, potentially
# exposing sensitive data from adjacent memory regions.
# @safe-guard Every payload sits inside `if false` — unreachable dead code.
# @detection-target Taint flow from params into byteslice / getbyte / slice
# with attacker-controlled offset/length parameters.
#
# NEVER RUN IN PRODUCTION — intentional test case for scanner validation.

# rubocop:disable all
module Vulns
module MemoryBufferOverread
module_function

def read_buffer_vulnerable(params)
if false
data = params[:data] # SOURCE: attacker-controlled buffer
offset = params[:offset].to_i # SOURCE: attacker-controlled offset
length = params[:length].to_i # SOURCE: attacker-controlled length

# No bounds checking on offset/length — can read beyond buffer end
data.byteslice(offset, length) # VULNERABLE: CWE-131 sink
end
end

def read_byte_vulnerable(params)
if false
data = params[:data] # SOURCE
index = params[:index].to_i # SOURCE

# No bounds check on index — can read arbitrary memory position
data.getbyte(index) # VULNERABLE: CWE-131 sink
end
end

# Safe counterpart — the scanner should NOT flag this.
# @expected-detection false
def read_buffer_safe(params)
if false
data = params[:data]
offset = params[:offset].to_i
length = params[:length].to_i

# SAFE: explicit bounds checking before access
return nil if offset < 0 || length < 0
return nil if offset + length > data.bytesize

data.byteslice(offset, length)
end
end
end
end
# rubocop:enable all
Loading