@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,125 @@
|
|
|
1
|
+
# CWE-489: Weak Root Detection and Anti-Tamper Patterns (Android)
|
|
2
|
+
# ZhuMa V4.0 - Android Rule Library
|
|
3
|
+
# Source: ZhuMa V4.1 Rule Expansion - root detection and integrity gaps
|
|
4
|
+
|
|
5
|
+
rules:
|
|
6
|
+
- id: zm-android-weak-root-detection
|
|
7
|
+
severity: MEDIUM
|
|
8
|
+
message: |
|
|
9
|
+
Detected weak root detection pattern that only checks for common 'su' binary paths
|
|
10
|
+
or Superuser.apk existence. These checks are trivially bypassed by Magisk, KernelSU,
|
|
11
|
+
or APatch which can hide su and mount custom paths.
|
|
12
|
+
Remediation: Use multiple detection methods: check system properties (ro.debuggable, ro.secure),
|
|
13
|
+
check for magisk binaries, verify bootloader status, check for test-keys build,
|
|
14
|
+
and use SafetyNet/Play Integrity as an additional signal.
|
|
15
|
+
languages:
|
|
16
|
+
- java
|
|
17
|
+
patterns:
|
|
18
|
+
- pattern-either:
|
|
19
|
+
- pattern: |
|
|
20
|
+
new File("/system/app/Superuser.apk").exists()
|
|
21
|
+
- pattern: |
|
|
22
|
+
new File("/system/bin/su").exists()
|
|
23
|
+
- pattern: |
|
|
24
|
+
new File("/sbin/su").exists()
|
|
25
|
+
- pattern: |
|
|
26
|
+
new File("/system/xbin/su").exists()
|
|
27
|
+
- pattern: |
|
|
28
|
+
new File("/data/local/xbin/su").exists()
|
|
29
|
+
- pattern: |
|
|
30
|
+
new File("/data/local/bin/su").exists()
|
|
31
|
+
- pattern: |
|
|
32
|
+
new File("/vendor/bin/su").exists()
|
|
33
|
+
- pattern: |
|
|
34
|
+
new File("/system/sd/xbin/su").exists()
|
|
35
|
+
metadata:
|
|
36
|
+
cwe: "CWE-489: Active Debug Code / Leftover Debug Code"
|
|
37
|
+
owasp-mobile: "M8: Code Tampering"
|
|
38
|
+
masvs: "MASVS-RESILIENCE-1"
|
|
39
|
+
category: android-anti-tamper
|
|
40
|
+
precision: very-high
|
|
41
|
+
confidence: very-high
|
|
42
|
+
source: "ZhuMa V4.1 Rule Expansion"
|
|
43
|
+
references:
|
|
44
|
+
- https://cwe.mitre.org/data/definitions/489.html
|
|
45
|
+
- https://developer.android.com/privacy-and-security/risks/root-detection
|
|
46
|
+
|
|
47
|
+
- id: zm-android-root-check-exec-su
|
|
48
|
+
severity: MEDIUM
|
|
49
|
+
message: |
|
|
50
|
+
Detected Runtime.exec("su") or ProcessBuilder("su") for root detection.
|
|
51
|
+
Executing 'su' on a rooted device triggers a Superuser prompt, alerting the user
|
|
52
|
+
that the app is performing root detection. Modern root solutions can also intercept this.
|
|
53
|
+
Remediation: Use passive detection methods that do not trigger shell execution or user prompts.
|
|
54
|
+
languages:
|
|
55
|
+
- java
|
|
56
|
+
patterns:
|
|
57
|
+
- pattern-either:
|
|
58
|
+
- pattern: Runtime.getRuntime().exec("su")
|
|
59
|
+
- pattern: Runtime.getRuntime().exec("su -c")
|
|
60
|
+
- pattern: Runtime.getRuntime().exec(new String[] {"su", "-c", "$CMD"})
|
|
61
|
+
- pattern: $RT.exec("su")
|
|
62
|
+
metadata:
|
|
63
|
+
cwe: "CWE-489: Active Debug Code / Leftover Debug Code"
|
|
64
|
+
owasp-mobile: "M8: Code Tampering"
|
|
65
|
+
masvs: "MASVS-RESILIENCE-1"
|
|
66
|
+
category: android-anti-tamper
|
|
67
|
+
precision: high
|
|
68
|
+
confidence: high
|
|
69
|
+
source: "ZhuMa V4.1 Rule Expansion"
|
|
70
|
+
references:
|
|
71
|
+
- https://cwe.mitre.org/data/definitions/489.html
|
|
72
|
+
|
|
73
|
+
- id: zm-android-root-beer-library-check
|
|
74
|
+
severity: INFO
|
|
75
|
+
message: |
|
|
76
|
+
Detected RootBeer library usage for root detection.
|
|
77
|
+
RootBeer uses well-known detection methods that are specifically targeted by MagiskHide
|
|
78
|
+
and other root-hiding frameworks. Consider supplementing with additional techniques.
|
|
79
|
+
Remediation: Combine RootBeer with native checks (TracerPid, proc maps), Play Integrity API,
|
|
80
|
+
and obfuscated detection logic.
|
|
81
|
+
languages:
|
|
82
|
+
- java
|
|
83
|
+
patterns:
|
|
84
|
+
- pattern-either:
|
|
85
|
+
- pattern: RootBeer($CTX).isRooted()
|
|
86
|
+
- pattern: new RootBeer($CTX).isRooted()
|
|
87
|
+
- pattern: new com.scottyab.rootbeer.RootBeer($CTX).isRooted()
|
|
88
|
+
metadata:
|
|
89
|
+
cwe: "CWE-489: Active Debug Code / Leftover Debug Code"
|
|
90
|
+
owasp-mobile: "M8: Code Tampering"
|
|
91
|
+
masvs: "MASVS-RESILIENCE-1"
|
|
92
|
+
category: android-anti-tamper
|
|
93
|
+
precision: very-high
|
|
94
|
+
confidence: very-high
|
|
95
|
+
source: "ZhuMa V4.1 Rule Expansion"
|
|
96
|
+
references:
|
|
97
|
+
- https://cwe.mitre.org/data/definitions/489.html
|
|
98
|
+
|
|
99
|
+
- id: zm-android-emulator-detection-only
|
|
100
|
+
severity: LOW
|
|
101
|
+
message: |
|
|
102
|
+
Detected emulator detection using Build.FINGERPRINT or Build.MODEL checks only.
|
|
103
|
+
These checks are easily spoofed by modifying system properties.
|
|
104
|
+
Remediation: Use hardware-backed attestation (KeyStore with TEE attestation) for stronger checks.
|
|
105
|
+
languages:
|
|
106
|
+
- java
|
|
107
|
+
patterns:
|
|
108
|
+
- pattern-either:
|
|
109
|
+
- pattern: $BUILD_FINGERPRINT.contains("generic")
|
|
110
|
+
- pattern: $BUILD_FINGERPRINT.contains("sdk")
|
|
111
|
+
- pattern: Build.FINGERPRINT.startsWith("generic")
|
|
112
|
+
- pattern: Build.MODEL.contains("google_sdk")
|
|
113
|
+
- pattern: Build.MODEL.contains("Emulator")
|
|
114
|
+
- pattern: Build.MODEL.contains("Android SDK")
|
|
115
|
+
- pattern: Build.MANUFACTURER.contains("Genymotion")
|
|
116
|
+
metadata:
|
|
117
|
+
cwe: "CWE-489: Active Debug Code / Leftover Debug Code"
|
|
118
|
+
owasp-mobile: "M8: Code Tampering"
|
|
119
|
+
masvs: "MASVS-RESILIENCE-2"
|
|
120
|
+
category: android-anti-tamper
|
|
121
|
+
precision: high
|
|
122
|
+
confidence: high
|
|
123
|
+
source: "ZhuMa V4.1 Rule Expansion"
|
|
124
|
+
references:
|
|
125
|
+
- https://cwe.mitre.org/data/definitions/489.html
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
# CWE-489: Debug Bridge Detection - Stetho / Flipper / Debug Tools in Release (Android)
|
|
2
|
+
# ZhuMa V4.0 - Android Rule Library
|
|
3
|
+
# Source: ZhuMa V4.1 Rule Expansion - debug tool leakage
|
|
4
|
+
|
|
5
|
+
rules:
|
|
6
|
+
- id: zm-android-stetho-debug-bridge
|
|
7
|
+
severity: MEDIUM
|
|
8
|
+
message: |
|
|
9
|
+
Detected Facebook Stetho initialization. Stetho enables Chrome DevTools inspection of the app's
|
|
10
|
+
network traffic, databases, and SharedPreferences. If this leaks into a release build,
|
|
11
|
+
attackers can attach DevTools and exfiltrate sensitive data.
|
|
12
|
+
Remediation: Wrap Stetho initialization in a BuildConfig.DEBUG check, or use debugImplementation
|
|
13
|
+
dependency scope so it is stripped from release builds.
|
|
14
|
+
languages:
|
|
15
|
+
- java
|
|
16
|
+
patterns:
|
|
17
|
+
- pattern-either:
|
|
18
|
+
- pattern: Stetho.initializeWithDefaults($CTX)
|
|
19
|
+
- pattern: Stetho.initialize($INITIALIZER)
|
|
20
|
+
- pattern: new Stetho.DefaultInspectorModulesBuilder($CTX).build()
|
|
21
|
+
- pattern: com.facebook.stetho.Stetho.initializeWithDefaults($CTX)
|
|
22
|
+
metadata:
|
|
23
|
+
cwe: "CWE-489: Active Debug Code / Leftover Debug Code"
|
|
24
|
+
owasp-mobile: "M8: Code Tampering"
|
|
25
|
+
masvs: "MASVS-RESILIENCE-2"
|
|
26
|
+
category: android-debug
|
|
27
|
+
precision: very-high
|
|
28
|
+
confidence: very-high
|
|
29
|
+
source: "ZhuMa V4.1 Rule Expansion"
|
|
30
|
+
references:
|
|
31
|
+
- https://cwe.mitre.org/data/definitions/489.html
|
|
32
|
+
- https://facebook.github.io/stetho/
|
|
33
|
+
|
|
34
|
+
- id: zm-android-flipper-debug-bridge
|
|
35
|
+
severity: MEDIUM
|
|
36
|
+
message: |
|
|
37
|
+
Detected Facebook Flipper debug bridge initialization. Flipper provides a desktop debugging
|
|
38
|
+
interface for inspecting network traffic, databases, and app state. In release builds,
|
|
39
|
+
this creates a data exfiltration surface.
|
|
40
|
+
Remediation: Use debugImplementation for Flipper dependencies and guard initialization with BuildConfig.DEBUG.
|
|
41
|
+
languages:
|
|
42
|
+
- java
|
|
43
|
+
patterns:
|
|
44
|
+
- pattern-either:
|
|
45
|
+
- pattern: SoLoader.init($CTX, false)
|
|
46
|
+
- pattern: Flipper.init($CTX, $CONFIG)
|
|
47
|
+
- pattern: com.facebook.flipper.android.Flipper.init($CTX, $CONFIG)
|
|
48
|
+
- pattern: new FlipperClient($CTX)
|
|
49
|
+
- pattern: $CLIENT.addPlugin($PLUGIN)
|
|
50
|
+
metadata:
|
|
51
|
+
cwe: "CWE-489: Active Debug Code / Leftover Debug Code"
|
|
52
|
+
owasp-mobile: "M8: Code Tampering"
|
|
53
|
+
masvs: "MASVS-RESILIENCE-2"
|
|
54
|
+
category: android-debug
|
|
55
|
+
precision: medium
|
|
56
|
+
confidence: medium
|
|
57
|
+
source: "ZhuMa V4.1 Rule Expansion"
|
|
58
|
+
references:
|
|
59
|
+
- https://cwe.mitre.org/data/definitions/489.html
|
|
60
|
+
|
|
61
|
+
- id: zm-android-chuck-interceptor-debug
|
|
62
|
+
severity: MEDIUM
|
|
63
|
+
message: |
|
|
64
|
+
Detected Chuck HTTP interceptor initialization. Chuck captures all HTTP traffic and
|
|
65
|
+
exposes it through a notification-based UI. Leaving this in release builds leaks all
|
|
66
|
+
API requests, responses, tokens, and credentials to anyone with physical access.
|
|
67
|
+
Remediation: Use debugImplementation for Chuck and guard with BuildConfig.DEBUG.
|
|
68
|
+
languages:
|
|
69
|
+
- java
|
|
70
|
+
patterns:
|
|
71
|
+
- pattern-either:
|
|
72
|
+
- pattern: new ChuckInterceptor($CTX)
|
|
73
|
+
- pattern: com.readystatesoftware.chuck.ChuckInterceptor($CTX)
|
|
74
|
+
metadata:
|
|
75
|
+
cwe: "CWE-489: Active Debug Code / Leftover Debug Code"
|
|
76
|
+
owasp-mobile: "M8: Code Tampering"
|
|
77
|
+
masvs: "MASVS-RESILIENCE-2"
|
|
78
|
+
category: android-debug
|
|
79
|
+
precision: very-high
|
|
80
|
+
confidence: very-high
|
|
81
|
+
source: "ZhuMa V4.1 Rule Expansion"
|
|
82
|
+
references:
|
|
83
|
+
- https://cwe.mitre.org/data/definitions/489.html
|
|
84
|
+
|
|
85
|
+
- id: zm-android-leakcanary-debug
|
|
86
|
+
severity: LOW
|
|
87
|
+
message: |
|
|
88
|
+
Detected LeakCanary memory leak detector initialization in potential release code.
|
|
89
|
+
LeakCanary adds a launcher icon and notification in debug builds, which is a
|
|
90
|
+
signal that the app is debuggable or has debug code.
|
|
91
|
+
Remediation: Use debugImplementation for LeakCanary dependency.
|
|
92
|
+
languages:
|
|
93
|
+
- java
|
|
94
|
+
patterns:
|
|
95
|
+
- pattern-either:
|
|
96
|
+
- pattern: LeakCanary.install($APP)
|
|
97
|
+
- pattern: com.squareup.leakcanary.LeakCanary.install($APP)
|
|
98
|
+
metadata:
|
|
99
|
+
cwe: "CWE-489: Active Debug Code / Leftover Debug Code"
|
|
100
|
+
owasp-mobile: "M8: Code Tampering"
|
|
101
|
+
masvs: "MASVS-RESILIENCE-2"
|
|
102
|
+
category: android-debug
|
|
103
|
+
precision: very-high
|
|
104
|
+
confidence: very-high
|
|
105
|
+
source: "ZhuMa V4.1 Rule Expansion"
|
|
106
|
+
references:
|
|
107
|
+
- https://cwe.mitre.org/data/definitions/489.html
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
# CWE-502: 不安全反序列化 / 序列化注入 (Android)
|
|
2
|
+
# 逐码 ZhuMa V4.0 — Android 规则库
|
|
3
|
+
# 来源: V3 审计引擎 VULN-SE-001 / VULN-SE-002
|
|
4
|
+
|
|
5
|
+
rules:
|
|
6
|
+
- id: zm-android-serializable-readobject-intent-extra
|
|
7
|
+
severity: CRITICAL
|
|
8
|
+
message: |
|
|
9
|
+
检测到可序列化对象通过 Intent 传递 + readObject() 自定义实现。
|
|
10
|
+
这构成反序列化注入攻击面 (CVE-2020-0069 类似)。
|
|
11
|
+
如果接收方组件为导出组件(exported=true),攻击者可通过构造恶意序列化对象
|
|
12
|
+
触发 readObject() 中的代码执行 — 在 Android Binder 反序列化过程中即可触发。
|
|
13
|
+
修复: 禁用 Java 原生 Serializable,改用 Parcelable;
|
|
14
|
+
或对 readObject() 做严格的类型安全校验和 whitelist。
|
|
15
|
+
languages:
|
|
16
|
+
- java
|
|
17
|
+
patterns:
|
|
18
|
+
- pattern: |
|
|
19
|
+
class $CLASS implements Serializable {
|
|
20
|
+
...
|
|
21
|
+
private void readObject(ObjectInputStream $S) {
|
|
22
|
+
...
|
|
23
|
+
}
|
|
24
|
+
...
|
|
25
|
+
}
|
|
26
|
+
- pattern-inside: |
|
|
27
|
+
...
|
|
28
|
+
$INTENT.putExtra($KEY, $OBJECT);
|
|
29
|
+
...
|
|
30
|
+
metadata:
|
|
31
|
+
cwe: "CWE-502: Deserialization of Untrusted Data"
|
|
32
|
+
owasp-mobile: "M8: Code Tampering"
|
|
33
|
+
masvs: "MASVS-CODE-4"
|
|
34
|
+
category: android-serialization
|
|
35
|
+
precision: medium
|
|
36
|
+
confidence: medium
|
|
37
|
+
likelihood: medium
|
|
38
|
+
impact: critical
|
|
39
|
+
source: "V3 Audit Engine - VULN-SE-001"
|
|
40
|
+
references:
|
|
41
|
+
- https://cwe.mitre.org/data/definitions/502.html
|
|
42
|
+
- https://nvd.nist.gov/vuln/detail/CVE-2020-0069
|
|
43
|
+
|
|
44
|
+
- id: zm-android-parcelable-no-instanceof-check
|
|
45
|
+
severity: HIGH
|
|
46
|
+
message: |
|
|
47
|
+
检测到 getParcelableExtra() / getParcelable() 的结果未做 instanceof 检查
|
|
48
|
+
就直接强制类型转换。攻击者可通过 Intent 注入传递类型不匹配的 Parcelable,
|
|
49
|
+
导致意外的类型转换或内存布局利用。
|
|
50
|
+
修复: 提取 Parcelable 后始终先做 instanceof 检查再强制转换。
|
|
51
|
+
languages:
|
|
52
|
+
- java
|
|
53
|
+
patterns:
|
|
54
|
+
- pattern-either:
|
|
55
|
+
- pattern: |
|
|
56
|
+
($TYPE) $INTENT.getParcelableExtra($KEY)
|
|
57
|
+
- pattern: |
|
|
58
|
+
($TYPE) getIntent().getParcelableExtra($KEY)
|
|
59
|
+
- pattern: |
|
|
60
|
+
($TYPE) $BUNDLE.getParcelable($KEY)
|
|
61
|
+
- pattern-not: |
|
|
62
|
+
if ($OBJ instanceof $TYPE) {
|
|
63
|
+
...
|
|
64
|
+
($TYPE) $INTENT.getParcelableExtra($KEY);
|
|
65
|
+
...
|
|
66
|
+
}
|
|
67
|
+
metadata:
|
|
68
|
+
cwe: "CWE-502: Deserialization of Untrusted Data"
|
|
69
|
+
owasp-mobile: "M8: Code Tampering"
|
|
70
|
+
masvs: "MASVS-CODE-4"
|
|
71
|
+
category: android-serialization
|
|
72
|
+
precision: medium
|
|
73
|
+
confidence: low
|
|
74
|
+
source: "V3 Audit Engine - VULN-SE-002"
|
|
75
|
+
references:
|
|
76
|
+
- https://developer.android.com/reference/android/os/Bundle#getParcelable(java.lang.String,%20java.lang.Class%3CT%3E)
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
# CWE-552: 文件全局可读 (Android)
|
|
2
|
+
# 逐码 ZhuMa V4.0 — Android 规则库
|
|
3
|
+
# 来源: V3 审计引擎 VULN-FD-002
|
|
4
|
+
|
|
5
|
+
rules:
|
|
6
|
+
- id: zm-android-world-readable-writable
|
|
7
|
+
severity: HIGH
|
|
8
|
+
message: |
|
|
9
|
+
检测到使用已废弃的 MODE_WORLD_READABLE 或 MODE_WORLD_WRITEABLE 文件模式。
|
|
10
|
+
这使得任何 APP 都可以读取/写入该文件,导致敏感数据泄露或配置篡改。
|
|
11
|
+
Android 7.0+ 已完全禁止此模式(将抛出 SecurityException)。
|
|
12
|
+
修复: 使用 Context.MODE_PRIVATE;跨进程共享数据使用 ContentProvider。
|
|
13
|
+
languages:
|
|
14
|
+
- java
|
|
15
|
+
patterns:
|
|
16
|
+
- pattern-either:
|
|
17
|
+
- pattern: |
|
|
18
|
+
$CTX.openFileOutput($NAME, Context.MODE_WORLD_READABLE)
|
|
19
|
+
- pattern: |
|
|
20
|
+
$CTX.openFileOutput($NAME, Context.MODE_WORLD_WRITEABLE)
|
|
21
|
+
- pattern: |
|
|
22
|
+
getSharedPreferences($NAME, Context.MODE_WORLD_READABLE)
|
|
23
|
+
- pattern: |
|
|
24
|
+
getSharedPreferences($NAME, Context.MODE_WORLD_WRITEABLE)
|
|
25
|
+
metadata:
|
|
26
|
+
cwe: "CWE-552: Files or Directories Accessible to External Parties"
|
|
27
|
+
owasp-mobile: "M8: Security Decisions Via Untrusted Inputs"
|
|
28
|
+
masvs: "MASVS-STORAGE-2"
|
|
29
|
+
category: android-storage
|
|
30
|
+
precision: very-high
|
|
31
|
+
confidence: very-high
|
|
32
|
+
likelihood: medium
|
|
33
|
+
impact: high
|
|
34
|
+
source: "V3 Audit Engine - VULN-FD-002"
|
|
35
|
+
references:
|
|
36
|
+
- https://developer.android.com/reference/android/content/Context#MODE_WORLD_READABLE
|
|
37
|
+
- https://developer.android.com/privacy-and-security/risks/world-readable
|
|
38
|
+
|
|
39
|
+
- id: zm-android-world-readable-sharedpref
|
|
40
|
+
severity: HIGH
|
|
41
|
+
message: |
|
|
42
|
+
检测到已废弃的 MODE_MULTI_PROCESS SharedPreferences 模式。
|
|
43
|
+
多进程同时写入 SP 可能导致 XML 损坏、安全配置回退到不安全默认值。
|
|
44
|
+
修复: 跨进程数据共享使用 ContentProvider 或 DataStore。
|
|
45
|
+
languages:
|
|
46
|
+
- java
|
|
47
|
+
patterns:
|
|
48
|
+
- pattern-either:
|
|
49
|
+
- pattern: |
|
|
50
|
+
$CTX.getSharedPreferences($NAME, Context.MODE_MULTI_PROCESS)
|
|
51
|
+
- pattern: |
|
|
52
|
+
getSharedPreferences($NAME, Context.MODE_MULTI_PROCESS)
|
|
53
|
+
metadata:
|
|
54
|
+
cwe: "CWE-367: Time-of-check Time-of-use (TOCTOU) Race Condition"
|
|
55
|
+
owasp-mobile: "M8: Security Decisions Via Untrusted Inputs"
|
|
56
|
+
masvs: "MASVS-STORAGE-2"
|
|
57
|
+
category: android-storage
|
|
58
|
+
precision: very-high
|
|
59
|
+
confidence: very-high
|
|
60
|
+
source: "V3 Audit Engine - VULN-TOCTOU-002"
|
|
61
|
+
references:
|
|
62
|
+
- https://developer.android.com/reference/android/content/Context#MODE_MULTI_PROCESS
|
|
63
|
+
- https://developer.android.com/topic/libraries/architecture/datastore
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
# CWE-749: WebView addJavascriptInterface Without Annotation (Android)
|
|
2
|
+
# ZhuMa V4.0 - Android Rule Library
|
|
3
|
+
# Source: ZhuMa V4.1 Rule Expansion - JSBridge hardening
|
|
4
|
+
|
|
5
|
+
rules:
|
|
6
|
+
- id: zm-android-addjavascriptinterface-no-annotation
|
|
7
|
+
severity: HIGH
|
|
8
|
+
message: |
|
|
9
|
+
Detected addJavascriptInterface() exposing an object whose methods lack @JavascriptInterface annotation.
|
|
10
|
+
On API < 17 (Android 4.2), all public methods are exposed. On API >= 17, only annotated methods
|
|
11
|
+
are exposed. However, the exposed object may inadvertently inherit dangerous methods
|
|
12
|
+
(e.g., getClass() leading to Runtime.exec() via reflection) if not carefully restricted.
|
|
13
|
+
Remediation: Ensure all exposed methods have @JavascriptInterface annotation.
|
|
14
|
+
Restrict the interface to minimal required methods. Consider message-passing patterns instead.
|
|
15
|
+
languages:
|
|
16
|
+
- java
|
|
17
|
+
patterns:
|
|
18
|
+
- pattern-either:
|
|
19
|
+
- pattern: $WV.addJavascriptInterface($OBJ, "$NAME")
|
|
20
|
+
metadata:
|
|
21
|
+
cwe: "CWE-749: Exposed Dangerous Method or Function"
|
|
22
|
+
owasp-mobile: "M1: Improper Platform Usage"
|
|
23
|
+
masvs: "MASVS-PLATFORM-2"
|
|
24
|
+
category: android-webview
|
|
25
|
+
precision: medium
|
|
26
|
+
confidence: medium
|
|
27
|
+
source: "ZhuMa V4.1 Rule Expansion"
|
|
28
|
+
references:
|
|
29
|
+
- https://cwe.mitre.org/data/definitions/749.html
|
|
30
|
+
- https://developer.android.com/privacy-and-security/risks/webview-addjavascriptinterface
|
|
31
|
+
|
|
32
|
+
- id: zm-android-javascriptinterface-exposed-getclass
|
|
33
|
+
severity: CRITICAL
|
|
34
|
+
message: |
|
|
35
|
+
Detected a class used with addJavascriptInterface() that has a method returning Class or Method objects.
|
|
36
|
+
JavaScript can traverse getClass() to access Runtime.getRuntime().exec(), achieving RCE in the app context.
|
|
37
|
+
This is the classic WebView RCE attack (CVE-2012-6636 and variants).
|
|
38
|
+
Remediation: Never expose objects with reflection-capable methods. Filter exposed methods carefully.
|
|
39
|
+
languages:
|
|
40
|
+
- java
|
|
41
|
+
patterns:
|
|
42
|
+
- pattern-either:
|
|
43
|
+
- pattern: addJavascriptInterface($OBJ, "$NAME")
|
|
44
|
+
metadata:
|
|
45
|
+
cwe: "CWE-749: Exposed Dangerous Method or Function"
|
|
46
|
+
owasp-mobile: "M1: Improper Platform Usage"
|
|
47
|
+
masvs: "MASVS-PLATFORM-2"
|
|
48
|
+
category: android-webview
|
|
49
|
+
precision: low
|
|
50
|
+
confidence: low
|
|
51
|
+
source: "ZhuMa V4.1 Rule Expansion"
|
|
52
|
+
references:
|
|
53
|
+
- https://cwe.mitre.org/data/definitions/749.html
|
|
54
|
+
- https://labs.f-secure.com/archive/webview-addjavascriptinterface-remote-code-execution/
|
|
55
|
+
|
|
56
|
+
- id: zm-android-javascriptinterface-annotation-check
|
|
57
|
+
severity: MEDIUM
|
|
58
|
+
message: |
|
|
59
|
+
Detected a class potentially exposed via addJavascriptInterface.
|
|
60
|
+
Review that all public methods accessible from JavaScript have @android.webkit.JavascriptInterface annotation
|
|
61
|
+
and do not expose dangerous functionality (file I/O, reflection, command execution).
|
|
62
|
+
languages:
|
|
63
|
+
- generic
|
|
64
|
+
patterns:
|
|
65
|
+
- pattern-either:
|
|
66
|
+
- pattern: |
|
|
67
|
+
$CLASS implements JavascriptInterface
|
|
68
|
+
- pattern: $CLASS extends JavascriptInterface
|
|
69
|
+
metadata:
|
|
70
|
+
cwe: "CWE-749: Exposed Dangerous Method or Function"
|
|
71
|
+
owasp-mobile: "M1: Improper Platform Usage"
|
|
72
|
+
masvs: "MASVS-PLATFORM-2"
|
|
73
|
+
category: android-webview
|
|
74
|
+
precision: low
|
|
75
|
+
confidence: low
|
|
76
|
+
source: "ZhuMa V4.1 Rule Expansion"
|
|
77
|
+
references:
|
|
78
|
+
- https://cwe.mitre.org/data/definitions/749.html
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
# CWE-749: WebView JS Bridge 暴露危险方法 (Android)
|
|
2
|
+
# 逐码 ZhuMa V4.0 — Android 规则库
|
|
3
|
+
# 来源: V3 审计引擎 VULN-WV-002 / VULN-WV-003
|
|
4
|
+
|
|
5
|
+
rules:
|
|
6
|
+
- id: zm-android-webview-jsbridge-with-addjavascriptinterface
|
|
7
|
+
severity: CRITICAL
|
|
8
|
+
message: |
|
|
9
|
+
检测到 WebView 使用 addJavascriptInterface() 暴露 Java 对象给 JavaScript。
|
|
10
|
+
如果暴露的对象包含危险方法(如 Runtime.exec、反射调用、文件操作),
|
|
11
|
+
攻击者可通过构造恶意 HTML 或 XSS 实现远程代码执行 (RCE)。
|
|
12
|
+
本规则检测到 JS Bridge 已启用 + 暴露类中包含危险方法签名。
|
|
13
|
+
修复: 移除 addJavascriptInterface() 中对敏感 API 的直接暴露;
|
|
14
|
+
使用 postMessage / evaluateJavascript 消息通道替代。
|
|
15
|
+
languages:
|
|
16
|
+
- java
|
|
17
|
+
patterns:
|
|
18
|
+
- pattern: |
|
|
19
|
+
$WV.addJavascriptInterface($OBJ, $NAME);
|
|
20
|
+
metavariable-regex:
|
|
21
|
+
metavariable: $DANGEROUS
|
|
22
|
+
regex: '(?i)(Runtime\.exec|ProcessBuilder|Class\.forName|Method\.invoke|openOrCreateDatabase|getSharedPreferences|startActivity|sendTextMessage)'
|
|
23
|
+
metadata:
|
|
24
|
+
cwe: "CWE-749: Exposed Dangerous Method or Function"
|
|
25
|
+
owasp-mobile: "M7: Client Code Quality"
|
|
26
|
+
masvs: "MASVS-PLATFORM-2"
|
|
27
|
+
category: android-webview
|
|
28
|
+
precision: medium
|
|
29
|
+
confidence: medium
|
|
30
|
+
likelihood: critical
|
|
31
|
+
impact: critical
|
|
32
|
+
source: "V3 Audit Engine - VULN-WV-002"
|
|
33
|
+
references:
|
|
34
|
+
- https://developer.android.com/privacy-and-security/risks/webview-javascript-interface
|
|
35
|
+
- https://labs.mwrinfosecurity.com/blog/2014/02/12/webview-addjavascriptinterface-remote-code-execution/
|
|
36
|
+
|
|
37
|
+
- id: zm-android-webview-jsbridge-enabled
|
|
38
|
+
severity: WARNING
|
|
39
|
+
message: |
|
|
40
|
+
检测到 addJavascriptInterface() 调用。
|
|
41
|
+
需人工审计暴露给 JavaScript 的 Java 对象中是否包含危险方法(文件操作、命令执行、反射等)。
|
|
42
|
+
如果 JS Bridge 非业务必需,建议完全移除。
|
|
43
|
+
languages:
|
|
44
|
+
- java
|
|
45
|
+
patterns:
|
|
46
|
+
- pattern: |
|
|
47
|
+
$WV.addJavascriptInterface($OBJ, $NAME)
|
|
48
|
+
metadata:
|
|
49
|
+
cwe: "CWE-749: Exposed Dangerous Method or Function"
|
|
50
|
+
owasp-mobile: "M7: Client Code Quality"
|
|
51
|
+
masvs: "MASVS-PLATFORM-2"
|
|
52
|
+
category: android-webview
|
|
53
|
+
precision: very-high
|
|
54
|
+
confidence: low
|
|
55
|
+
source: "V3 Audit Engine - VULN-WV-003"
|
|
56
|
+
references:
|
|
57
|
+
- https://developer.android.com/privacy-and-security/risks/webview-javascript-interface
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
# CWE-749 and CWE-79: WebView Advanced Injection Attacks (Android)
|
|
2
|
+
# ZhuMa V4.0 - Android Rule Library
|
|
3
|
+
# Source: ZhuMa V4.1 Rule Expansion - WebView injection surface
|
|
4
|
+
|
|
5
|
+
rules:
|
|
6
|
+
- id: zm-android-webview-loadurl-untrusted-input
|
|
7
|
+
severity: HIGH
|
|
8
|
+
message: |
|
|
9
|
+
Detected WebView.loadUrl() with a URL built from untrusted input (Intent extras, URI query params,
|
|
10
|
+
EditText content). This enables URL injection: an attacker can load javascript: URLs to execute
|
|
11
|
+
arbitrary code in the WebView context, or redirect to phishing pages.
|
|
12
|
+
Remediation: Validate URLs against a whitelist of allowed domains. Never pass user-controlled
|
|
13
|
+
strings directly to loadUrl(). Use a strict allowlist for schemes (https only) and hosts.
|
|
14
|
+
languages:
|
|
15
|
+
- java
|
|
16
|
+
patterns:
|
|
17
|
+
- pattern-either:
|
|
18
|
+
- pattern: |
|
|
19
|
+
$WV.loadUrl($INPUT)
|
|
20
|
+
metadata:
|
|
21
|
+
cwe: "CWE-749: Exposed Dangerous Method or Function"
|
|
22
|
+
owasp-mobile: "M1: Improper Platform Usage"
|
|
23
|
+
masvs: "MASVS-PLATFORM-2"
|
|
24
|
+
category: android-webview
|
|
25
|
+
precision: low
|
|
26
|
+
confidence: low
|
|
27
|
+
source: "ZhuMa V4.1 Rule Expansion"
|
|
28
|
+
references:
|
|
29
|
+
- https://cwe.mitre.org/data/definitions/749.html
|
|
30
|
+
- https://developer.android.com/privacy-and-security/risks/webview-url-loading
|
|
31
|
+
|
|
32
|
+
- id: zm-android-webview-loadurl-getstringextra
|
|
33
|
+
severity: HIGH
|
|
34
|
+
message: |
|
|
35
|
+
Detected WebView.loadUrl() with untrusted input from Intent.getStringExtra().
|
|
36
|
+
This is a common deeplink-to-WebView injection path: an attacker sends an Intent with a malicious
|
|
37
|
+
URL, which the app loads directly into a WebView without validation.
|
|
38
|
+
Remediation: Validate the URL scheme (must be https://), host (against whitelist), and path.
|
|
39
|
+
languages:
|
|
40
|
+
- java
|
|
41
|
+
patterns:
|
|
42
|
+
- pattern-either:
|
|
43
|
+
- pattern: |
|
|
44
|
+
$WV.loadUrl(getIntent().getStringExtra("$KEY"))
|
|
45
|
+
metadata:
|
|
46
|
+
cwe: "CWE-749: Exposed Dangerous Method or Function"
|
|
47
|
+
owasp-mobile: "M1: Improper Platform Usage"
|
|
48
|
+
masvs: "MASVS-PLATFORM-2"
|
|
49
|
+
category: android-webview
|
|
50
|
+
precision: high
|
|
51
|
+
confidence: high
|
|
52
|
+
source: "ZhuMa V4.1 Rule Expansion"
|
|
53
|
+
references:
|
|
54
|
+
- https://cwe.mitre.org/data/definitions/749.html
|
|
55
|
+
|
|
56
|
+
- id: zm-android-webview-loadurl-javascript-scheme
|
|
57
|
+
severity: CRITICAL
|
|
58
|
+
message: |
|
|
59
|
+
Detected WebView.loadUrl() with a "javascript:" scheme URL with dynamic content.
|
|
60
|
+
Javascript URLs can execute arbitrary code in the WebView context, including accessing
|
|
61
|
+
cookies, localStorage, and JavaScript interfaces. Combined with untrusted input, this enables XSS.
|
|
62
|
+
Remediation: Never use "javascript:" URLs in loadUrl(). Use evaluateJavascript() for controlled JS execution.
|
|
63
|
+
languages:
|
|
64
|
+
- java
|
|
65
|
+
patterns:
|
|
66
|
+
- pattern-either:
|
|
67
|
+
- pattern: |
|
|
68
|
+
$WV.loadUrl("javascript:" + $SCRIPT)
|
|
69
|
+
- pattern: |
|
|
70
|
+
$WV.loadUrl(String.format("javascript:%s", $SCRIPT))
|
|
71
|
+
metadata:
|
|
72
|
+
cwe: "CWE-79: Improper Neutralization of Input During Web Page Generation"
|
|
73
|
+
owasp-mobile: "M1: Improper Platform Usage"
|
|
74
|
+
masvs: "MASVS-PLATFORM-2"
|
|
75
|
+
category: android-webview
|
|
76
|
+
precision: very-high
|
|
77
|
+
confidence: very-high
|
|
78
|
+
source: "ZhuMa V4.1 Rule Expansion"
|
|
79
|
+
references:
|
|
80
|
+
- https://cwe.mitre.org/data/definitions/79.html
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
# CWE-78: 命令注入 (Android)
|
|
2
|
+
# 逐码 ZhuMa V4.0 — Android 规则库
|
|
3
|
+
# 来源: V3 审计引擎 VULN-CE-001 / VULN-CE-002
|
|
4
|
+
|
|
5
|
+
rules:
|
|
6
|
+
- id: zm-android-runtime-exec-variable-concat
|
|
7
|
+
severity: CRITICAL
|
|
8
|
+
message: |
|
|
9
|
+
检测到 Runtime.exec() 或 ProcessBuilder 使用变量拼接构造命令。
|
|
10
|
+
如果输入来自用户可控来源(Intent Extra、网络输入、Deeplink 参数),
|
|
11
|
+
攻击者可注入恶意命令实现远程代码执行 (RCE)。
|
|
12
|
+
Android 应用场景中常见于: 文件操作、视频处理、PDF 生成等 JNI/Shell 桥接代码。
|
|
13
|
+
修复: 绝不在 Android 中使用 Runtime.exec() 执行 Shell 命令;使用 Android API 替代;
|
|
14
|
+
如果必须使用 exec(),只能用 String[] 数组形式 + 硬编码参数,绝不拼接用户输入。
|
|
15
|
+
languages:
|
|
16
|
+
- java
|
|
17
|
+
patterns:
|
|
18
|
+
- pattern-either:
|
|
19
|
+
- pattern: |
|
|
20
|
+
Runtime.getRuntime().exec($CMD + $PARAM)
|
|
21
|
+
- pattern: |
|
|
22
|
+
Runtime.getRuntime().exec($CMD + $PARAM + $PARAM2)
|
|
23
|
+
- pattern: |
|
|
24
|
+
new ProcessBuilder($CMD + $PARAM)
|
|
25
|
+
- pattern: |
|
|
26
|
+
$PB = new ProcessBuilder($CMD + $PARAM)
|
|
27
|
+
- pattern-either:
|
|
28
|
+
- pattern-regex: 'getString'
|
|
29
|
+
- pattern-regex: 'getIntent'
|
|
30
|
+
- pattern-regex: 'getData'
|
|
31
|
+
- pattern-regex: 'getQuery'
|
|
32
|
+
- pattern-regex: 'getParam'
|
|
33
|
+
- pattern-regex: 'getExtras'
|
|
34
|
+
metadata:
|
|
35
|
+
cwe: "CWE-78: Improper Neutralization of Special Elements used in an OS Command ('OS Command Injection')"
|
|
36
|
+
owasp-mobile: "M8: Code Tampering"
|
|
37
|
+
masvs: "MASVS-CODE-4"
|
|
38
|
+
category: android-code-execution
|
|
39
|
+
precision: medium
|
|
40
|
+
confidence: medium
|
|
41
|
+
likelihood: medium
|
|
42
|
+
impact: critical
|
|
43
|
+
source: "V3 Audit Engine - VULN-CE-001"
|
|
44
|
+
references:
|
|
45
|
+
- https://cwe.mitre.org/data/definitions/78.html
|
|
46
|
+
- https://developer.android.com/privacy-and-security/risks/process-execution
|
|
47
|
+
|
|
48
|
+
- id: zm-android-runtime-exec-present
|
|
49
|
+
severity: WARNING
|
|
50
|
+
message: |
|
|
51
|
+
检测到 Runtime.exec() 调用,需确认所有参数均为硬编码常量而非用户输入。
|
|
52
|
+
如果参数中任何部分来自 Intent Extra、网络数据、Deeplink 等不可信来源,
|
|
53
|
+
则存在命令注入风险。
|
|
54
|
+
languages:
|
|
55
|
+
- java
|
|
56
|
+
patterns:
|
|
57
|
+
- pattern-either:
|
|
58
|
+
- pattern: |
|
|
59
|
+
Runtime.getRuntime().exec(...)
|
|
60
|
+
- pattern: |
|
|
61
|
+
new ProcessBuilder(...)
|
|
62
|
+
- pattern-not-inside: |
|
|
63
|
+
if (BuildConfig.DEBUG) {
|
|
64
|
+
...
|
|
65
|
+
Runtime.getRuntime().exec(...);
|
|
66
|
+
...
|
|
67
|
+
}
|
|
68
|
+
metadata:
|
|
69
|
+
cwe: "CWE-78: Improper Neutralization of Special Elements used in an OS Command ('OS Command Injection')"
|
|
70
|
+
owasp-mobile: "M8: Code Tampering"
|
|
71
|
+
masvs: "MASVS-CODE-4"
|
|
72
|
+
category: android-code-execution
|
|
73
|
+
precision: very-high
|
|
74
|
+
confidence: low
|
|
75
|
+
source: "V3 Audit Engine - VULN-CE-002"
|
|
76
|
+
references:
|
|
77
|
+
- https://cwe.mitre.org/data/definitions/78.html
|