@code-sentinel-cli/code-sentinel-cli 4.0.6 → 4.0.7
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/bin.js +16204 -9882
- package/dist/builtin-rules/static/general/dockerfile-dependency-confusion.rule.js +27 -2
- package/dist/builtin-rules/static/general/java-weak-randomness.rule.js +41 -0
- package/dist/builtin-rules/static/general/kubernetes-pod-security.rule.js +90 -0
- package/dist/builtin-rules/static/general/no-dynamic-code-eval.rule.js +84 -0
- package/dist/builtin-rules/static/general/no-hardcoded-secret.rule.js +179 -13
- package/dist/builtin-rules/static/general/no-reflective-access-override.rule.js +6 -23
- package/dist/builtin-rules/static/general/no-unsafe-html-sink.rule.js +50 -7
- package/dist/builtin-rules/static/general/openapi-https-credentials.rule.js +90 -0
- package/dist/builtin-rules/static/general/sensitive-exception-response.rule.js +44 -0
- package/dist/builtin-rules/static/general/sensitive-output-exposure.rule.js +1 -1
- package/dist/builtin-rules/static/spring-boot/explicit-csp-required.rule.js +37 -0
- package/dist/builtin-rules/static/spring-boot/no-command-injection.rule.js +7 -1
- package/dist/builtin-rules/static/spring-boot/no-devtools-in-production.rule.js +13 -16
- package/dist/builtin-rules/static/spring-boot/no-global-permit-all.rule.js +50 -0
- package/dist/builtin-rules/static/spring-boot/no-negative-sensitive-input.rule.js +91 -0
- package/dist/builtin-rules/static/spring-boot/no-path-traversal.rule.js +7 -1
- package/dist/builtin-rules/static/spring-boot/no-servlet-xss.rule.js +7 -1
- package/dist/builtin-rules/static/spring-boot/no-spel-injection.rule.js +7 -1
- package/dist/builtin-rules/static/spring-boot/no-sql-string-concat.rule.js +7 -1
- package/dist/builtin-rules/static/spring-boot/no-ssrf.rule.js +23 -3
- package/dist/builtin-rules/static/spring-boot/password-reset-without-proof.rule.js +84 -0
- package/dist/builtin-rules/static/spring-boot/stored-content-without-sanitization.rule.js +93 -0
- package/dist/index.d.ts +154 -18
- package/dist/index.js +16204 -9882
- package/node_modules/@code-sentinel/parsers/index.js +330 -198
- package/package.json +1 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { maskJsComments } from '@code-sentinel/parsers';
|
|
1
|
+
import { isThirdPartyAsset, maskJsComments } from '@code-sentinel/parsers';
|
|
2
2
|
|
|
3
3
|
// builtin-rules/static/general/no-unsafe-html-sink.rule.ts
|
|
4
4
|
var JQUERY_HTML_RE = /(?:\$|jQuery)\s*\([^\n)]{1,240}\)\s*\.\s*html\s*\(\s*([^;\n)]{1,240})\s*\)/g;
|
|
@@ -13,6 +13,20 @@ var isSafeStaticValue = (value) => {
|
|
|
13
13
|
const trimmed = value.trim();
|
|
14
14
|
return STATIC_LITERAL_RE.test(trimmed) || ENCODED_VALUE_RE.test(trimmed);
|
|
15
15
|
};
|
|
16
|
+
var statementRhs = (content, start) => {
|
|
17
|
+
for (let i = start; i < content.length; i++) {
|
|
18
|
+
const ch = content[i];
|
|
19
|
+
if (ch === "'" || ch === '"' || ch === "`") {
|
|
20
|
+
for (i++; i < content.length && content[i] !== ch; i++) {
|
|
21
|
+
if (content[i] === "\\") i++;
|
|
22
|
+
else if (content[i] === "\n" && ch !== "`") return null;
|
|
23
|
+
}
|
|
24
|
+
continue;
|
|
25
|
+
}
|
|
26
|
+
if (ch === ";" || ch === "\n") return content.slice(start, i).trim();
|
|
27
|
+
}
|
|
28
|
+
return content.slice(start).trim();
|
|
29
|
+
};
|
|
16
30
|
var matches = (content) => {
|
|
17
31
|
const found = [];
|
|
18
32
|
const add = (api, value, index) => {
|
|
@@ -22,8 +36,12 @@ var matches = (content) => {
|
|
|
22
36
|
JQUERY_HTML_RE.lastIndex = 0;
|
|
23
37
|
for (const match of content.matchAll(JQUERY_HTML_RE)) add("jQuery.html()", match[1], match.index);
|
|
24
38
|
INNER_HTML_RE.lastIndex = 0;
|
|
25
|
-
for (const match of content.matchAll(INNER_HTML_RE))
|
|
26
|
-
|
|
39
|
+
for (const match of content.matchAll(INNER_HTML_RE)) {
|
|
40
|
+
const valueStart = match.index + match[0].length - (match[2]?.length ?? 0);
|
|
41
|
+
const whole = statementRhs(content, valueStart);
|
|
42
|
+
const value = whole !== null && isSafeStaticValue(whole) ? whole : match[2];
|
|
43
|
+
add(`${match[1] ?? "innerHTML"} assignment`, value, match.index);
|
|
44
|
+
}
|
|
27
45
|
INSERT_ADJACENT_HTML_RE.lastIndex = 0;
|
|
28
46
|
for (const match of content.matchAll(INSERT_ADJACENT_HTML_RE))
|
|
29
47
|
add("insertAdjacentHTML()", match[1], match.index);
|
|
@@ -32,12 +50,32 @@ var matches = (content) => {
|
|
|
32
50
|
add(`document.${match[1] ?? "write"}()`, match[2], match.index);
|
|
33
51
|
return found.sort((a, b) => a.index - b.index);
|
|
34
52
|
};
|
|
53
|
+
var V_HTML_RE = /\bv-html\s*=\s*(?:"([^"]*)"|'([^']*)')/g;
|
|
54
|
+
var QUOTED = String.raw`(?:'(?:[^'\\]|\\.)*'|"(?:[^"\\]|\\.)*"|\x60[^\x60$]*\x60)`;
|
|
55
|
+
var LITERAL_TERNARY_RE = new RegExp(String.raw`^[^?]+\?\s*${QUOTED}\s*:\s*${QUOTED}$`);
|
|
56
|
+
var LITERAL_RE = new RegExp(`^${QUOTED}$`);
|
|
57
|
+
var VUE_SAFE_RE = /sanitiz|dompurify|escapehtml|htmlencode|encodehtml|<|^\$t\(|^\$i18n\b/i;
|
|
58
|
+
var isSafeVHtmlValue = (value) => {
|
|
59
|
+
const v = value.trim();
|
|
60
|
+
return v === "" || LITERAL_RE.test(v) || LITERAL_TERNARY_RE.test(v) || VUE_SAFE_RE.test(v);
|
|
61
|
+
};
|
|
62
|
+
var vHtmlMatches = (template) => {
|
|
63
|
+
const masked = template.replace(HTML_COMMENT_RE, (comment) => comment.replace(/[^\n]/g, " "));
|
|
64
|
+
const found = [];
|
|
65
|
+
V_HTML_RE.lastIndex = 0;
|
|
66
|
+
for (const match of masked.matchAll(V_HTML_RE)) {
|
|
67
|
+
const value = match[1] ?? match[2] ?? "";
|
|
68
|
+
if (isSafeVHtmlValue(value)) continue;
|
|
69
|
+
found.push({ api: "v-html", value: value.trim(), index: match.index });
|
|
70
|
+
}
|
|
71
|
+
return found;
|
|
72
|
+
};
|
|
35
73
|
var rule = {
|
|
36
74
|
id: "general/no-unsafe-html-sink",
|
|
37
|
-
version:
|
|
75
|
+
version: 4,
|
|
38
76
|
kind: "static-ts",
|
|
39
77
|
title: "Kh\xF4ng \u0111\u01B0a gi\xE1 tr\u1ECB \u0111\u1ED9ng v\xE0o HTML sink kh\xF4ng \u0111\u01B0\u1EE3c encode",
|
|
40
|
-
description: "Ph\xE1t hi\u1EC7n jQuery.html(), innerHTML/outerHTML, insertAdjacentHTML()
|
|
78
|
+
description: "Ph\xE1t hi\u1EC7n jQuery.html(), innerHTML/outerHTML, insertAdjacentHTML(), document.write() v\xE0 v-html c\u1EE7a Vue nh\u1EADn gi\xE1 tr\u1ECB \u0111\u1ED9ng. \u0110\xE2y l\xE0 HTML Injection; n\u1EBFu gi\xE1 tr\u1ECB \u0111\u01B0\u1EE3c l\u01B0u v\xE0 hi\u1EC3n th\u1ECB l\u1EA1i th\xEC c\xF3 th\u1EC3 l\xE0 Stored XSS.",
|
|
41
79
|
severity: "warning",
|
|
42
80
|
category: "security",
|
|
43
81
|
languages: ["typescript", "javascript", "html"],
|
|
@@ -46,16 +84,21 @@ var rule = {
|
|
|
46
84
|
usesParser: false,
|
|
47
85
|
baseConfidence: 80,
|
|
48
86
|
check(ctx) {
|
|
87
|
+
if (isThirdPartyAsset(ctx.file.path, ctx.file.content)) return [];
|
|
49
88
|
const content = maskJsComments(ctx.file.content).replace(
|
|
50
89
|
HTML_COMMENT_RE,
|
|
51
90
|
(comment) => comment.replace(/[^\n]/g, " ")
|
|
52
91
|
);
|
|
53
|
-
|
|
92
|
+
const template = ctx.file.vueTemplate;
|
|
93
|
+
const all = [...matches(content), ...template ? vHtmlMatches(template) : []].sort(
|
|
94
|
+
(a, b) => a.index - b.index
|
|
95
|
+
);
|
|
96
|
+
return all.map((match) => ({
|
|
54
97
|
file: ctx.file.path,
|
|
55
98
|
range: { line: lineOf(content, match.index), column: 1 },
|
|
56
99
|
confidence: 80,
|
|
57
100
|
message: `${match.api} nh\u1EADn gi\xE1 tr\u1ECB \u0111\u1ED9ng \`${match.value}\` v\xE0 \u0111\u01B0a th\u1EB3ng v\xE0o DOM (HTML Injection; c\xF3 th\u1EC3 l\xE0 Stored XSS n\u1EBFu d\u1EEF li\u1EC7u \u0111\u01B0\u1EE3c l\u01B0u r\u1ED3i render l\u1EA1i).`,
|
|
58
|
-
suggestion: "D\xF9ng textContent/jQuery.text()/Angular interpolation \u0111\u1EC3 hi\u1EC3n th\u1ECB text. N\u1EBFu nghi\u1EC7p v\u1EE5 b\u1EAFt bu\u1ED9c HTML, sanitize b\u1EB1ng allowlist \u0111\xE1ng tin c\u1EADy tr\u01B0\u1EDBc khi render; ki\u1EC3m th\u1EED lu\u1ED3ng t\u1EA1o/s\u1EEDa \u2192 l\u01B0u \u2192 m\u1EDF l\u1EA1i b\u1EB1ng ng\u01B0\u1EDDi d\xF9ng kh\xE1c \u0111\u1EC3 x\xE1c nh\u1EADn ho\u1EB7c lo\u1EA1i tr\u1EEB Stored XSS."
|
|
101
|
+
suggestion: (match.api === "v-html" ? "D\xF9ng n\u1ED9i suy {{ }} c\u1EE7a Vue (t\u1EF1 escape) \u0111\u1EC3 hi\u1EC3n th\u1ECB text." : "D\xF9ng textContent/jQuery.text()/Angular interpolation \u0111\u1EC3 hi\u1EC3n th\u1ECB text.") + " N\u1EBFu nghi\u1EC7p v\u1EE5 b\u1EAFt bu\u1ED9c HTML, sanitize b\u1EB1ng allowlist \u0111\xE1ng tin c\u1EADy tr\u01B0\u1EDBc khi render; ki\u1EC3m th\u1EED lu\u1ED3ng t\u1EA1o/s\u1EEDa \u2192 l\u01B0u \u2192 m\u1EDF l\u1EA1i b\u1EB1ng ng\u01B0\u1EDDi d\xF9ng kh\xE1c \u0111\u1EC3 x\xE1c nh\u1EADn ho\u1EB7c lo\u1EA1i tr\u1EEB Stored XSS."
|
|
59
102
|
}));
|
|
60
103
|
}
|
|
61
104
|
};
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import { parseAllDocuments } from 'yaml';
|
|
2
|
+
|
|
3
|
+
// builtin-rules/static/general/infrastructure-config-audit.ts
|
|
4
|
+
var record = (value) => typeof value === "object" && value !== null && !Array.isArray(value) ? value : null;
|
|
5
|
+
var list = (value) => Array.isArray(value) ? value : [];
|
|
6
|
+
var auditInfrastructureConfig = (content) => {
|
|
7
|
+
const signals = [];
|
|
8
|
+
for (const doc of parseAllDocuments(content)) {
|
|
9
|
+
if (doc.errors.length) continue;
|
|
10
|
+
let root;
|
|
11
|
+
try {
|
|
12
|
+
root = record(doc.toJS());
|
|
13
|
+
} catch {
|
|
14
|
+
continue;
|
|
15
|
+
}
|
|
16
|
+
if (!root) continue;
|
|
17
|
+
const line = content.slice(0, doc.range?.[0] ?? 0).split("\n").length;
|
|
18
|
+
const spec = record(root.spec);
|
|
19
|
+
const workload = ["Deployment", "StatefulSet", "DaemonSet", "Job", "ReplicaSet"].includes(
|
|
20
|
+
String(root.kind)
|
|
21
|
+
);
|
|
22
|
+
const pod = root.kind === "Pod" ? spec : workload ? record(record(spec?.template)?.spec) : root.kind === "CronJob" ? record(record(record(record(spec?.jobTemplate)?.spec)?.template)?.spec) : null;
|
|
23
|
+
if (pod && list(pod.containers).length) {
|
|
24
|
+
const podProfile = record(record(pod.securityContext)?.seccompProfile);
|
|
25
|
+
const unconstrained = [...list(pod.containers), ...list(pod.initContainers)].some(
|
|
26
|
+
(container) => {
|
|
27
|
+
const profile = record(record(record(container)?.securityContext)?.seccompProfile) ?? podProfile;
|
|
28
|
+
return !(profile?.type === "RuntimeDefault" || profile?.type === "Localhost" && typeof profile.localhostProfile === "string" && profile.localhostProfile.length > 0);
|
|
29
|
+
}
|
|
30
|
+
);
|
|
31
|
+
if (unconstrained) signals.push({ line, control: "k8s-seccomp" });
|
|
32
|
+
if (pod.automountServiceAccountToken !== false)
|
|
33
|
+
signals.push({ line, control: "k8s-token-automount" });
|
|
34
|
+
}
|
|
35
|
+
if (typeof root.openapi === "string") {
|
|
36
|
+
const paths = record(root.paths);
|
|
37
|
+
let exposed = false;
|
|
38
|
+
for (const path of Object.values(paths ?? {})) {
|
|
39
|
+
const pathItem = record(path);
|
|
40
|
+
for (const method of [
|
|
41
|
+
"get",
|
|
42
|
+
"post",
|
|
43
|
+
"put",
|
|
44
|
+
"patch",
|
|
45
|
+
"delete",
|
|
46
|
+
"head",
|
|
47
|
+
"options",
|
|
48
|
+
"trace"
|
|
49
|
+
]) {
|
|
50
|
+
const operation = record(pathItem?.[method]);
|
|
51
|
+
if (!operation) continue;
|
|
52
|
+
const security = operation.security ?? root.security;
|
|
53
|
+
const authenticated = list(security).some(
|
|
54
|
+
(entry) => Object.keys(record(entry) ?? {}).length > 0
|
|
55
|
+
);
|
|
56
|
+
const servers = operation.servers ?? pathItem?.servers ?? root.servers;
|
|
57
|
+
if (authenticated && list(servers).some((server) => /^http:\/\//i.test(String(record(server)?.url ?? ""))))
|
|
58
|
+
exposed = true;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
if (exposed) signals.push({ line, control: "openapi-http-credentials" });
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
return signals;
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
// builtin-rules/static/general/openapi-https-credentials.rule.ts
|
|
68
|
+
var rule = {
|
|
69
|
+
id: "general/openapi-https-credentials",
|
|
70
|
+
version: 1,
|
|
71
|
+
kind: "static-ts",
|
|
72
|
+
title: "OpenAPI trao \u0111\u1ED5i credential qua HTTPS",
|
|
73
|
+
severity: "warning",
|
|
74
|
+
category: "security",
|
|
75
|
+
languages: ["yaml"],
|
|
76
|
+
scope: "general",
|
|
77
|
+
usesParser: false,
|
|
78
|
+
baseConfidence: 80,
|
|
79
|
+
check: (ctx) => auditInfrastructureConfig(ctx.file.content).filter((signal) => signal.control === "openapi-http-credentials").map((signal) => ({
|
|
80
|
+
file: ctx.file.path,
|
|
81
|
+
range: { line: signal.line, column: 1 },
|
|
82
|
+
confidence: 80,
|
|
83
|
+
message: "An authenticated OpenAPI operation inherits or declares an HTTP server. This is a source contract finding, not proof of deployed transport. [control=openapi-http-credentials]",
|
|
84
|
+
suggestion: "Use HTTPS for credential-bearing operations and verify effective operation/path/global servers and security overrides."
|
|
85
|
+
}))
|
|
86
|
+
};
|
|
87
|
+
|
|
88
|
+
export { rule };
|
|
89
|
+
//# sourceMappingURL=openapi-https-credentials.rule.js.map
|
|
90
|
+
//# sourceMappingURL=openapi-https-credentials.rule.js.map
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { maskJavaFiles } from '@code-sentinel/parsers';
|
|
2
|
+
|
|
3
|
+
// builtin-rules/static/general/sensitive-exception-response.rule.ts
|
|
4
|
+
var SENSITIVE = /password|passwd|secret|token|credential|\bpin\b|\botp\b|get(?:Localized)?Message\s*\(|getStackTrace\s*\(/i;
|
|
5
|
+
var rule = {
|
|
6
|
+
id: "general/sensitive-exception-response",
|
|
7
|
+
version: 1,
|
|
8
|
+
kind: "static-ts",
|
|
9
|
+
title: "Ki\u1EC3m tra th\xF4ng tin nh\u1EA1y c\u1EA3m qua exception/response",
|
|
10
|
+
severity: "warning",
|
|
11
|
+
category: "security",
|
|
12
|
+
languages: ["java"],
|
|
13
|
+
scope: "general",
|
|
14
|
+
usesParser: false,
|
|
15
|
+
baseConfidence: 65,
|
|
16
|
+
check: (ctx) => {
|
|
17
|
+
const masked = maskJavaFiles([ctx.file])[0]?.content ?? ctx.file.content;
|
|
18
|
+
const source = masked.replace(
|
|
19
|
+
/"(?:[^"\\]|\\.)*"/g,
|
|
20
|
+
(literal) => literal.replace(/[^\r\n]/g, " ")
|
|
21
|
+
);
|
|
22
|
+
const sinks = /\bthrow\s+new\s+[\w$.]*Exception\s*\((\s*)([^;]*?)\)\s*;|\bResponseEntity\s*\.\s*[^;\n]*?\bbody\s*\((\s*)([^;]*?)\)\s*;/g;
|
|
23
|
+
return [...source.matchAll(sinks)].flatMap((match) => {
|
|
24
|
+
const argument = match[2] ?? match[4] ?? "";
|
|
25
|
+
if (!SENSITIVE.test(argument)) return [];
|
|
26
|
+
const metadataOnly = /^\s*(?:[\w$.]+\.)?[A-Z][A-Z_0-9]+(?:\s*,\s*\w+)*\s*$/.test(argument);
|
|
27
|
+
const argumentStart = (match.index ?? 0) + match[0].indexOf(argument);
|
|
28
|
+
return [
|
|
29
|
+
{
|
|
30
|
+
file: ctx.file.path,
|
|
31
|
+
range: { line: source.slice(0, argumentStart).split("\n").length, column: 1 },
|
|
32
|
+
confidence: metadataOnly ? 40 : 65,
|
|
33
|
+
severity: metadataOnly ? "info" : "warning",
|
|
34
|
+
message: metadataOnly ? "Sensitive validation/error metadata reaches an exception sink; review HTTP mapping and enumeration risk. No raw credential disclosure is proven. [control=sensitive-error-metadata]" : "Sensitive value or exception detail reaches an exception/response sink; inspect serialization and HTTP exposure. [control=sensitive-exception-value]",
|
|
35
|
+
suggestion: "Verify the global exception handler and response body; redact sensitive values and assess whether error distinctions reveal protected information."
|
|
36
|
+
}
|
|
37
|
+
];
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
export { rule };
|
|
43
|
+
//# sourceMappingURL=sensitive-exception-response.rule.js.map
|
|
44
|
+
//# sourceMappingURL=sensitive-exception-response.rule.js.map
|
|
@@ -3,7 +3,7 @@ import { findSensitiveOutput } from '@code-sentinel/parsers';
|
|
|
3
3
|
// builtin-rules/static/general/sensitive-output-exposure.rule.ts
|
|
4
4
|
var rule = {
|
|
5
5
|
id: "general/sensitive-output-exposure",
|
|
6
|
-
version:
|
|
6
|
+
version: 2,
|
|
7
7
|
kind: "static-ts",
|
|
8
8
|
title: "Kh\xF4ng ghi d\u1EEF li\u1EC7u nh\u1EA1y c\u1EA3m ra log ho\u1EB7c console",
|
|
9
9
|
description: "Ph\xE1t hi\u1EC7n password/token/secret/PII b\u1ECB \u0111\u01B0a v\xE0o Java logger, System.out/System.err, ho\u1EB7c browser console. D\xF9ng c\xF9ng b\u1EB1ng ch\u1EE9ng v\u1EDBi `cs assess` checklist #83 (CWE-532).",
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { maskJavaFiles } from '@code-sentinel/parsers';
|
|
2
|
+
|
|
3
|
+
// builtin-rules/static/spring-boot/explicit-csp-required.rule.ts
|
|
4
|
+
var SECURITY_CONFIG = /@EnableWebSecurity\b|\bSecurityFilterChain\b|extends\s+WebSecurityConfigurerAdapter\b/;
|
|
5
|
+
var CSP = /\bcontentSecurityPolicy\s*\(|["']Content-Security-Policy["']/i;
|
|
6
|
+
var rule = {
|
|
7
|
+
id: "spring-boot/explicit-csp-required",
|
|
8
|
+
version: 1,
|
|
9
|
+
kind: "static-ts",
|
|
10
|
+
title: "Spring Security c\u1EA7n CSP t\u01B0\u1EDDng minh",
|
|
11
|
+
description: "Spring Security kh\xF4ng th\xEAm Content-Security-Policy m\u1EB7c \u0111\u1ECBnh. C\u1EA3nh b\xE1o khi source c\xF3 SecurityFilterChain nh\u01B0ng kh\xF4ng khai b\xE1o CSP.",
|
|
12
|
+
severity: "warning",
|
|
13
|
+
category: "security",
|
|
14
|
+
languages: ["java"],
|
|
15
|
+
scope: "spring-boot",
|
|
16
|
+
requires: "text",
|
|
17
|
+
usesParser: false,
|
|
18
|
+
baseConfidence: 80,
|
|
19
|
+
check(ctx) {
|
|
20
|
+
const source = maskJavaFiles([ctx.file])[0]?.content ?? ctx.file.content;
|
|
21
|
+
if (!SECURITY_CONFIG.test(source) || CSP.test(source)) return [];
|
|
22
|
+
const index = source.search(SECURITY_CONFIG);
|
|
23
|
+
return [
|
|
24
|
+
{
|
|
25
|
+
file: ctx.file.path,
|
|
26
|
+
range: { line: source.slice(0, index).split("\n").length, column: 1 },
|
|
27
|
+
confidence: 80,
|
|
28
|
+
message: "Spring Security config kh\xF4ng khai b\xE1o Content-Security-Policy; CSP kh\xF4ng n\u1EB1m trong default header c\u1EE7a Spring. [control=missing-explicit-csp]",
|
|
29
|
+
suggestion: "Khai b\xE1o contentSecurityPolicy(...) v\u1EDBi policy ph\xF9 h\u1EE3p. N\u1EBFu CSP do gateway/reverse-proxy \u0111\u1EB7t, suppress finding v\xE0 d\u1EABn chi\u1EBFu c\u1EA5u h\xECnh/runtime probe."
|
|
30
|
+
}
|
|
31
|
+
];
|
|
32
|
+
}
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
export { rule };
|
|
36
|
+
//# sourceMappingURL=explicit-csp-required.rule.js.map
|
|
37
|
+
//# sourceMappingURL=explicit-csp-required.rule.js.map
|
|
@@ -18,7 +18,13 @@ var rule = {
|
|
|
18
18
|
// rule's projection logic is unchanged; the bump invalidates findings cached on
|
|
19
19
|
// unchanged file content before the broader analyzer coverage.
|
|
20
20
|
// v5 (ADR-0065 calibration): luồng taint trực tiếp → severity blocker
|
|
21
|
-
|
|
21
|
+
// v6 (D1 — JAX-RS taint sources): no rule-logic change. The Java analyzer
|
|
22
|
+
// gained 8 `jaxrs/*` parameter sources (`@QueryParam`/`@FormParam`/…, javax +
|
|
23
|
+
// jakarta) and seeds a bare impl param from the annotation on the interface
|
|
24
|
+
// method it overrides. The rule cache key is `(id, version, file.hash)`, so a
|
|
25
|
+
// taint-table change alone does NOT rotate it — without this bump a warm cache
|
|
26
|
+
// keeps serving the pre-D1 result (measured: 1 vs 10 SSRF on the same module).
|
|
27
|
+
version: 6,
|
|
22
28
|
kind: "static-ts",
|
|
23
29
|
title: "Kh\xF4ng ch\u1EA1y l\u1EC7nh h\u1EC7 th\u1ED1ng t\u1EEB d\u1EEF li\u1EC7u ch\u01B0a ki\u1EC3m so\xE1t (OS Command Injection)",
|
|
24
30
|
description: "D\u1EEF li\u1EC7u t\u1EEB request (@RequestParam, @PathVariable, @RequestBody, @RequestHeader, HttpServletRequest, \u2026) ch\u1EA3y th\u1EB3ng v\xE0o l\u1EC7nh h\u1EC7 \u0111i\u1EC1u h\xE0nh (`Runtime.getRuntime().exec(...)` ho\u1EB7c `ProcessBuilder.command(...)`) l\xE0 l\u1ED7 h\u1ED5ng OS Command Injection (CWE-78) \u2014 k\u1EBB t\u1EA5n c\xF4ng ch\xE8n \u0111\u01B0\u1EE3c l\u1EC7nh shell t\xF9y \xFD ch\u1EA1y tr\xEAn server (RCE). Rule d\xF9ng taint analysis (Tier-1 li\xEAn th\u1EE7 t\u1EE5c trong c\xF9ng method) \u0111\u1EC3 truy v\u1EBFt lu\u1ED3ng d\u1EEF li\u1EC7u. Kh\u1EAFc ph\u1EE5c: tr\xE1nh g\u1ECDi shell; n\u1EBFu b\u1EAFt bu\u1ED9c, d\xF9ng allowlist l\u1EC7nh/tham s\u1ED1 c\u1ED1 \u0111\u1ECBnh v\xE0 truy\u1EC1n d\u1EA1ng m\u1EA3ng tham s\u1ED1 (kh\xF4ng n\u1ED1i chu\u1ED7i v\xE0o `sh -c`), kh\xF4ng bao gi\u1EDD d\u1EF1ng l\u1EC7nh t\u1EEB gi\xE1 tr\u1ECB do ng\u01B0\u1EDDi d\xF9ng nh\u1EADp.",
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import { DEVTOOLS_BUILD_FILE_RE,
|
|
1
|
+
import { DEVTOOLS_BUILD_FILE_RE, findDevToolsDeclarations } from '@code-sentinel/parsers';
|
|
2
2
|
|
|
3
3
|
// builtin-rules/static/spring-boot/no-devtools-in-production.rule.ts
|
|
4
4
|
var rule = {
|
|
5
5
|
id: "spring-boot/no-devtools-in-production",
|
|
6
|
-
version:
|
|
6
|
+
version: 4,
|
|
7
7
|
kind: "static-ts",
|
|
8
|
-
title: "
|
|
9
|
-
description: "
|
|
8
|
+
title: "Ki\u1EC3m tra DevTools trong c\u1EA5u h\xECnh build v\xE0 s\u1EA3n ph\u1EA9m production (CWE-489)",
|
|
9
|
+
description: "Ki\u1EC3m tra dependency spring-boot-devtools. Profile pentest ghi nh\u1EADn c\u1EA3 optional/developmentOnly \u0111\u1EC3 review profile build, JAR/WAR v\xE0 runtime; khai b\xE1o dependency ch\u01B0a ch\u1EE9ng minh DevTools \u0111ang b\u1EADt production.",
|
|
10
10
|
severity: "error",
|
|
11
11
|
category: "security",
|
|
12
12
|
languages: ["xml", "text"],
|
|
@@ -14,21 +14,18 @@ var rule = {
|
|
|
14
14
|
requires: "text",
|
|
15
15
|
usesParser: false,
|
|
16
16
|
baseConfidence: 90,
|
|
17
|
+
defaultOptions: { reportDeclaredDependency: true },
|
|
17
18
|
check(ctx) {
|
|
18
19
|
const file = ctx.file;
|
|
19
20
|
if (!DEVTOOLS_BUILD_FILE_RE.test(file.path)) return [];
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
confidence: 90,
|
|
29
|
-
suggestion: file.path.toLowerCase().endsWith("pom.xml") ? "Th\xEAm '<optional>true</optional>' v\xE0o b\xEAn trong kh\u1ED1i <dependency> c\u1EE7a spring-boot-devtools." : "Chuy\u1EC3n c\u1EA5u h\xECnh t\u1EEB 'implementation' / 'compileOnly' sang 'developmentOnly' (v\xED d\u1EE5: developmentOnly 'org.springframework.boot:spring-boot-devtools')."
|
|
30
|
-
}
|
|
31
|
-
];
|
|
21
|
+
return findDevToolsDeclarations(file.content, file.path).filter((finding) => finding.isVulnerable || ctx.options.reportDeclaredDependency).map((finding) => ({
|
|
22
|
+
file: finding.file,
|
|
23
|
+
range: { line: finding.line, column: 1 },
|
|
24
|
+
severity: finding.isVulnerable ? "error" : "warning",
|
|
25
|
+
confidence: finding.isVulnerable ? 90 : 60,
|
|
26
|
+
message: finding.reason,
|
|
27
|
+
suggestion: "Inspect the production build profile, packaged JAR/WAR and runtime configuration; verify DevTools is excluded/disabled."
|
|
28
|
+
}));
|
|
32
29
|
}
|
|
33
30
|
};
|
|
34
31
|
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { maskJavaFiles } from '@code-sentinel/parsers';
|
|
2
|
+
|
|
3
|
+
// builtin-rules/static/spring-boot/no-global-permit-all.rule.ts
|
|
4
|
+
var GLOBAL_PERMIT_PATTERNS = [
|
|
5
|
+
/\banyRequest\s*\(\s*\)\s*\.\s*permitAll\s*\(\s*\)/g,
|
|
6
|
+
/\brequestMatchers\s*\(\s*(?:[\w$.]+\s*\.\s*pattern\s*\(\s*)?["'](?:\/\*\*|\*\*)["'][^;]{0,160}?\)\s*\)?\s*\.\s*permitAll\s*\(\s*\)/g
|
|
7
|
+
];
|
|
8
|
+
var isTestPath = (path) => /(?:^|[/\\])(?:test|tests|fixtures|mock)(?:[/\\]|$)/i.test(path) || /[._-](?:test|tests|spec)\.java$/i.test(path);
|
|
9
|
+
var lineOf = (content, index) => content.slice(0, index).split("\n").length;
|
|
10
|
+
var rule = {
|
|
11
|
+
id: "spring-boot/no-global-permit-all",
|
|
12
|
+
version: 1,
|
|
13
|
+
kind: "static-ts",
|
|
14
|
+
title: "Kh\xF4ng m\u1EDF c\xF4ng khai to\xE0n b\u1ED9 Spring Security filter chain",
|
|
15
|
+
description: 'Ph\xE1t hi\u1EC7n anyRequest().permitAll() ho\u1EB7c requestMatchers("/**").permitAll(). \u0110\xE2y l\xE0 grant c\xF4ng khai to\xE0n c\u1EE5c \u1EDF t\u1EA7ng Spring Security; gateway ho\u1EB7c method security c\xF3 th\u1EC3 v\u1EABn b\u1EA3o v\u1EC7 n\xEAn finding y\xEAu c\u1EA7u review thay v\xEC t\u1EF1 kh\u1EB3ng \u0111\u1ECBnh khai th\xE1c.',
|
|
16
|
+
severity: "warning",
|
|
17
|
+
category: "security",
|
|
18
|
+
languages: ["java"],
|
|
19
|
+
scope: "spring-boot",
|
|
20
|
+
requires: "text",
|
|
21
|
+
usesParser: false,
|
|
22
|
+
baseConfidence: 90,
|
|
23
|
+
check(ctx) {
|
|
24
|
+
if (isTestPath(ctx.file.path)) return [];
|
|
25
|
+
const source = maskJavaFiles([ctx.file])[0]?.content ?? ctx.file.content;
|
|
26
|
+
if (!/\b(?:SecurityFilterChain|HttpSecurity)\b/.test(source)) return [];
|
|
27
|
+
const findings = [];
|
|
28
|
+
const seen = /* @__PURE__ */ new Set();
|
|
29
|
+
for (const pattern of GLOBAL_PERMIT_PATTERNS) {
|
|
30
|
+
pattern.lastIndex = 0;
|
|
31
|
+
for (const match of source.matchAll(pattern)) {
|
|
32
|
+
const index = match.index ?? 0;
|
|
33
|
+
if (seen.has(index)) continue;
|
|
34
|
+
seen.add(index);
|
|
35
|
+
findings.push({
|
|
36
|
+
file: ctx.file.path,
|
|
37
|
+
range: { line: lineOf(source, index), column: 1 },
|
|
38
|
+
confidence: 90,
|
|
39
|
+
message: "Spring Security c\u1EA5p permitAll cho to\xE0n b\u1ED9 request; m\u1ECDi endpoint ph\u1EE5 thu\u1ED9c ho\xE0n to\xE0n v\xE0o gateway ho\u1EB7c method-level security. [control=global-permit-all]",
|
|
40
|
+
suggestion: "\u0110\u1ED5i catch-all th\xE0nh authenticated()/denyAll() v\xE0 allowlist ri\xEAng endpoint public. N\u1EBFu ch\u1EE7 \xFD \u1EE7y quy\u1EC1n cho gateway/method interceptor, b\u1ED5 sung test b\u1EAFt bu\u1ED9c ch\u1EE9ng minh m\u1ECDi endpoint nh\u1EA1y c\u1EA3m \u0111\u1EC1u \u0111\u01B0\u1EE3c l\u1EDBp \u0111\xF3 b\u1EA3o v\u1EC7."
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
return findings.sort((a, b) => a.range.line - b.range.line);
|
|
45
|
+
}
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
export { rule };
|
|
49
|
+
//# sourceMappingURL=no-global-permit-all.rule.js.map
|
|
50
|
+
//# sourceMappingURL=no-global-permit-all.rule.js.map
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import { asTreeSitterTree } from '@code-sentinel/parsers';
|
|
2
|
+
|
|
3
|
+
// builtin-rules/static/spring-boot/no-negative-sensitive-input.rule.ts
|
|
4
|
+
var REQUEST_TYPE_SUFFIX = /(?:DTO|Dto|VM|Request|Command|Payload|Form)$/;
|
|
5
|
+
var SENSITIVE_NUMBER_PREFIX = /^(?:amount|price|cost|fee|dues|payment|money|balance|quantity|total|count|number|value)(?:[A-Z_]|$)/i;
|
|
6
|
+
var SENSITIVE_NUMBER_SUFFIX = /(?:amount|price|cost|fee|dues|payment|money|balance|quantity|total|count|number|value)$/i;
|
|
7
|
+
var NUMERIC_TYPE = /* @__PURE__ */ new Set([
|
|
8
|
+
"byte",
|
|
9
|
+
"short",
|
|
10
|
+
"int",
|
|
11
|
+
"long",
|
|
12
|
+
"float",
|
|
13
|
+
"double",
|
|
14
|
+
"Byte",
|
|
15
|
+
"Short",
|
|
16
|
+
"Integer",
|
|
17
|
+
"Long",
|
|
18
|
+
"Float",
|
|
19
|
+
"Double",
|
|
20
|
+
"BigDecimal",
|
|
21
|
+
"BigInteger"
|
|
22
|
+
]);
|
|
23
|
+
var NON_NEGATIVE_ANNOTATION = /@(?:Positive|PositiveOrZero|NonNegative)\b|@Min\s*\(\s*(?:value\s*=\s*)?0\s*\)|@DecimalMin\s*\(\s*(?:value\s*=\s*)?["']?(?:0+(?:\.0+)?)["']?|@Range\s*\([^)]*\bmin\s*=\s*0\b/i;
|
|
24
|
+
function* walk(node, type) {
|
|
25
|
+
const stack = [node];
|
|
26
|
+
while (stack.length > 0) {
|
|
27
|
+
const current = stack.pop();
|
|
28
|
+
if (!current) continue;
|
|
29
|
+
if (current.type === type) yield current;
|
|
30
|
+
for (let i = current.namedChildCount - 1; i >= 0; i--) {
|
|
31
|
+
const child = current.namedChild(i);
|
|
32
|
+
if (child) stack.push(child);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
var isRequestDto = (node) => {
|
|
37
|
+
const name = node.childForFieldName("name")?.text ?? "";
|
|
38
|
+
return REQUEST_TYPE_SUFFIX.test(name);
|
|
39
|
+
};
|
|
40
|
+
var modifiersText = (node) => {
|
|
41
|
+
for (let i = 0; i < node.namedChildCount; i++) {
|
|
42
|
+
const child = node.namedChild(i);
|
|
43
|
+
if (child?.type === "modifiers") return child.text;
|
|
44
|
+
}
|
|
45
|
+
return "";
|
|
46
|
+
};
|
|
47
|
+
var simpleType = (type) => type.replace(/^.*\./, "").trim();
|
|
48
|
+
var rule = {
|
|
49
|
+
id: "spring-boot/no-negative-sensitive-input",
|
|
50
|
+
version: 1,
|
|
51
|
+
kind: "static-ts",
|
|
52
|
+
title: "DTO request c\xF3 s\u1ED1 nh\u1EA1y c\u1EA3m c\u1EA7n ch\u1EB7n gi\xE1 tr\u1ECB \xE2m",
|
|
53
|
+
description: "Ph\xE1t hi\u1EC7n field s\u1ED1 d\u1EA1ng amount/fee/quantity/... trong DTO request kh\xF4ng c\xF3 r\xE0ng bu\u1ED9c kh\xF4ng \xE2m. \u0110\xE2y l\xE0 review nghi\u1EC7p v\u1EE5: m\u1ED9t s\u1ED1 lu\u1ED3ng ho\xE0n ti\u1EC1n/\u0111i\u1EC1u ch\u1EC9nh c\xF3 th\u1EC3 cho ph\xE9p gi\xE1 tr\u1ECB \xE2m.",
|
|
54
|
+
severity: "warning",
|
|
55
|
+
category: "security",
|
|
56
|
+
languages: ["java"],
|
|
57
|
+
scope: "spring-boot",
|
|
58
|
+
requires: "syntactic",
|
|
59
|
+
baseConfidence: 75,
|
|
60
|
+
check(ctx) {
|
|
61
|
+
const tree = asTreeSitterTree(ctx.parsed);
|
|
62
|
+
const findings = [];
|
|
63
|
+
for (const declaration of walk(tree.rootNode, "class_declaration")) {
|
|
64
|
+
if (!isRequestDto(declaration)) continue;
|
|
65
|
+
for (const field of walk(declaration, "field_declaration")) {
|
|
66
|
+
const type = simpleType(field.childForFieldName("type")?.text ?? "");
|
|
67
|
+
if (!NUMERIC_TYPE.has(type)) continue;
|
|
68
|
+
if (NON_NEGATIVE_ANNOTATION.test(modifiersText(field))) continue;
|
|
69
|
+
for (let i = 0; i < field.namedChildCount; i++) {
|
|
70
|
+
const child = field.namedChild(i);
|
|
71
|
+
if (child?.type !== "variable_declarator") continue;
|
|
72
|
+
const name = child.childForFieldName("name");
|
|
73
|
+
if (!name || !SENSITIVE_NUMBER_PREFIX.test(name.text) && !SENSITIVE_NUMBER_SUFFIX.test(name.text))
|
|
74
|
+
continue;
|
|
75
|
+
findings.push({
|
|
76
|
+
file: ctx.file.path,
|
|
77
|
+
range: { line: name.startPosition.row + 1, column: name.startPosition.column + 1 },
|
|
78
|
+
confidence: 75,
|
|
79
|
+
message: "Numeric request field c\xF3 \xFD ngh\u0129a ti\u1EC1n/s\u1ED1 l\u01B0\u1EE3ng kh\xF4ng c\xF3 r\xE0ng bu\u1ED9c ch\u1EB7n gi\xE1 tr\u1ECB \xE2m. [control=numeric-input-lower-bound-review]",
|
|
80
|
+
suggestion: 'N\u1EBFu gi\xE1 tr\u1ECB \xE2m kh\xF4ng h\u1EE3p l\u1EC7, th\xEAm @Positive, @PositiveOrZero, @Min(0), ho\u1EB7c @DecimalMin("0") v\xE0o DTO. N\u1EBFu nghi\u1EC7p v\u1EE5 cho ph\xE9p ho\xE0n ti\u1EC1n/\u0111i\u1EC1u ch\u1EC9nh \xE2m, suppress finding k\xE8m l\xFD do.'
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
return findings;
|
|
86
|
+
}
|
|
87
|
+
};
|
|
88
|
+
|
|
89
|
+
export { rule };
|
|
90
|
+
//# sourceMappingURL=no-negative-sensitive-input.rule.js.map
|
|
91
|
+
//# sourceMappingURL=no-negative-sensitive-input.rule.js.map
|
|
@@ -11,7 +11,13 @@ var SINK_LABEL = {
|
|
|
11
11
|
};
|
|
12
12
|
var rule = {
|
|
13
13
|
id: "spring-boot/no-path-traversal",
|
|
14
|
-
|
|
14
|
+
// v4 (D1 — JAX-RS taint sources): no rule-logic change. The Java analyzer
|
|
15
|
+
// gained 8 `jaxrs/*` parameter sources (`@QueryParam`/`@FormParam`/…, javax +
|
|
16
|
+
// jakarta) and seeds a bare impl param from the annotation on the interface
|
|
17
|
+
// method it overrides. The rule cache key is `(id, version, file.hash)`, so a
|
|
18
|
+
// taint-table change alone does NOT rotate it — without this bump a warm cache
|
|
19
|
+
// keeps serving the pre-D1 result (measured: 1 vs 10 SSRF on the same module).
|
|
20
|
+
version: 4,
|
|
15
21
|
kind: "static-ts",
|
|
16
22
|
title: "Kh\xF4ng m\u1EDF file theo \u0111\u01B0\u1EDDng d\u1EABn t\u1EEB d\u1EEF li\u1EC7u ch\u01B0a ki\u1EC3m so\xE1t (Path Traversal)",
|
|
17
23
|
description: "D\u1EEF li\u1EC7u t\u1EEB request (@RequestParam, @PathVariable, @RequestBody, @RequestHeader, @RequestPart, HttpServletRequest, \u2026) ch\u1EA3y th\u1EB3ng v\xE0o \u0111\u01B0\u1EDDng d\u1EABn filesystem (`new File(...)`, `new FileInputStream(...)`, `getResource(...)`) ho\u1EB7c kh\xF3a object-store MinIO (`.object(...)`) l\xE0 l\u1ED7 h\u1ED5ng Path Traversal (CWE-22) \u2014 k\u1EBB t\u1EA5n c\xF4ng d\xF9ng `../../../../etc/passwd` \u0111\u1EC3 \u0111\u1ECDc/ghi file ngo\xE0i th\u01B0 m\u1EE5c d\u1EF1 ki\u1EBFn. Rule d\xF9ng taint analysis (Tier-1 li\xEAn th\u1EE7 t\u1EE5c trong c\xF9ng method) \u0111\u1EC3 truy v\u1EBFt lu\u1ED3ng d\u1EEF li\u1EC7u. Kh\u1EAFc ph\u1EE5c: chu\u1EA9n h\xF3a \u0111\u01B0\u1EDDng d\u1EABn (`getCanonicalPath()`) r\u1ED3i ki\u1EC3m tra n\u1EB1m trong th\u01B0 m\u1EE5c g\u1ED1c cho ph\xE9p (allowlist); kh\xF4ng bao gi\u1EDD gh\xE9p \u0111\u01B0\u1EDDng d\u1EABn tr\u1EF1c ti\u1EBFp t\u1EEB input ng\u01B0\u1EDDi d\xF9ng.",
|
|
@@ -5,7 +5,13 @@ var SINK_LABEL = {
|
|
|
5
5
|
};
|
|
6
6
|
var rule = {
|
|
7
7
|
id: "spring-boot/no-servlet-xss",
|
|
8
|
-
|
|
8
|
+
// v2 (D1 — JAX-RS taint sources): no rule-logic change. The Java analyzer
|
|
9
|
+
// gained 8 `jaxrs/*` parameter sources (`@QueryParam`/`@FormParam`/…, javax +
|
|
10
|
+
// jakarta) and seeds a bare impl param from the annotation on the interface
|
|
11
|
+
// method it overrides. The rule cache key is `(id, version, file.hash)`, so a
|
|
12
|
+
// taint-table change alone does NOT rotate it — without this bump a warm cache
|
|
13
|
+
// keeps serving the pre-D1 result (measured: 1 vs 10 SSRF on the same module).
|
|
14
|
+
version: 2,
|
|
9
15
|
kind: "static-ts",
|
|
10
16
|
title: "Kh\xF4ng ghi d\u1EEF li\u1EC7u ch\u01B0a ki\u1EC3m so\xE1t v\xE0o response HTML (Reflected XSS)",
|
|
11
17
|
description: "D\u1EEF li\u1EC7u t\u1EEB request (@RequestParam, @PathVariable, @RequestBody, @RequestHeader, HttpServletRequest, Cookie, \u2026) ghi th\u1EB3ng v\xE0o body response qua `response.getWriter().write/print/println/printf/format(...)` m\xE0 kh\xF4ng encode l\xE0 l\u1ED7 h\u1ED5ng Reflected Cross-Site Scripting (CWE-79) \u2014 k\u1EBB t\u1EA5n c\xF4ng ch\xE8n `<script>` ch\u1EA1y trong phi\xEAn \u0111\u0103ng nh\u1EADp c\u1EE7a n\u1EA1n nh\xE2n (\u0111\xE1nh c\u1EAFp session, thao t\xE1c thay ng\u01B0\u1EDDi d\xF9ng). Rule d\xF9ng taint analysis (Tier-1 trong c\xF9ng method) \u0111\u1EC3 truy v\u1EBFt lu\u1ED3ng d\u1EEF li\u1EC7u; sink \u0111\u01B0\u1EE3c gate theo receiver `getWriter()` n\xEAn kh\xF4ng nh\u1EA7m v\u1EDBi `System.out.println` / `String.format`. Kh\u1EAFc ph\u1EE5c: HTML-encode gi\xE1 tr\u1ECB tr\u01B0\u1EDBc khi ghi (OWASP Java Encoder `Encode.forHtml(...)`), ho\u1EB7c tr\u1EA3 JSON qua `@ResponseBody` \u0111\u1EC3 Spring t\u1EF1 serialize thay v\xEC ghi tay ra writer.",
|
|
@@ -6,7 +6,13 @@ var SINK_LABEL = {
|
|
|
6
6
|
var rule = {
|
|
7
7
|
id: "spring-boot/no-spel-injection",
|
|
8
8
|
// v3 (ADR-0065 calibration): luồng taint trực tiếp → severity blocker
|
|
9
|
-
|
|
9
|
+
// v4 (D1 — JAX-RS taint sources): no rule-logic change. The Java analyzer
|
|
10
|
+
// gained 8 `jaxrs/*` parameter sources (`@QueryParam`/`@FormParam`/…, javax +
|
|
11
|
+
// jakarta) and seeds a bare impl param from the annotation on the interface
|
|
12
|
+
// method it overrides. The rule cache key is `(id, version, file.hash)`, so a
|
|
13
|
+
// taint-table change alone does NOT rotate it — without this bump a warm cache
|
|
14
|
+
// keeps serving the pre-D1 result (measured: 1 vs 10 SSRF on the same module).
|
|
15
|
+
version: 4,
|
|
10
16
|
kind: "static-ts",
|
|
11
17
|
title: "Kh\xF4ng parse SpEL t\u1EEB d\u1EEF li\u1EC7u ch\u01B0a ki\u1EC3m so\xE1t (Expression Language Injection)",
|
|
12
18
|
description: "D\u1EEF li\u1EC7u t\u1EEB request (@RequestParam, @PathVariable, @RequestBody, @RequestHeader, HttpServletRequest, \u2026) ch\u1EA3y th\u1EB3ng v\xE0o `ExpressionParser.parseExpression(...)` l\xE0 l\u1ED7 h\u1ED5ng Expression Language (SpEL) Injection (CWE-917) \u2014 bi\u1EC3u th\u1EE9c SpEL do k\u1EBB t\u1EA5n c\xF4ng ki\u1EC3m so\xE1t c\xF3 th\u1EC3 g\u1ECDi method t\xF9y \xFD (`T(java.lang.Runtime).getRuntime().exec(...)`) \u2192 RCE. Rule d\xF9ng taint analysis (Tier-1 li\xEAn th\u1EE7 t\u1EE5c trong c\xF9ng method) \u0111\u1EC3 truy v\u1EBFt lu\u1ED3ng d\u1EEF li\u1EC7u. Kh\u1EAFc ph\u1EE5c: kh\xF4ng bao gi\u1EDD parse SpEL t\u1EEB input ng\u01B0\u1EDDi d\xF9ng; n\u1EBFu c\u1EA7n bi\u1EC3u th\u1EE9c \u0111\u1ED9ng, d\xF9ng allowlist bi\u1EC3u th\u1EE9c c\u1ED1 \u0111\u1ECBnh, ho\u1EB7c `SimpleEvaluationContext` (ch\u1EB7n type reference / method call nguy hi\u1EC3m) thay cho `StandardEvaluationContext`.",
|
|
@@ -153,7 +153,13 @@ var isConcatRoot = (node) => {
|
|
|
153
153
|
var rule = {
|
|
154
154
|
id: "spring-boot/no-sql-string-concat",
|
|
155
155
|
// v7 (ADR-0065 calibration): band CONFIRMED → severity blocker
|
|
156
|
-
|
|
156
|
+
// v8 (D1 — JAX-RS taint sources): no rule-logic change. The Java analyzer
|
|
157
|
+
// gained 8 `jaxrs/*` parameter sources (`@QueryParam`/`@FormParam`/…, javax +
|
|
158
|
+
// jakarta) and seeds a bare impl param from the annotation on the interface
|
|
159
|
+
// method it overrides. The rule cache key is `(id, version, file.hash)`, so a
|
|
160
|
+
// taint-table change alone does NOT rotate it — without this bump a warm cache
|
|
161
|
+
// keeps serving the pre-D1 result (measured: 1 vs 10 SSRF on the same module).
|
|
162
|
+
version: 8,
|
|
157
163
|
kind: "static-ts",
|
|
158
164
|
title: "Kh\xF4ng n\u1ED1i SQL b\u1EB1ng `+` \u2014 d\xF9ng prepared statement / named parameter",
|
|
159
165
|
description: "N\u1ED1i chu\u1ED7i SQL b\u1EB1ng `+` l\xE0 pattern \u0111i\u1EC3n h\xECnh c\u1EE7a SQL Injection. v2 d\xF9ng taint analysis: n\u1ED1i c\xF3 gi\xE1 tr\u1ECB t\u1EEB request (taint-confirmed) \u2192 error tin c\u1EADy cao; n\u1ED1i to\xE0n h\u1EB1ng s\u1ED1 (literal / `static final`) \u2192 b\u1ECF qua; c\xF2n l\u1EA1i gi\u1EEF c\u1EA3nh b\xE1o nh\u01B0 v1. D\xF9ng JdbcTemplate `?` + args, JPQL `:param` + `setParameter(...)`, ho\u1EB7c Spring Data query methods.",
|
|
@@ -3,17 +3,37 @@ var SSRF_SINK_IDS = /* @__PURE__ */ new Set([
|
|
|
3
3
|
"spring/rest-template-ssrf",
|
|
4
4
|
"spring/web-client-ssrf",
|
|
5
5
|
"spring/url-ssrf",
|
|
6
|
-
"spring/okhttp-url"
|
|
6
|
+
"spring/okhttp-url",
|
|
7
|
+
"spring/jdbc-url-ssrf",
|
|
8
|
+
"spring/datasource-url-ssrf"
|
|
7
9
|
]);
|
|
8
10
|
var SINK_LABEL = {
|
|
9
11
|
"spring/rest-template-ssrf": "RestTemplate (getForObject / exchange / \u2026)",
|
|
10
12
|
"spring/web-client-ssrf": "WebClient.uri(...)",
|
|
11
13
|
"spring/url-ssrf": "new URL(...) / new URI(...)",
|
|
12
|
-
"spring/okhttp-url": "OkHttp Request.Builder.url(...)"
|
|
14
|
+
"spring/okhttp-url": "OkHttp Request.Builder.url(...)",
|
|
15
|
+
"spring/jdbc-url-ssrf": "DriverManager.getConnection(jdbcUrl, ...)",
|
|
16
|
+
"spring/datasource-url-ssrf": "DataSource.setJdbcUrl / setUrl(...)"
|
|
13
17
|
};
|
|
14
18
|
var rule = {
|
|
15
19
|
id: "spring-boot/no-ssrf",
|
|
16
|
-
|
|
20
|
+
// v5 (D1 — JAX-RS taint sources): no rule-logic change. The Java analyzer
|
|
21
|
+
// gained 8 `jaxrs/*` parameter sources (`@QueryParam`/`@FormParam`/…, javax +
|
|
22
|
+
// jakarta) and seeds a bare impl param from the annotation on the interface
|
|
23
|
+
// method it overrides. The rule cache key is `(id, version, file.hash)`, so a
|
|
24
|
+
// taint-table change alone does NOT rotate it — without this bump a warm cache
|
|
25
|
+
// keeps serving the pre-D1 result (measured: 1 vs 10 SSRF on the same module).
|
|
26
|
+
// v7 (2026-09-17): no rule-logic change. The analyzer drops `new URL(spec)` when the assigned
|
|
27
|
+
// value is only read through inert accessors (getHost/getProtocol/…) — a redirect GUARD on
|
|
28
|
+
// mcdt_bqp was a CONFIRMED-VULN SSRF. Also two JDBC-URL sinks (DriverManager.getConnection, DataSource
|
|
29
|
+
// setJdbcUrl/setUrl — SR BUG-53088). Bumped so a warm cache cannot keep the pre-gate result.
|
|
30
|
+
// v6 (ADR-0086 — host-fixing prefix): no rule-logic change either. The four SSRF sinks now
|
|
31
|
+
// carry `urlAuthority`, so the Java analyzer no longer reports taint that reaches the URL only
|
|
32
|
+
// AFTER a host-fixing constant (`base + "?q=" + t`, `"/api/items/" + id`,
|
|
33
|
+
// `endpoint + StringPool.QUESTION + params`) — a query value / path segment on a host the
|
|
34
|
+
// server chose is parameter injection, not SSRF. Same cache reason as v5: bump or a warm cache
|
|
35
|
+
// keeps serving the suppressed findings.
|
|
36
|
+
version: 7,
|
|
17
37
|
kind: "static-ts",
|
|
18
38
|
title: "Kh\xF4ng g\u1ECDi HTTP ra ngo\xE0i b\u1EB1ng URL t\u1EEB d\u1EEF li\u1EC7u ch\u01B0a ki\u1EC3m so\xE1t (SSRF)",
|
|
19
39
|
description: "D\u1EEF li\u1EC7u t\u1EEB request (@RequestParam, @PathVariable, @RequestBody, @RequestHeader, HttpServletRequest, \u2026) ch\u1EA3y th\u1EB3ng v\xE0o URL c\u1EE7a m\u1ED9t l\u1EDDi g\u1ECDi HTTP ra ngo\xE0i (RestTemplate `getForObject`/`exchange`/\u2026, WebClient `.uri(...)`, ho\u1EB7c OkHttp `Request.Builder.url(...)`) l\xE0 l\u1ED7 h\u1ED5ng Server-Side Request Forgery (CWE-918) \u2014 k\u1EBB t\u1EA5n c\xF4ng \u0111i\u1EC1u khi\u1EC3n server g\u1ECDi t\u1EDBi \u0111\u1ECBa ch\u1EC9 n\u1ED9i b\u1ED9 / metadata cloud (vd. 169.254.169.254) ho\u1EB7c d\u1ECBch v\u1EE5 n\u1ED9i b\u1ED9 kh\xF4ng \u0111\u01B0\u1EE3c ph\xE9p truy c\u1EADp t\u1EEB b\xEAn ngo\xE0i. Rule d\xF9ng taint analysis (Tier-1 li\xEAn th\u1EE7 t\u1EE5c trong c\xF9ng method) \u0111\u1EC3 truy v\u1EBFt lu\u1ED3ng d\u1EEF li\u1EC7u. Kh\u1EAFc ph\u1EE5c: validate URL b\u1EB1ng allowlist host/scheme c\u1ED1 \u0111\u1ECBnh; kh\xF4ng bao gi\u1EDD gh\xE9p URL \u0111\xEDch tr\u1EF1c ti\u1EBFp t\u1EEB gi\xE1 tr\u1ECB do ng\u01B0\u1EDDi d\xF9ng nh\u1EADp.",
|