@zhuma4/cli 4.0.0-alpha.1
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/README.md +42 -0
- package/dist/commands/config.d.ts +3 -0
- package/dist/commands/config.d.ts.map +1 -0
- package/dist/commands/config.js +18 -0
- package/dist/commands/config.js.map +1 -0
- package/dist/commands/init.d.ts +3 -0
- package/dist/commands/init.d.ts.map +1 -0
- package/dist/commands/init.js +11 -0
- package/dist/commands/init.js.map +1 -0
- package/dist/commands/scan.d.ts +3 -0
- package/dist/commands/scan.d.ts.map +1 -0
- package/dist/commands/scan.js +96 -0
- package/dist/commands/scan.js.map +1 -0
- package/dist/commands/scan_appid.d.ts +20 -0
- package/dist/commands/scan_appid.d.ts.map +1 -0
- package/dist/commands/scan_appid.js +301 -0
- package/dist/commands/scan_appid.js.map +1 -0
- package/dist/commands/scan_manifest.d.ts +13 -0
- package/dist/commands/scan_manifest.d.ts.map +1 -0
- package/dist/commands/scan_manifest.js +103 -0
- package/dist/commands/scan_manifest.js.map +1 -0
- package/dist/engine/api-submit.d.ts +16 -0
- package/dist/engine/api-submit.d.ts.map +1 -0
- package/dist/engine/api-submit.js +66 -0
- package/dist/engine/api-submit.js.map +1 -0
- package/dist/engine/batch_scan.d.ts +36 -0
- package/dist/engine/batch_scan.d.ts.map +1 -0
- package/dist/engine/batch_scan.js +192 -0
- package/dist/engine/batch_scan.js.map +1 -0
- package/dist/engine/config.d.ts +12 -0
- package/dist/engine/config.d.ts.map +1 -0
- package/dist/engine/config.js +27 -0
- package/dist/engine/config.js.map +1 -0
- package/dist/engine/errors.d.ts +36 -0
- package/dist/engine/errors.d.ts.map +1 -0
- package/dist/engine/errors.js +99 -0
- package/dist/engine/errors.js.map +1 -0
- package/dist/engine/filter.d.ts +13 -0
- package/dist/engine/filter.d.ts.map +1 -0
- package/dist/engine/filter.js +64 -0
- package/dist/engine/filter.js.map +1 -0
- package/dist/engine/finding_classifier.d.ts +108 -0
- package/dist/engine/finding_classifier.d.ts.map +1 -0
- package/dist/engine/finding_classifier.js +440 -0
- package/dist/engine/finding_classifier.js.map +1 -0
- package/dist/engine/incremental/engine.d.ts +25 -0
- package/dist/engine/incremental/engine.d.ts.map +1 -0
- package/dist/engine/incremental/engine.js +337 -0
- package/dist/engine/incremental/engine.js.map +1 -0
- package/dist/engine/incremental/git-diff.d.ts +19 -0
- package/dist/engine/incremental/git-diff.d.ts.map +1 -0
- package/dist/engine/incremental/git-diff.js +175 -0
- package/dist/engine/incremental/git-diff.js.map +1 -0
- package/dist/engine/incremental/types.d.ts +33 -0
- package/dist/engine/incremental/types.d.ts.map +1 -0
- package/dist/engine/incremental/types.js +11 -0
- package/dist/engine/incremental/types.js.map +1 -0
- package/dist/engine/manifest_scanner.d.ts +48 -0
- package/dist/engine/manifest_scanner.d.ts.map +1 -0
- package/dist/engine/manifest_scanner.js +599 -0
- package/dist/engine/manifest_scanner.js.map +1 -0
- package/dist/engine/project.d.ts +22 -0
- package/dist/engine/project.d.ts.map +1 -0
- package/dist/engine/project.js +279 -0
- package/dist/engine/project.js.map +1 -0
- package/dist/engine/sarif.d.ts +13 -0
- package/dist/engine/sarif.d.ts.map +1 -0
- package/dist/engine/sarif.js +44 -0
- package/dist/engine/sarif.js.map +1 -0
- package/dist/engine/sca-integration.d.ts +36 -0
- package/dist/engine/sca-integration.d.ts.map +1 -0
- package/dist/engine/sca-integration.js +91 -0
- package/dist/engine/sca-integration.js.map +1 -0
- package/dist/engine/scanner.d.ts +18 -0
- package/dist/engine/scanner.d.ts.map +1 -0
- package/dist/engine/scanner.js +138 -0
- package/dist/engine/scanner.js.map +1 -0
- package/dist/index.d.ts +13 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +41 -0
- package/dist/index.js.map +1 -0
- package/dist/report/render.d.ts +23 -0
- package/dist/report/render.d.ts.map +1 -0
- package/dist/report/render.js +335 -0
- package/dist/report/render.js.map +1 -0
- package/package.json +41 -0
- package/rules/android/mobile-cleartext-traffic.yaml +46 -0
- package/rules/android/mobile-component-security.yaml +107 -0
- package/rules/android/mobile-crypto-weakness.yaml +139 -0
- package/rules/android/mobile-cwe-1021-tapjacking.yaml +81 -0
- package/rules/android/mobile-cwe-114-dynamic-dex-loading.yaml +41 -0
- package/rules/android/mobile-cwe-200-clipboard-data-leak.yaml +66 -0
- package/rules/android/mobile-cwe-200-debug-builds.yaml +111 -0
- package/rules/android/mobile-cwe-200-log-sensitive-data.yaml +61 -0
- package/rules/android/mobile-cwe-200-webview-debugging.yaml +56 -0
- package/rules/android/mobile-cwe-200-webview-universal-access.yaml +30 -0
- package/rules/android/mobile-cwe-200-window-flags.yaml +96 -0
- package/rules/android/mobile-cwe-22-content-provider-openfile.yaml +73 -0
- package/rules/android/mobile-cwe-22-path-traversal.yaml +86 -0
- package/rules/android/mobile-cwe-287-biometric-weakness.yaml +102 -0
- package/rules/android/mobile-cwe-295-cert-pinning-missing.yaml +78 -0
- package/rules/android/mobile-cwe-295-webview-ssl-bypass.yaml +104 -0
- package/rules/android/mobile-cwe-312-cleartext-storage.yaml +109 -0
- package/rules/android/mobile-cwe-319-cleartext-communication.yaml +84 -0
- package/rules/android/mobile-cwe-321-hardcoded-crypto-keys.yaml +132 -0
- package/rules/android/mobile-cwe-326-short-rsa.yaml +108 -0
- package/rules/android/mobile-cwe-327-rc4-3des.yaml +107 -0
- package/rules/android/mobile-cwe-329-cbc-padding-oracle.yaml +76 -0
- package/rules/android/mobile-cwe-470-reflection-injection.yaml +39 -0
- package/rules/android/mobile-cwe-489-root-detection-weak.yaml +125 -0
- package/rules/android/mobile-cwe-489-stetho-debug.yaml +107 -0
- package/rules/android/mobile-cwe-502-insecure-deserialization.yaml +76 -0
- package/rules/android/mobile-cwe-552-world-readable-files.yaml +63 -0
- package/rules/android/mobile-cwe-749-webview-java-objects.yaml +78 -0
- package/rules/android/mobile-cwe-749-webview-jsbridge.yaml +57 -0
- package/rules/android/mobile-cwe-749-webview-loadurl-injection.yaml +80 -0
- package/rules/android/mobile-cwe-78-command-injection.yaml +77 -0
- package/rules/android/mobile-cwe-780-rsa-no-oaep.yaml +80 -0
- package/rules/android/mobile-cwe-79-webview-setdata.yaml +78 -0
- package/rules/android/mobile-cwe-79-webview-xss.yaml +65 -0
- package/rules/android/mobile-cwe-798-hardcoded-credentials.yaml +108 -0
- package/rules/android/mobile-cwe-89-sql-injection.yaml +100 -0
- package/rules/android/mobile-cwe-927-implicit-intent.yaml +121 -0
- package/rules/android/mobile-cwe-927-ipc-file-provider.yaml +102 -0
- package/rules/android/mobile-cwe-939-deeplink-validation.yaml +76 -0
- package/rules/android/mobile-sdk-google-firebase-open.yaml +117 -0
- package/rules/android/mobile-sdk-tencent-tpns-config-leak.yaml +131 -0
- package/rules/android/mobile-secrets-storage.yaml +136 -0
- package/rules/android/mobile-webview-security.yaml +88 -0
- package/rules/common/cwe-200-sensitive-data-exposure.yaml +61 -0
- package/rules/common/cwe-22-path-traversal.yaml +47 -0
- package/rules/common/cwe-295-ssl-bypass.yaml +217 -0
- package/rules/common/cwe-295-ssl-verification-disabled.yaml +64 -0
- package/rules/common/cwe-306-missing-authentication.yaml +44 -0
- package/rules/common/cwe-326-weak-key-size.yaml +107 -0
- package/rules/common/cwe-327-weak-crypto.yaml +177 -0
- package/rules/common/cwe-328-weak-hash.yaml +96 -0
- package/rules/common/cwe-329-cbc-mode.yaml +26 -0
- package/rules/common/cwe-352-csrf.yaml +23 -0
- package/rules/common/cwe-434-unrestricted-file-upload.yaml +41 -0
- package/rules/common/cwe-502-insecure-deserialization.yaml +44 -0
- package/rules/common/cwe-601-url-redirect.yaml +110 -0
- package/rules/common/cwe-611-xxe.yaml +70 -0
- package/rules/common/cwe-732-incorrect-permission.yaml +49 -0
- package/rules/common/cwe-770-resource-exhaustion.yaml +44 -0
- package/rules/common/cwe-78-os-command-injection.yaml +43 -0
- package/rules/common/cwe-787-out-of-bounds-write.yaml +37 -0
- package/rules/common/cwe-79-xss.yaml +51 -0
- package/rules/common/cwe-862-missing-authorization.yaml +40 -0
- package/rules/common/cwe-89-sqli.yaml +89 -0
- package/rules/common/cwe-918-ssrf.yaml +45 -0
- package/rules/common/cwe-94-code-injection.yaml +59 -0
- package/rules/common/zm-go-cwe22-path-traversal-fs.yaml +117 -0
- package/rules/common/zm-go-cwe22-path-traversal.yaml +103 -0
- package/rules/common/zm-go-cwe307-brute-force.yaml +129 -0
- package/rules/common/zm-go-cwe326-weak-crypto.yaml +124 -0
- package/rules/common/zm-go-cwe327-weak-cipher.yaml +152 -0
- package/rules/common/zm-go-cwe384-session-fixation.yaml +128 -0
- package/rules/common/zm-go-cwe502-deserialization.yaml +120 -0
- package/rules/common/zm-go-cwe78-command-injection.yaml +95 -0
- package/rules/common/zm-go-cwe79-xss.yaml +104 -0
- package/rules/common/zm-go-cwe798-hardcoded-creds.yaml +153 -0
- package/rules/common/zm-go-cwe89-sqli.yaml +89 -0
- package/rules/common/zm-go-cwe918-ssrf.yaml +117 -0
- package/rules/common/zm-java-cwe117-log-injection.yaml +83 -0
- package/rules/common/zm-java-cwe117-logforging.yaml +153 -0
- package/rules/common/zm-java-cwe200-actuator-exposure.yaml +8 -0
- package/rules/common/zm-java-cwe200-info-disclosure.yaml +91 -0
- package/rules/common/zm-java-cwe22-file-depth.yaml +135 -0
- package/rules/common/zm-java-cwe22-path-traversal-spring.yaml +81 -0
- package/rules/common/zm-java-cwe284-missing-auth-spring.yaml +131 -0
- package/rules/common/zm-java-cwe295-webview-ssl.yaml +123 -0
- package/rules/common/zm-java-cwe327-weakcrypto.yaml +197 -0
- package/rules/common/zm-java-cwe347-jwt.yaml +30 -0
- package/rules/common/zm-java-cwe352-csrf-depth.yaml +107 -0
- package/rules/common/zm-java-cwe352-csrf-disabled.yaml +15 -0
- package/rules/common/zm-java-cwe501-trust-boundary.yaml +124 -0
- package/rules/common/zm-java-cwe502-deserial-depth.yaml +128 -0
- package/rules/common/zm-java-cwe502-fastjson.yaml +137 -0
- package/rules/common/zm-java-cwe502-gadget.yaml +158 -0
- package/rules/common/zm-java-cwe502-jndi-injection.yaml +91 -0
- package/rules/common/zm-java-cwe502-shiro.yaml +108 -0
- package/rules/common/zm-java-cwe601-url-redirect-spring.yaml +85 -0
- package/rules/common/zm-java-cwe611-xxe-enhanced.yaml +80 -0
- package/rules/common/zm-java-cwe611-xxe-transformer.yaml +85 -0
- package/rules/common/zm-java-cwe639-idor.yaml +123 -0
- package/rules/common/zm-java-cwe79-xss-depth.yaml +98 -0
- package/rules/common/zm-java-cwe862-authz-depth.yaml +127 -0
- package/rules/common/zm-java-cwe915-mass-assignment.yaml +16 -0
- package/rules/common/zm-java-cwe917-expression-injection.yaml +120 -0
- package/rules/common/zm-java-cwe918-resttemplate.yaml +67 -0
- package/rules/common/zm-java-cwe918-ssrf-depth.yaml +103 -0
- package/rules/common/zm-java-cwe918-ssrf-resttemplate.yaml +77 -0
- package/rules/common/zm-java-cwe918-webclient.yaml +44 -0
- package/rules/common/zm-java-cwe94-ognl.yaml +66 -0
- package/rules/common/zm-java-cwe94-spel-injection.yaml +85 -0
- package/rules/common/zm-java-cwe94-spel.yaml +112 -0
- package/rules/common/zm-java-cwe94-ssti.yaml +22 -0
- package/rules/common/zm-java-cwe942-cors.yaml +15 -0
- package/rules/common/zm-js-cwe1321-prototype-pollution.yaml +61 -0
- package/rules/common/zm-js-cwe200-info-disclosure.yaml +95 -0
- package/rules/common/zm-js-cwe22-path-traversal-fs.yaml +113 -0
- package/rules/common/zm-js-cwe22-pathtraversal.yaml +111 -0
- package/rules/common/zm-js-cwe307-brute-force.yaml +136 -0
- package/rules/common/zm-js-cwe345-postmessage.yaml +75 -0
- package/rules/common/zm-js-cwe347-jwt-weak.yaml +95 -0
- package/rules/common/zm-js-cwe352-csrf.yaml +52 -0
- package/rules/common/zm-js-cwe384-session-fixation.yaml +132 -0
- package/rules/common/zm-js-cwe502-deserialization.yaml +119 -0
- package/rules/common/zm-js-cwe611-xxe.yaml +108 -0
- package/rules/common/zm-js-cwe639-idor.yaml +122 -0
- package/rules/common/zm-js-cwe693-helmet-missing.yaml +46 -0
- package/rules/common/zm-js-cwe78-exec.yaml +37 -0
- package/rules/common/zm-js-cwe78-spawn.yaml +37 -0
- package/rules/common/zm-js-cwe79-domxss.yaml +84 -0
- package/rules/common/zm-js-cwe79-react-xss.yaml +18 -0
- package/rules/common/zm-js-cwe79-xss-ejs.yaml +70 -0
- package/rules/common/zm-js-cwe89-sqli.yaml +153 -0
- package/rules/common/zm-js-cwe915-mass-assignment.yaml +111 -0
- package/rules/common/zm-js-cwe918-ssrf-fetch.yaml +134 -0
- package/rules/common/zm-js-cwe918-ssrf.yaml +132 -0
- package/rules/common/zm-js-cwe94-template-injection.yaml +130 -0
- package/rules/common/zm-js-cwe942-cors.yaml +49 -0
- package/rules/common/zm-js-cwe943-nosql-injection.yaml +52 -0
- package/rules/common/zm-js-cwe95-eval.yaml +59 -0
- package/rules/common/zm-js-cwe95-function-ctor.yaml +31 -0
- package/rules/common/zm-py-cwe22-path-traversal.yaml +86 -0
- package/rules/common/zm-py-cwe327-weak-crypto.yaml +103 -0
- package/rules/common/zm-py-cwe502-pickle.yaml +92 -0
- package/rules/common/zm-py-cwe611-xxe.yaml +100 -0
- package/rules/common/zm-py-cwe78-command-injection.yaml +121 -0
- package/rules/common/zm-py-cwe79-xss.yaml +123 -0
- package/rules/common/zm-py-cwe798-hardcoded-creds.yaml +86 -0
- package/rules/common/zm-py-cwe89-sqli.yaml +59 -0
- package/rules/common/zm-py-cwe918-ssrf.yaml +123 -0
- package/rules/common/zm-py-cwe94-ssti.yaml +87 -0
- package/rules/common/zm-py-cwe943-nosql-injection.yaml +123 -0
- package/rules/iac/ansible/zm-ansible-cwe269-privilege-escalation.yaml +63 -0
- package/rules/iac/ansible/zm-ansible-cwe78-command-injection.yaml +67 -0
- package/rules/iac/ansible/zm-ansible-cwe798-hardcoded-creds.yaml +93 -0
- package/rules/iac/terraform/zm-tf-cwe200-s3-bucket-public.yaml +100 -0
- package/rules/iac/terraform/zm-tf-cwe284-sg-wide-open.yaml +88 -0
- package/rules/iac/terraform/zm-tf-cwe311-iam-wildcard.yaml +83 -0
- package/rules/iac/terraform/zm-tf-cwe319-rds-public.yaml +72 -0
- package/rules/iac/terraform/zm-tf-cwe798-hardcoded-creds.yaml +102 -0
- package/rules/iac/zm-docker-cwe250-root-user.yaml +50 -0
- package/rules/iac/zm-docker-cwe400-resource-limit.yaml +92 -0
- package/rules/iac/zm-docker-security.yaml +104 -0
- package/rules/iac/zm-k8s-cwe200-service-account.yaml +83 -0
- package/rules/iac/zm-k8s-cwe250-privileged.yaml +56 -0
- package/rules/iac/zm-k8s-security.yaml +79 -0
- package/rules/rules_index.yaml.off +477 -0
- package/rules/semgrep-registry/anonymous-ldap-bind.yaml +34 -0
- package/rules/semgrep-registry/bad-hexa-conversion.yaml +32 -0
- package/rules/semgrep-registry/blowfish-insufficient-key-size.yaml +39 -0
- package/rules/semgrep-registry/cbc-padding-oracle.yaml +38 -0
- package/rules/semgrep-registry/command-injection-formatted-runtime-call.yaml +90 -0
- package/rules/semgrep-registry/command-injection-process-builder.yaml +148 -0
- package/rules/semgrep-registry/cookie-missing-httponly.yaml +38 -0
- package/rules/semgrep-registry/cookie-missing-secure-flag.yaml +38 -0
- package/rules/semgrep-registry/crlf-injection-logs.yaml +86 -0
- package/rules/semgrep-registry/dangerous-groovy-shell.yaml +46 -0
- package/rules/semgrep-registry/el-injection.yaml +137 -0
- package/rules/semgrep-registry/formatted-sql-string.yaml +95 -0
- package/rules/semgrep-registry/http-response-splitting.yaml +44 -0
- package/rules/semgrep-registry/index.txt +1 -0
- package/rules/semgrep-registry/insecure-smtp-connection.yaml +34 -0
- package/rules/semgrep-registry/java-reverse-shell.yaml +43 -0
- package/rules/semgrep-registry/jdbc-sql-formatted-string.yaml +120 -0
- package/rules/semgrep-registry/ldap-entry-poisoning.yaml +41 -0
- package/rules/semgrep-registry/ldap-injection.yaml +82 -0
- package/rules/semgrep-registry/md5-used-as-password.yaml +44 -0
- package/rules/semgrep-registry/object-deserialization.yaml +34 -0
- package/rules/semgrep-registry/ognl-injection.yaml +839 -0
- package/rules/semgrep-registry/overly-permissive-file-permission.yaml +49 -0
- package/rules/semgrep-registry/permissive-cors.yaml +77 -0
- package/rules/semgrep-registry/script-engine-injection.yaml +66 -0
- package/rules/semgrep-registry/tainted-cmd-from-http-request.yaml +74 -0
- package/rules/semgrep-registry/tainted-env-from-http-request.yaml +46 -0
- package/rules/semgrep-registry/tainted-ldapi-from-http-request.yaml +42 -0
- package/rules/semgrep-registry/tainted-session-from-http-request.yaml +70 -0
- package/rules/semgrep-registry/tainted-xpath-from-http-request.yaml +38 -0
- package/rules/semgrep-registry/unsafe-reflection.yaml +39 -0
- package/rules/semgrep-registry/unvalidated-redirect.yaml +127 -0
- package/rules/semgrep-registry/url-rewriting.yaml +82 -0
- package/rules/semgrep-registry/weak-ssl-context.yaml +34 -0
- package/rules/semgrep-registry/xml-decoder.yaml +53 -0
- package/rules/semgrep-registry/xssrequestwrapper-is-insecure.yaml +40 -0
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
# 逐码 ZhuMa IaC 规则 — Dockerfile 安全检测
|
|
2
|
+
# V4.1 Sprint 3 起步 — 首批5条覆盖最常见的 Docker 镜像构建安全问题
|
|
3
|
+
|
|
4
|
+
rules:
|
|
5
|
+
# ZM-IAC-DOCKER-001: FROM 使用 latest tag
|
|
6
|
+
- id: zm-iac-docker-latest-001
|
|
7
|
+
severity: LOW
|
|
8
|
+
message: |
|
|
9
|
+
FROM 使用 `latest` tag — 每次构建拉取不同镜像,不可重现。
|
|
10
|
+
使用语义化版本固定基础镜像标签,例如 `node:20-alpine` 而非 `node:latest`。
|
|
11
|
+
languages:
|
|
12
|
+
- dockerfile
|
|
13
|
+
pattern: |
|
|
14
|
+
FROM $IMAGE:latest
|
|
15
|
+
metadata:
|
|
16
|
+
cwe: "CWE-1104: Use of Unmaintained Third Party Components"
|
|
17
|
+
owasp: "A06:2021 - Vulnerable and Outdated Components"
|
|
18
|
+
precision: very-high
|
|
19
|
+
tags: [docker, supply-chain, reproducibility]
|
|
20
|
+
|
|
21
|
+
# ZM-IAC-DOCKER-002: RUN curl/wget 后未清理缓存
|
|
22
|
+
- id: zm-iac-docker-curl-cleanup-001
|
|
23
|
+
severity: LOW
|
|
24
|
+
message: |
|
|
25
|
+
`curl`/`wget` 拉取文件后未在同层 `RUN` 中删除临时文件 — 镜像膨胀且残留敏感信息。
|
|
26
|
+
合并为单条 `RUN curl ... && rm -f /tmp/... && apk del curl` 或使用 multi-stage 避免工具链残留。
|
|
27
|
+
languages:
|
|
28
|
+
- dockerfile
|
|
29
|
+
pattern-either:
|
|
30
|
+
- pattern: |
|
|
31
|
+
RUN $CURL ...
|
|
32
|
+
- pattern: |
|
|
33
|
+
RUN $WGET ...
|
|
34
|
+
metadata:
|
|
35
|
+
cwe: "CWE-1104: Use of Unmaintained Third Party Components"
|
|
36
|
+
owasp: "A06:2021 - Vulnerable and Outdated Components"
|
|
37
|
+
precision: low
|
|
38
|
+
tags: [docker, image-size, supply-chain]
|
|
39
|
+
|
|
40
|
+
# ZM-IAC-DOCKER-003: USER root (未降权)
|
|
41
|
+
- id: zm-iac-docker-root-001
|
|
42
|
+
severity: MEDIUM
|
|
43
|
+
message: |
|
|
44
|
+
容器以 `root` 身份运行 — 容器逃逸后拥有宿主机 root 权限。
|
|
45
|
+
Dockerfile 末尾添加 `USER 1000` 切换到非 root 用户,
|
|
46
|
+
或 Kubernetes PodSecurityContext 设置 `runAsNonRoot: true`。
|
|
47
|
+
languages:
|
|
48
|
+
- dockerfile
|
|
49
|
+
pattern: |
|
|
50
|
+
USER root
|
|
51
|
+
pattern-not: |
|
|
52
|
+
USER $NONROOT
|
|
53
|
+
metadata:
|
|
54
|
+
cwe: "CWE-250: Execution with Unnecessary Privileges"
|
|
55
|
+
owasp: "A05:2021 - Security Misconfiguration"
|
|
56
|
+
precision: very-high
|
|
57
|
+
tags: [docker, privilege-escalation, root]
|
|
58
|
+
|
|
59
|
+
# ZM-IAC-DOCKER-004: COPY --chown 缺失(COPY 的文件以 root 拥有)
|
|
60
|
+
- id: zm-iac-docker-chown-001
|
|
61
|
+
severity: LOW
|
|
62
|
+
message: |
|
|
63
|
+
`COPY` 未使用 `--chown` — 文件默认为 `root:root` 拥有,非 root 用户无法读取。
|
|
64
|
+
使用 `COPY --chown=1000:1000 src/ dest/` 将文件所有权授予非 root 用户。
|
|
65
|
+
languages:
|
|
66
|
+
- dockerfile
|
|
67
|
+
pattern: |
|
|
68
|
+
COPY $SRC $DEST
|
|
69
|
+
pattern-not: |
|
|
70
|
+
COPY --chown=$OWNER $SRC $DEST
|
|
71
|
+
metadata:
|
|
72
|
+
cwe: "CWE-732: Incorrect Permission Assignment for Critical Resource"
|
|
73
|
+
owasp: "A05:2021 - Security Misconfiguration"
|
|
74
|
+
precision: low
|
|
75
|
+
tags: [docker, file-permission]
|
|
76
|
+
|
|
77
|
+
# ZM-IAC-DOCKER-005: EXPOSE 敏感端口
|
|
78
|
+
- id: zm-iac-docker-sensitive-port-001
|
|
79
|
+
severity: HIGH
|
|
80
|
+
message: |
|
|
81
|
+
EXPOSE 暴露了数据库/管理/调试端口 — 端口 22(SSH)/2375(Docker)/3306(MySQL)/5432(PostgreSQL)/
|
|
82
|
+
6379(Redis)/27017(MongoDB)/9200(ES)/9090(Prometheus) 不应直接对外。
|
|
83
|
+
仅 EXPOSE 业务端口 (80/443/8080),敏感端口由内部网络或 sidecar 代理访问。
|
|
84
|
+
languages:
|
|
85
|
+
- dockerfile
|
|
86
|
+
pattern-either:
|
|
87
|
+
- pattern: EXPOSE 22
|
|
88
|
+
- pattern: EXPOSE 2375
|
|
89
|
+
- pattern: EXPOSE 3306
|
|
90
|
+
- pattern: EXPOSE 5432
|
|
91
|
+
- pattern: EXPOSE 6379
|
|
92
|
+
- pattern: EXPOSE 27017
|
|
93
|
+
- pattern: EXPOSE 9200
|
|
94
|
+
- pattern: EXPOSE 9090
|
|
95
|
+
- pattern: EXPOSE 9093
|
|
96
|
+
- pattern: EXPOSE 3000
|
|
97
|
+
- pattern: EXPOSE 5000
|
|
98
|
+
- pattern: EXPOSE 8000
|
|
99
|
+
- pattern: EXPOSE 8500
|
|
100
|
+
metadata:
|
|
101
|
+
cwe: "CWE-200: Exposure of Sensitive Information"
|
|
102
|
+
owasp: "A05:2021 - Security Misconfiguration"
|
|
103
|
+
precision: very-high
|
|
104
|
+
tags: [docker, network-exposure, sensitive-port]
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
# 逐码 ZhuMa IaC 规则 — Kubernetes ServiceAccount 安全检测
|
|
2
|
+
# V4.1 Sprint — CWE-200: Exposure of Sensitive Information
|
|
3
|
+
# 检测: ServiceAccount未限制、automountServiceAccountToken未设false、cluster-admin绑定
|
|
4
|
+
|
|
5
|
+
rules:
|
|
6
|
+
# ZM-K8S-CWE200-SA-001: ServiceAccount automountServiceAccountToken 未显式禁用
|
|
7
|
+
- id: zm-k8s-cwe200-sa-001
|
|
8
|
+
severity: MEDIUM
|
|
9
|
+
message: |
|
|
10
|
+
ServiceAccount 未设置 `automountServiceAccountToken: false` — 默认挂载API token到Pod中。
|
|
11
|
+
即使应用不需要访问K8s API,token仍然存在,权限逃逸后可调用API Server。
|
|
12
|
+
|
|
13
|
+
修复:
|
|
14
|
+
1. 在 ServiceAccount 或 Pod spec 中设置: `automountServiceAccountToken: false`
|
|
15
|
+
2. 仅向需要API访问的ServiceAccount授予最低权限
|
|
16
|
+
3. 使用Pod Security Admission限制 automountServiceAccountToken
|
|
17
|
+
languages:
|
|
18
|
+
- yaml
|
|
19
|
+
pattern: |
|
|
20
|
+
automountServiceAccountToken: true
|
|
21
|
+
metadata:
|
|
22
|
+
cwe: "CWE-200: Exposure of Sensitive Information to an Unauthorized Actor"
|
|
23
|
+
category: iac-kubernetes
|
|
24
|
+
precision: very-high
|
|
25
|
+
confidence: high
|
|
26
|
+
tags: [kubernetes, service-account, token-exposure, security-misconfiguration]
|
|
27
|
+
|
|
28
|
+
# ZM-K8S-CWE200-SA-002: ClusterRoleBinding 绑定到默认 ServiceAccount
|
|
29
|
+
- id: zm-k8s-cwe200-sa-002
|
|
30
|
+
severity: CRITICAL
|
|
31
|
+
message: |
|
|
32
|
+
ClusterRoleBinding 将 `cluster-admin` 或高危 ClusterRole 绑定到 `default` ServiceAccount
|
|
33
|
+
或命名空间级别的 ServiceAccount。这授予了集群范围的管理权限。
|
|
34
|
+
|
|
35
|
+
检查 subjects 中的 name 是否为 `default` 或非专用的 ServiceAccount。
|
|
36
|
+
|
|
37
|
+
修复:
|
|
38
|
+
1. 将 cluster-admin 绑定限制为仅系统组件和管理员账户
|
|
39
|
+
2. 为应用创建专用 ServiceAccount 并绑定最小权限 Role
|
|
40
|
+
3. 使用 RoleBinding(命名空间级)替代 ClusterRoleBinding(集群级)
|
|
41
|
+
4. 定期审计 ClusterRoleBinding/subjects
|
|
42
|
+
languages:
|
|
43
|
+
- yaml
|
|
44
|
+
pattern-either:
|
|
45
|
+
- pattern: |
|
|
46
|
+
subjects:
|
|
47
|
+
- kind: ServiceAccount
|
|
48
|
+
name: default
|
|
49
|
+
- pattern: |
|
|
50
|
+
subjects:
|
|
51
|
+
- kind: ServiceAccount
|
|
52
|
+
name: default
|
|
53
|
+
- pattern: |
|
|
54
|
+
subjects: [{kind: ServiceAccount, name: default}]
|
|
55
|
+
metadata:
|
|
56
|
+
cwe: "CWE-200: Exposure of Sensitive Information to an Unauthorized Actor"
|
|
57
|
+
category: iac-kubernetes
|
|
58
|
+
precision: very-high
|
|
59
|
+
confidence: high
|
|
60
|
+
tags: [kubernetes, clusterrole-binding, privilege-escalation, cluster-admin]
|
|
61
|
+
|
|
62
|
+
# ZM-K8S-CWE200-SA-003: Pod spec 中 ServiceAccount 名称为 default
|
|
63
|
+
- id: zm-k8s-cwe200-sa-003
|
|
64
|
+
severity: LOW
|
|
65
|
+
message: |
|
|
66
|
+
Pod 使用 `serviceAccountName: default` — 每个命名空间中的默认 ServiceAccount。
|
|
67
|
+
default ServiceAccount 可能已被授予不必要的权限。
|
|
68
|
+
应为每个应用创建专用 ServiceAccount 并授予最小权限。
|
|
69
|
+
|
|
70
|
+
修复:
|
|
71
|
+
1. 创建应用专用 ServiceAccount: `serviceAccountName: my-app`
|
|
72
|
+
2. 绑定最小权限 Role(非 cluster-admin)
|
|
73
|
+
3. 设置 `automountServiceAccountToken: false` 如不需要K8s API访问
|
|
74
|
+
languages:
|
|
75
|
+
- yaml
|
|
76
|
+
pattern: |
|
|
77
|
+
serviceAccountName: default
|
|
78
|
+
metadata:
|
|
79
|
+
cwe: "CWE-200: Exposure of Sensitive Information to an Unauthorized Actor"
|
|
80
|
+
category: iac-kubernetes
|
|
81
|
+
precision: very-high
|
|
82
|
+
confidence: high
|
|
83
|
+
tags: [kubernetes, service-account, best-practice, least-privilege]
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
# 逐码 ZhuMa IaC 规则 — Kubernetes 特权容器深度检测
|
|
2
|
+
# V4.1 Sprint — CWE-250: Execution with Unnecessary Privileges
|
|
3
|
+
|
|
4
|
+
rules:
|
|
5
|
+
# ZM-K8S-CWE250-001: hostNetwork: true
|
|
6
|
+
- id: zm-k8s-cwe250-priv-001
|
|
7
|
+
severity: HIGH
|
|
8
|
+
message: |
|
|
9
|
+
Pod 启用 `hostNetwork: true` — 容器共享宿主机网络命名空间,可监听宿主机端口、嗅探网络流量。
|
|
10
|
+
除非是 CNI 插件或网络监控组件,否则应移除 `hostNetwork: true` 并使用 ClusterIP/NodePort 暴露服务。
|
|
11
|
+
languages:
|
|
12
|
+
- yaml
|
|
13
|
+
pattern: |
|
|
14
|
+
hostNetwork: true
|
|
15
|
+
metadata:
|
|
16
|
+
cwe: "CWE-250: Execution with Unnecessary Privileges"
|
|
17
|
+
category: iac-kubernetes
|
|
18
|
+
precision: very-high
|
|
19
|
+
confidence: high
|
|
20
|
+
tags: [kubernetes, hostNetwork, privilege-escalation, network-isolation]
|
|
21
|
+
|
|
22
|
+
# ZM-K8S-CWE250-002: hostPID: true
|
|
23
|
+
- id: zm-k8s-cwe250-priv-002
|
|
24
|
+
severity: CRITICAL
|
|
25
|
+
message: |
|
|
26
|
+
Pod 启用 `hostPID: true` — 容器可查看和操作宿主机上的所有进程,可通过 `/proc` 直接与主机进程交互。
|
|
27
|
+
这是一种极度危险的配置,攻击者可以利用它向主机进程注入恶意代码。
|
|
28
|
+
除非绝对必要(如 node-exporter 等监控组件),否则应移除 `hostPID: true`。
|
|
29
|
+
languages:
|
|
30
|
+
- yaml
|
|
31
|
+
pattern: |
|
|
32
|
+
hostPID: true
|
|
33
|
+
metadata:
|
|
34
|
+
cwe: "CWE-250: Execution with Unnecessary Privileges"
|
|
35
|
+
category: iac-kubernetes
|
|
36
|
+
precision: very-high
|
|
37
|
+
confidence: high
|
|
38
|
+
tags: [kubernetes, hostPID, privilege-escalation, process-injection]
|
|
39
|
+
|
|
40
|
+
# ZM-K8S-CWE250-003: hostIPC: true
|
|
41
|
+
- id: zm-k8s-cwe250-priv-003
|
|
42
|
+
severity: HIGH
|
|
43
|
+
message: |
|
|
44
|
+
Pod 启用 `hostIPC: true` — 容器可访问宿主机进程间通信 (IPC) 命名空间,包括共享内存段和信号量。
|
|
45
|
+
这允许容器与宿主机上其他进程通过共享内存交互,可能被利用进行权限提升攻击。
|
|
46
|
+
除非是特定的系统组件,否则应移除 `hostIPC: true`。
|
|
47
|
+
languages:
|
|
48
|
+
- yaml
|
|
49
|
+
pattern: |
|
|
50
|
+
hostIPC: true
|
|
51
|
+
metadata:
|
|
52
|
+
cwe: "CWE-250: Execution with Unnecessary Privileges"
|
|
53
|
+
category: iac-kubernetes
|
|
54
|
+
precision: very-high
|
|
55
|
+
confidence: high
|
|
56
|
+
tags: [kubernetes, hostIPC, privilege-escalation, ipc-namespace]
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
# 逐码 ZhuMa IaC 规则 — Kubernetes 安全检测
|
|
2
|
+
# V4.1 Sprint 3 — 首批3条 K8s 最常见安全配置问题
|
|
3
|
+
|
|
4
|
+
rules:
|
|
5
|
+
# ZM-IAC-K8S-001: runAsNonRoot 未设置
|
|
6
|
+
- id: zm-iac-k8s-nonroot-001
|
|
7
|
+
severity: HIGH
|
|
8
|
+
message: |
|
|
9
|
+
Pod/容器未设置 `runAsNonRoot: true` — 容器可以以 root 身份运行。
|
|
10
|
+
在 Pod securityContext 或 Container securityContext 中添加:
|
|
11
|
+
```yaml
|
|
12
|
+
securityContext:
|
|
13
|
+
runAsNonRoot: true
|
|
14
|
+
runAsUser: 1000
|
|
15
|
+
```
|
|
16
|
+
languages:
|
|
17
|
+
- yaml
|
|
18
|
+
pattern: |
|
|
19
|
+
containers:
|
|
20
|
+
- name: $NAME
|
|
21
|
+
image: $IMAGE
|
|
22
|
+
pattern-not: |
|
|
23
|
+
containers:
|
|
24
|
+
- name: $NAME
|
|
25
|
+
image: $IMAGE
|
|
26
|
+
securityContext:
|
|
27
|
+
...
|
|
28
|
+
runAsNonRoot: $VAL
|
|
29
|
+
metadata:
|
|
30
|
+
cwe: "CWE-250: Execution with Unnecessary Privileges"
|
|
31
|
+
owasp: "A05:2021 - Security Misconfiguration"
|
|
32
|
+
precision: medium
|
|
33
|
+
tags: [kubernetes, privilege-escalation, securitycontext]
|
|
34
|
+
|
|
35
|
+
# ZM-IAC-K8S-002: privileged: true
|
|
36
|
+
- id: zm-iac-k8s-privileged-001
|
|
37
|
+
severity: CRITICAL
|
|
38
|
+
message: |
|
|
39
|
+
容器以 `privileged: true` 运行 — 该容器获得宿主机的所有 Linux Capabilities,
|
|
40
|
+
包括加载内核模块、访问所有设备。除非是系统级组件 (如 kube-proxy、CNI 插件),
|
|
41
|
+
否则应移除 `privileged: true` 并使用细粒度 `capabilities` 声明。
|
|
42
|
+
languages:
|
|
43
|
+
- yaml
|
|
44
|
+
pattern: |
|
|
45
|
+
privileged: true
|
|
46
|
+
metadata:
|
|
47
|
+
cwe: "CWE-250: Execution with Unnecessary Privileges"
|
|
48
|
+
owasp: "A05:2021 - Security Misconfiguration"
|
|
49
|
+
precision: very-high
|
|
50
|
+
tags: [kubernetes, privileged-container, rce, escape]
|
|
51
|
+
|
|
52
|
+
# ZM-IAC-K8S-003: allowPrivilegeEscalation 未显式禁用
|
|
53
|
+
- id: zm-iac-k8s-allow-escalation-001
|
|
54
|
+
severity: MEDIUM
|
|
55
|
+
message: |
|
|
56
|
+
未显式设置 `allowPrivilegeEscalation: false` — 默认允许子进程获取比父进程更多的特权。
|
|
57
|
+
在容器 securityContext 中添加:
|
|
58
|
+
```yaml
|
|
59
|
+
securityContext:
|
|
60
|
+
allowPrivilegeEscalation: false
|
|
61
|
+
```
|
|
62
|
+
languages:
|
|
63
|
+
- yaml
|
|
64
|
+
pattern: |
|
|
65
|
+
containers:
|
|
66
|
+
- name: $NAME
|
|
67
|
+
image: $IMAGE
|
|
68
|
+
pattern-not: |
|
|
69
|
+
containers:
|
|
70
|
+
- name: $NAME
|
|
71
|
+
image: $IMAGE
|
|
72
|
+
securityContext:
|
|
73
|
+
...
|
|
74
|
+
allowPrivilegeEscalation: $VAL
|
|
75
|
+
metadata:
|
|
76
|
+
cwe: "CWE-250: Execution with Unnecessary Privileges"
|
|
77
|
+
owasp: "A05:2021 - Security Misconfiguration"
|
|
78
|
+
precision: medium
|
|
79
|
+
tags: [kubernetes, privilege-escalation, securitycontext]
|