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:** 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-209, CWE-256, CWE-290, 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 @@ -47,6 +47,7 @@ counts as a detection. See `docs/SCANNER_INTEGRATION.md`.
| Sensitive session cookie without the Secure attribute | [`cookie-security-flags.js`](../vulns/javascript/cookie-security-flags.js) | CWE-614 | medium | yes | 1 vuln / 1 safe |
| Credentialed CORS configured with a wildcard origin | [`cors-wildcard-credentials.js`](../vulns/javascript/cors-wildcard-credentials.js) | CWE-942 | high | yes | 1 vuln / 1 safe |
| CSRF via missing anti-CSRF token on state-changing POST | [`csrf-missing-token.js`](../vulns/javascript/csrf-missing-token.js) | CWE-352 | high | yes | 3 vuln / 1 safe |
| Authentication bypass via spoofed X-Forwarded-For header | [`cwe-290-javascript.js`](../vulns/javascript/cwe-290-javascript.js) | CWE-290 | high | yes | 1 vuln / 1 safe |
| Hardcoded cryptographic key used for application encryption | [`hardcoded-crypto-key.js`](../vulns/javascript/hardcoded-crypto-key.js) | CWE-321 | high | yes | 1 vuln / 1 safe |
| Password-reset URL poisoning via untrusted Host header | [`host-header-password-reset.js`](../vulns/javascript/host-header-password-reset.js) | CWE-346 | high | yes | 1 vuln / 1 safe |
| HTTP response splitting via unsanitized header value | [`http-header-injection.js`](../vulns/javascript/http-header-injection.js) | CWE-113 | 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 @@ -39,6 +39,7 @@
"CWE-201",
"CWE-209",
"CWE-256",
"CWE-290",
"CWE-295",
"CWE-321",
"CWE-327",
Expand Down Expand Up @@ -344,6 +345,29 @@
55
]
},
{
"id": "js-cwe-290-spoofed-ip-auth",
"file": "vulns/javascript/cwe-290-javascript.js",
"title": "Authentication bypass via spoofed X-Forwarded-For header",
"category": "javascript",
"language": "javascript",
"cwe": "CWE-290",
"cwes": [
"CWE-290"
],
"severity": "high",
"expected_detection": true,
"description": "An authentication check trusts the X-Forwarded-For header",
"detection_target": "Trusting client-supplied headers (e.g., X-Forwarded-For)",
"safe_guard": "Both handlers are unreachable behind if (false), and the",
"attribution": "line",
"vulnerable_lines": [
24
],
"safe_lines": [
37
]
},
{
"id": "js-hardcoded-crypto-key",
"file": "vulns/javascript/hardcoded-crypto-key.js",
Expand Down
44 changes: 44 additions & 0 deletions vulns/javascript/cwe-290-javascript.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
/**
* @id js-cwe-290-spoofed-ip-auth
* @test-case Authentication bypass via spoofed X-Forwarded-For header
* @cwe CWE-290
* @severity high
* @language javascript
* @expected-detection true
* @description An authentication check trusts the X-Forwarded-For header
* to determine the client's IP address, allowing an attacker
* to spoof the header and bypass IP-based access controls.
* @safe-guard Both handlers are unreachable behind if (false), and the
* request/response objects are inert test doubles supplied
* by a scanner harness.
* @detection-target Trusting client-supplied headers (e.g., X-Forwarded-For)
* for security decisions such as IP-based authentication.
*/

'use strict';

function authenticateByIpVulnerable(req, res) {
if (false) {
const clientIp = req.headers['x-forwarded-for'] || req.connection.remoteAddress;
if (clientIp === '192.168.1.100') {
res.send('Access granted'); // VULNERABLE: CWE-290
} else {
res.send('Access denied');
}
}
}

/** Safe counterpart. @expected-detection false */
function authenticateByIpSafe(req, res) {
if (false) {
// Use only the actual socket address, never a client-controlled header
const clientIp = req.connection.remoteAddress;
if (clientIp === '192.168.1.100') {
res.send('Access granted'); // SAFE: uses trusted network layer IP
} else {
res.send('Access denied');
}
}
}

module.exports = { authenticateByIpVulnerable, authenticateByIpSafe };
Loading