@profullstack/threatcrush 0.6.1 → 0.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/daemon.js +84 -0
- package/dist/daemon.js.map +1 -1
- package/dist/index.js +86 -1
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/daemon.js
CHANGED
|
@@ -5099,6 +5099,90 @@ var CODE_RULES = [
|
|
|
5099
5099
|
languages: ["php"],
|
|
5100
5100
|
pattern: /\bextract\s*\(\s*\$_(?:GET|POST|REQUEST|COOKIE)\b|\bimport_request_variables\s*\(/,
|
|
5101
5101
|
guard: false
|
|
5102
|
+
},
|
|
5103
|
+
// ── Java and Go: classes the other languages already had ─────────────────
|
|
5104
|
+
//
|
|
5105
|
+
// Command injection, SSRF and path traversal were implemented for JavaScript
|
|
5106
|
+
// and, in part, for Go, and never for Java — so the same defect in the same
|
|
5107
|
+
// codebase was reported or not depending on which file it lived in. TLS
|
|
5108
|
+
// verification, weak hashing and insecure randomness are deliberately absent
|
|
5109
|
+
// here: `tls-verification-disabled`, `weak-hash-on-credential` and
|
|
5110
|
+
// `insecure-randomness-for-secret` are language-agnostic and already cover
|
|
5111
|
+
// both, including Go's `InsecureSkipVerify` and Java's `MessageDigest`.
|
|
5112
|
+
{
|
|
5113
|
+
id: "java-runtime-exec-concatenation",
|
|
5114
|
+
title: "Runtime.exec with a concatenated command",
|
|
5115
|
+
consequence: "The single-string form of `exec` is split on whitespace and handed to the OS. A value carrying a space becomes extra arguments, and where a shell is invoked, `;` and `$(\u2026)` become extra commands.",
|
|
5116
|
+
cwe: "CWE-78",
|
|
5117
|
+
severity: "critical",
|
|
5118
|
+
languages: ["java"],
|
|
5119
|
+
// The array form — `exec(new String[]{"git", arg})` — passes argv and is
|
|
5120
|
+
// the fix, so it is not matched: the `+` has to be inside the string
|
|
5121
|
+
// argument for this to fire.
|
|
5122
|
+
pattern: /\b(?:Runtime\s*\.\s*getRuntime\s*\(\s*\)\s*\.\s*exec|ProcessBuilder)\s*\(\s*(?:"[^"\n]*"\s*\+|\w+\s*\+\s*")/
|
|
5123
|
+
},
|
|
5124
|
+
{
|
|
5125
|
+
id: "java-ssrf-outbound-request",
|
|
5126
|
+
title: "outbound request to a computed URL",
|
|
5127
|
+
consequence: "The destination is chosen by the caller, so the request can be aimed at internal services and cloud metadata endpoints that are reachable from this host and from nowhere else.",
|
|
5128
|
+
cwe: "CWE-918",
|
|
5129
|
+
severity: "high",
|
|
5130
|
+
languages: ["java"],
|
|
5131
|
+
pattern: /\bnew\s+URL\s*\(\s*(?!\s*"[a-z]+:\/\/[^"\n]*"\s*\))[^)\n]*\w|\bHttpRequest\s*\.\s*newBuilder\s*\(\s*\)\s*\.\s*uri\s*\(\s*URI\s*\.\s*create\s*\(\s*[^"\n)]/,
|
|
5132
|
+
needsContext: true
|
|
5133
|
+
},
|
|
5134
|
+
{
|
|
5135
|
+
id: "java-request-path-traversal",
|
|
5136
|
+
title: "file path built from request data",
|
|
5137
|
+
consequence: "A `../` sequence in the value walks out of the intended directory. The process then reads or writes wherever it lands, with its own privileges.",
|
|
5138
|
+
cwe: "CWE-22",
|
|
5139
|
+
severity: "high",
|
|
5140
|
+
languages: ["java"],
|
|
5141
|
+
pattern: /\b(?:new\s+File|new\s+FileInputStream|new\s+FileOutputStream|Paths\s*\.\s*get|Files\s*\.\s*(?:readAllBytes|newInputStream|newOutputStream|copy|delete))\s*\([^)\n]*\+/,
|
|
5142
|
+
// `getCanonicalPath().startsWith(base)` is the check that makes this safe,
|
|
5143
|
+
// and it is normally a line or two below the construction.
|
|
5144
|
+
guard: /getCanonicalPath|toRealPath|normalize\s*\(\s*\)|\bstartsWith\s*\(/,
|
|
5145
|
+
guardForward: 4,
|
|
5146
|
+
needsContext: true
|
|
5147
|
+
},
|
|
5148
|
+
{
|
|
5149
|
+
id: "java-broken-cipher",
|
|
5150
|
+
title: "broken cipher or ECB mode",
|
|
5151
|
+
consequence: "DES, RC2, RC4 and Blowfish are broken or too small to rely on. ECB encrypts identical plaintext blocks to identical ciphertext blocks, so structure in the data survives encryption and is readable straight off the ciphertext.",
|
|
5152
|
+
cwe: "CWE-327",
|
|
5153
|
+
severity: "high",
|
|
5154
|
+
languages: ["java"],
|
|
5155
|
+
// Bare `"AES"` is included: the JCE resolves it to `AES/ECB/PKCS5Padding`,
|
|
5156
|
+
// so the default is the mode this rule exists to catch.
|
|
5157
|
+
pattern: /\bCipher\s*\.\s*getInstance\s*\(\s*"(?:DES|DESede|RC2|RC4|ARCFOUR|Blowfish)(?:\/|")|\bCipher\s*\.\s*getInstance\s*\(\s*"[^"\n]*\/ECB\/|\bCipher\s*\.\s*getInstance\s*\(\s*"AES"\s*\)/,
|
|
5158
|
+
guard: false
|
|
5159
|
+
},
|
|
5160
|
+
{
|
|
5161
|
+
id: "go-request-path-traversal",
|
|
5162
|
+
title: "file path built from request data",
|
|
5163
|
+
consequence: "A `../` sequence in the value walks out of the intended directory, and the handler serves or writes whatever it reaches.",
|
|
5164
|
+
cwe: "CWE-22",
|
|
5165
|
+
severity: "high",
|
|
5166
|
+
languages: ["go"],
|
|
5167
|
+
pattern: /\b(?:os\s*\.\s*(?:Open|OpenFile|ReadFile|Create|Remove|WriteFile)|ioutil\s*\.\s*(?:ReadFile|WriteFile)|http\s*\.\s*ServeFile)\s*\([^)\n]*(?:r\s*\.\s*URL|FormValue|Query\s*\(\s*\)\s*\.\s*Get|mux\s*\.\s*Vars|\bfilepath\s*\.\s*Join\s*\([^)\n]*\w)/,
|
|
5168
|
+
// `filepath.Clean` alone does not bound the result to a directory, so it is
|
|
5169
|
+
// not a guard here — the containment check is.
|
|
5170
|
+
guard: /\bstrings\s*\.\s*HasPrefix\s*\(|\bfilepath\s*\.\s*Rel\s*\(|\bfs\s*\.\s*ValidPath\s*\(|\bhttp\s*\.\s*Dir\b/,
|
|
5171
|
+
guardBack: 5,
|
|
5172
|
+
guardForward: 3,
|
|
5173
|
+
needsContext: true
|
|
5174
|
+
},
|
|
5175
|
+
{
|
|
5176
|
+
id: "go-template-escaping-bypass",
|
|
5177
|
+
title: "value marked as pre-escaped HTML",
|
|
5178
|
+
consequence: "`template.HTML` tells `html/template` the value is already safe, which switches off the contextual escaping that makes the package worth using. Markup in the value reaches the page intact.",
|
|
5179
|
+
cwe: "CWE-79",
|
|
5180
|
+
severity: "high",
|
|
5181
|
+
languages: ["go"],
|
|
5182
|
+
// A conversion of a *variable*. `template.HTML("<br>")` on a literal is a
|
|
5183
|
+
// constant the author wrote and is not a finding.
|
|
5184
|
+
pattern: /\btemplate\s*\.\s*(?:HTML|JS|CSS|HTMLAttr|URL|Srcset)\s*\(\s*(?!\s*[`"])/,
|
|
5185
|
+
needsContext: true
|
|
5102
5186
|
}
|
|
5103
5187
|
];
|
|
5104
5188
|
var COMMENT_PREFIX = /^\s*(?:\/\/|\/\*|\*|#|--|<!--)/;
|