diff --git a/docs/VULNERABILITY_CATALOG.md b/docs/VULNERABILITY_CATALOG.md index 5763d34..c90b018 100644 --- a/docs/VULNERABILITY_CATALOG.md +++ b/docs/VULNERABILITY_CATALOG.md @@ -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-220, 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 @@ -27,6 +27,7 @@ counts as a detection. See `docs/SCANNER_INTEGRATION.md`. | Test case | File | CWE | Severity | Expected | Markers | |---|---|---|---|---|---| | OS command injection via exec.Command with a shell | [`cmd-injection-exec.go`](../vulns/go/cmd-injection-exec.go) | CWE-78 | critical | yes | 2 vuln / 1 safe | +| FTP credentials exposed via hardcoded connection string in source code | [`cwe-220-go.go`](../vulns/go/cwe-220-go.go) | CWE-220 | high | yes | 1 vuln / 1 safe | | Integer overflow and unchecked narrowing conversion | [`integer-overflow.go`](../vulns/go/integer-overflow.go) | CWE-190 | medium | yes | 2 vuln / 3 safe | | SQL injection via fmt.Sprintf | [`sqli-fmt-sprintf.go`](../vulns/go/sqli-fmt-sprintf.go) | CWE-89 | critical | yes | 2 vuln / 1 safe | | Server-side request forgery via http.Get on a user-supplied URL | [`ssrf-http-get.go`](../vulns/go/ssrf-http-get.go) | CWE-918 | high | yes | 2 vuln / 2 safe | diff --git a/vulns/VULNERABILITY_CATALOG.json b/vulns/VULNERABILITY_CATALOG.json index 153fdaf..f1295cb 100644 --- a/vulns/VULNERABILITY_CATALOG.json +++ b/vulns/VULNERABILITY_CATALOG.json @@ -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", @@ -38,6 +38,7 @@ "CWE-190", "CWE-201", "CWE-209", + "CWE-220", "CWE-256", "CWE-295", "CWE-321", @@ -99,6 +100,29 @@ 46 ] }, + { + "id": "go-cwe-220-ftp-credential-leak", + "file": "vulns/go/cwe-220-go.go", + "title": "FTP credentials exposed via hardcoded connection string in source code", + "category": "go", + "language": "go", + "cwe": "CWE-220", + "cwes": [ + "CWE-220" + ], + "severity": "high", + "expected_detection": true, + "description": "FTP credentials are hardcoded directly in the source code as part of a connection string. This exposes sensitive authentication data to anyone with access to the repository, violating CWE-220 (Exposure of Sensitive Information Through Data Queries). The credentials are embedded in a URL-like format that could be parsed by automated tools or human reviewers.", + "detection_target": "Hardcoded FTP credentials (username:password@host) in string literals or connection strings", + "safe_guard": "Guarded by the always-false `neverRun` constant plus an `ignore` build tag; no FTP connection is ever established.", + "attribution": "line", + "vulnerable_lines": [ + 24 + ], + "safe_lines": [ + 33 + ] + }, { "id": "go-integer-overflow", "file": "vulns/go/integer-overflow.go", diff --git a/vulns/go/cwe-220-go.go b/vulns/go/cwe-220-go.go new file mode 100644 index 0000000..f0adda2 --- /dev/null +++ b/vulns/go/cwe-220-go.go @@ -0,0 +1,43 @@ +// @id go-cwe-220-ftp-credential-leak +// @test-case FTP credentials exposed via hardcoded connection string in source code +// @cwe CWE-220 +// @severity high +// @language go +// @expected-detection true +// @description FTP credentials are hardcoded directly in the source code as part of a connection string. This exposes sensitive authentication data to anyone with access to the repository, violating CWE-220 (Exposure of Sensitive Information Through Data Queries). The credentials are embedded in a URL-like format that could be parsed by automated tools or human reviewers. +// @safe-guard Guarded by the always-false `neverRun` constant plus an `ignore` build tag; no FTP connection is ever established. +// @detection-target Hardcoded FTP credentials (username:password@host) in string literals or connection strings +// +// NEVER RUN IN PRODUCTION — intentional test case for scanner validation. + +//go:build ignore + +package vulns + +import ( + "net/http" + "strings" +) + +func ftpVulnerable(r *http.Request) string { + if neverRun { + // VULNERABLE: CWE-220 - hardcoded FTP credentials in connection string + ftpConn := "ftp://admin:SuperSecret123@ftp.example.com:21" + return ftpConn + } + return "" +} + +func ftpSafe(r *http.Request) string { + if neverRun { + // SAFE: credentials are read from environment variables, not hardcoded + user := os.Getenv("FTP_USER") + pass := os.Getenv("FTP_PASS") + host := os.Getenv("FTP_HOST") + if user == "" || pass == "" || host == "" { + return "" + } + return "ftp://" + user + ":" + pass + "@" + host + ":21" + } + return "" +} \ No newline at end of file