Our ~35 own rules left whole languages without SAST findings. Three permissively licensed community packs now run next to them, on the same semgrep invocation (--metrics=off, local files only): - GitLab sast-rules v2.10.1 (53bf5cf6): 148 rules for C#, Java, JavaScript/TypeScript, Python and one Go rule; only files whose header says "License: MIT (c) GitLab Inc.". Not vendored: c/ (every file GPL-2.0, generated from flawfinder), go/ apart from one file (Apache-2.0 gosec ports), scala/, rules/lgpl, rules/lgpl-cc (Commons Clause), rules/gitlab (EE). - 0xdea semgrep-rules (dae50da6, MIT): 35 C/C++ rules. - elttam semgrep-rules (24426856, MIT; its LICENSE carries the Semgrep template's copyright line): 34 rules for Java, Go and Struts/Spring XML. Each pack lives in compliance-agent/rules/vendor/<source>/ with LICENSE, NOTICE (provenance, what was left out and why) and UPSTREAM (pinned commit): upstream/ holds the selected files unchanged with their tests, pack.yaml the rules the agent runs, ids prefixed per source (gitlab-, 0xdea-, elttam-), rules.json an index for the tests. scripts/vendor-semgrep-rules.py regenerates all of it deterministically. Provenance: every candidate rule was compared with the Semgrep registry (semgrep/semgrep-rules, read only for the comparison). Eight GitLab Python/JS rules with the same message or the same patterns are not vendored, nor are elttam's Kubernetes rules (registry-derived). Also left out: elttam's entrypoint enumerators, its ORM-leak hints, three files whose upstream tests fail on semgrep 1.177 and a join-mode rule. Noise budget: run over the nightly fixtures, the public samples and FreeRTOS-Kernel, lwIP, OpenRA, eShopOnWeb, requests, express and spring-petclinic. 15 rules that flood real code (0xdea missing-return 1514 hits, typos 989, interesting-api-calls 718, signed-unsigned-conversion 221, suspicious-assert 176, format-string-bugs 61 ...; GitLab assert-used) are dropped from the pack, each listed with its reason in NOTICE. CPU time of the semgrep run roughly doubles on C-heavy trees (FreeRTOS-Kernel 70 s -> 136 s, lwIP 18 s -> 68 s), well inside the 10-minute stage timeout. Ids stay bare (#473 logic covers the vendored ids, fingerprint() unchanged). The control map gets one vendored semgrep binding per control, by CWE (by rule id for the few elttam rules without one), with exactly the languages of the rules behind it; a test checks every vendored rule maps to a control that claims its languages. Guard: semgrep_args() builds the one invocation; a test fails if any --config is not a staged local pack, or is auto, p/, r/ or a URL, and another scans the agent source, scripts, docker/, CI and Dockerfile.agent for a registry config. Nightly baselines with C, Python, C# or JS code change and need a bless run after the image is deployed. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01DmXxNULoSNPvjF7buKipsB
1611 lines
46 KiB
YAML
1611 lines
46 KiB
YAML
# elttam semgrep-rules, vendored by scripts/vendor-semgrep-rules.py; do not edit.
|
||
# Upstream: https://github.com/elttam/semgrep-rules at 244268562cc92d33f54b8a60a187df5520f91b26
|
||
# Licence: MIT (LICENSE names 'Copyright (c) 2020 Semgrep': the MIT text of the repository template the first commit came from); see LICENSE and NOTICE next to this file.
|
||
# Changed from upstream: ids prefixed with 'elttam-', rules
|
||
# left out as listed in NOTICE, rules re-serialised into one file.
|
||
rules:
|
||
- id: elttam-potential-symlink-takeover-with-os-executable
|
||
languages: [go]
|
||
message: os.Executable()s behaviour varies between operating systems. On Linux symlinks are followed,
|
||
while on MacOS and Windows they are not. Depending on context, this could lead to file replacement attacks
|
||
and local privilege escalation.
|
||
metadata:
|
||
category: security
|
||
subcategory: audit
|
||
likelihood: LOW
|
||
impact: LOW
|
||
confidence: LOW
|
||
technology:
|
||
- golang
|
||
severity: WARNING
|
||
patterns:
|
||
- pattern: '$BIN, ... := os.Executable()
|
||
|
||
'
|
||
- pattern-not-inside: '$BIN, ... := os.Executable()
|
||
|
||
...
|
||
|
||
..., ... := filepath.EvalSymlinks($BIN)
|
||
|
||
'
|
||
- id: elttam-sprintf-unescaped-control-characters
|
||
languages: [go]
|
||
message: fmt.Sprintf()'s %s formatting verb does not escape control characters in a string, such as \u000a
|
||
or backtick-enclosed multilines. This could lead to various vulnerabilities such as header injection,
|
||
request smuggling, log injection, etc.
|
||
metadata:
|
||
category: security
|
||
subcategory: audit
|
||
likelihood: LOW
|
||
impact: LOW
|
||
confidence: MEDIUM
|
||
technology:
|
||
- golang
|
||
severity: WARNING
|
||
mode: taint
|
||
options:
|
||
symbolic_propagation: true
|
||
pattern-sources:
|
||
- patterns:
|
||
- pattern-inside: "func $FUNC(...) $TYPE {\n ...\n return fmt.Sprintf(\"$VERB\", ...)\n}\n...\n"
|
||
- metavariable-regex:
|
||
metavariable: $VERB
|
||
regex: .*%s
|
||
- pattern: $FUNC(...)
|
||
pattern-sinks:
|
||
- pattern: filepath.Join(...)
|
||
- pattern: path.Join(...)
|
||
- pattern: $FUNC.log(...)
|
||
- id: elttam-non-atomic-use-of-converted-uintptr
|
||
languages: [go]
|
||
message: An unsafe.Pointer converted to an uintptr must be used in an atomic step. Without this it is
|
||
not guaranteed that the memory location uintptr points to will contain the intended structure.
|
||
metadata:
|
||
category: security
|
||
subcategory: vuln
|
||
likelihood: MEDIUM
|
||
impact: MEDIUM
|
||
confidence: MEDIUM
|
||
technology:
|
||
- golang
|
||
severity: WARNING
|
||
pattern-either:
|
||
- pattern: '$UINTPTR := uintptr(unsafe.Pointer( ... ))
|
||
|
||
...
|
||
|
||
... := $F(..., $UINTPTR, ...)
|
||
|
||
'
|
||
- pattern: '$UINTPTR := uintptr($PTR)
|
||
|
||
...
|
||
|
||
... := $F(..., $UINTPTR, ...)
|
||
|
||
'
|
||
- id: elttam-jakarta-mail-internetaddress-overloaded-ctor
|
||
languages: [java]
|
||
severity: WARNING
|
||
message: InternetAddress(String, ...) constructors do NOT validate the email address. They assign the
|
||
address field directly. Prefer the single-arg constructor + explicit validation.
|
||
metadata:
|
||
cwe:
|
||
- 'CWE-20: Improper Input Validation'
|
||
owasp:
|
||
- A04:2021 – Insecure Design
|
||
references:
|
||
- https://elttam.com/blog/jakarta-mail-primitives/
|
||
- https://cwe.mitre.org/data/definitions/20.html
|
||
- https://owasp.org/Top10/A04_2021-Insecure_Design/
|
||
category: security
|
||
subcategory: audit
|
||
likelihood: MEDIUM
|
||
impact: MEDIUM
|
||
confidence: LOW
|
||
technology:
|
||
- java
|
||
vulnerability_class:
|
||
- Improper Validation
|
||
pattern-either:
|
||
- pattern: new jakarta.mail.internet.InternetAddress($ADDR, $PERSONAL)
|
||
- pattern: new jakarta.mail.internet.InternetAddress($ADDR, $PERSONAL, $CHARSET)
|
||
- id: elttam-jakarta-mail-internetaddress-single-arg-validator
|
||
languages: [java]
|
||
severity: INFO
|
||
message: new InternetAddress(String) parses an email for RFC compliance, but should not be treated as
|
||
a full security/identity check. Ensure domain checks and trust decisions are not based solely on constructor
|
||
success.
|
||
metadata:
|
||
cwe:
|
||
- 'CWE-20: Improper Input Validation'
|
||
owasp:
|
||
- A04:2021 – Insecure Design
|
||
references:
|
||
- https://elttam.com/blog/jakarta-mail-primitives/
|
||
- https://cwe.mitre.org/data/definitions/20.html
|
||
- https://owasp.org/Top10/A04_2021-Insecure_Design/
|
||
category: security
|
||
subcategory: audit
|
||
likelihood: MEDIUM
|
||
impact: MEDIUM
|
||
confidence: LOW
|
||
technology:
|
||
- java
|
||
vulnerability_class:
|
||
- Improper Validation
|
||
pattern: new jakarta.mail.internet.InternetAddress($ADDR)
|
||
- id: elttam-jakarta-mail-mimemessage-raw-envelope-ctor
|
||
languages: [java]
|
||
severity: INFO
|
||
message: MimeMessage constructed from a raw source or InputStream. Headers such as From, Reply-To, Subject,
|
||
and Newsgroups will be parsed using InternetAddress/NewsAddress. Ensure user-controlled envelopes are
|
||
canonicalized and not blindly trusted.
|
||
metadata:
|
||
cwe:
|
||
- 'CWE-20: Improper Input Validation'
|
||
owasp:
|
||
- A04:2021 – Insecure Design
|
||
references:
|
||
- https://elttam.com/blog/jakarta-mail-primitives/
|
||
- https://cwe.mitre.org/data/definitions/20.html
|
||
- https://owasp.org/Top10/A04_2021-Insecure_Design/
|
||
category: security
|
||
subcategory: audit
|
||
likelihood: LOW
|
||
impact: MEDIUM
|
||
confidence: LOW
|
||
technology:
|
||
- java
|
||
pattern-either:
|
||
- pattern: new jakarta.mail.internet.MimeMessage($SESSION, $IS)
|
||
- pattern: new jakarta.mail.internet.MimeMessage($FOLDER, $IS, $MSGNUM)
|
||
- pattern: new jakarta.mail.internet.MimeMessage($SOURCE)
|
||
- id: elttam-jakarta-mail-mimemessage-newsgroups-recipients
|
||
languages: [java]
|
||
severity: INFO
|
||
message: MimeMessage.getRecipients(Message.RecipientType.NEWSGROUPS) used. Newsgroups headers may be concatenated
|
||
and parsed via NewsAddress, which silently normalizes malformed values. Review how this data is used.
|
||
metadata:
|
||
cwe:
|
||
- 'CWE-20: Improper Input Validation'
|
||
owasp:
|
||
- A04:2021 – Insecure Design
|
||
references:
|
||
- https://elttam.com/blog/jakarta-mail-primitives/
|
||
- https://cwe.mitre.org/data/definitions/20.html
|
||
- https://owasp.org/Top10/A04_2021-Insecure_Design/
|
||
category: security
|
||
subcategory: audit
|
||
likelihood: MEDIUM
|
||
impact: MEDIUM
|
||
confidence: LOW
|
||
technology:
|
||
- java
|
||
patterns:
|
||
- pattern: '$MM.getRecipients(MimeMessage.RecipientType.NEWSGROUPS)
|
||
|
||
'
|
||
- metavariable-type:
|
||
metavariable: $MM
|
||
type: jakarta.mail.internet.MimeMessage
|
||
- id: elttam-spring-internetaddresseditor-usage
|
||
languages: [java]
|
||
severity: INFO
|
||
message: Spring InternetAddressEditor used. This relies on Jakarta Mail parsing and will decode encoded
|
||
personal names (RFC 2047). Ensure the resulting personal/name fields are not used as trust signals.
|
||
metadata:
|
||
cwe:
|
||
- 'CWE-20: Improper Input Validation'
|
||
owasp:
|
||
- A04:2021 – Insecure Design
|
||
references:
|
||
- https://elttam.com/blog/jakarta-mail-primitives/
|
||
- https://cwe.mitre.org/data/definitions/20.html
|
||
- https://owasp.org/Top10/A04_2021-Insecure_Design/
|
||
category: security
|
||
subcategory: audit
|
||
likelihood: LOW
|
||
impact: MEDIUM
|
||
confidence: LOW
|
||
technology:
|
||
- java
|
||
pattern: new org.springframework.mail.javamail.InternetAddressEditor(...)
|
||
- id: elttam-spring-simplemailmessage-setfrom-raw
|
||
languages: [java]
|
||
severity: INFO
|
||
message: SimpleMailMessage.setFrom(...) called. If the from-address is influenced by user input, be aware
|
||
of encoded names and complex email syntax (e.g. encoded words, group addresses, angle-bracket forms).
|
||
metadata:
|
||
cwe:
|
||
- 'CWE-20: Improper Input Validation'
|
||
owasp:
|
||
- A04:2021 – Insecure Design
|
||
references:
|
||
- https://elttam.com/blog/jakarta-mail-primitives/
|
||
- https://cwe.mitre.org/data/definitions/20.html
|
||
- https://owasp.org/Top10/A04_2021-Insecure_Design/
|
||
category: security
|
||
subcategory: audit
|
||
likelihood: LOW
|
||
impact: MEDIUM
|
||
confidence: LOW
|
||
technology:
|
||
- java
|
||
patterns:
|
||
- pattern: $MSG.setFrom(...)
|
||
- metavariable-type:
|
||
metavariable: $MSG
|
||
type: org.springframework.mail.SimpleMailMessage
|
||
- id: elttam-email-domain-split-index
|
||
languages: [java]
|
||
severity: WARNING
|
||
message: Domain derived via email.split("@")[1]. This is fragile for complex, RFC-compliant addresses
|
||
(e.g. "\"foo@bar.com\"@example.com"). Prefer a proper email parser and canonicalization for domain checks.
|
||
metadata:
|
||
cwe:
|
||
- 'CWE-20: Improper Input Validation'
|
||
owasp:
|
||
- A04:2021 – Insecure Design
|
||
references:
|
||
- https://elttam.com/blog/jakarta-mail-primitives/
|
||
- https://cwe.mitre.org/data/definitions/20.html
|
||
- https://owasp.org/Top10/A04_2021-Insecure_Design/
|
||
category: security
|
||
subcategory: audit
|
||
likelihood: LOW
|
||
impact: MEDIUM
|
||
confidence: LOW
|
||
technology:
|
||
- java
|
||
pattern: $EMAIL.split("@")[1]
|
||
- id: elttam-email-domain-lastindexof
|
||
languages: [java]
|
||
severity: WARNING
|
||
message: Domain derived via substring(lastIndexOf("@") + 1). This can be tricked by overloaded or encoded
|
||
email addresses. Prefer a proper parser and canonical form instead of manual substring logic.
|
||
metadata:
|
||
cwe:
|
||
- 'CWE-20: Improper Input Validation'
|
||
owasp:
|
||
- A04:2021 – Insecure Design
|
||
references:
|
||
- https://elttam.com/blog/jakarta-mail-primitives/
|
||
- https://cwe.mitre.org/data/definitions/20.html
|
||
- https://owasp.org/Top10/A04_2021-Insecure_Design/
|
||
category: security
|
||
subcategory: audit
|
||
likelihood: LOW
|
||
impact: MEDIUM
|
||
confidence: LOW
|
||
technology:
|
||
- java
|
||
pattern: $EMAIL.substring($EMAIL.lastIndexOf("@") + 1)
|
||
- id: elttam-email-domain-endswith
|
||
languages: [java]
|
||
severity: WARNING
|
||
message: Domain/tenant derived using email.endsWith("..."). This can be bypassed with addresses like tester@evil.com@trusted.com.
|
||
Prefer comparing the canonical domain returned by a parser.
|
||
metadata:
|
||
cwe:
|
||
- 'CWE-20: Improper Input Validation'
|
||
owasp:
|
||
- A04:2021 – Insecure Design
|
||
references:
|
||
- https://elttam.com/blog/jakarta-mail-primitives/
|
||
- https://cwe.mitre.org/data/definitions/20.html
|
||
- https://owasp.org/Top10/A04_2021-Insecure_Design/
|
||
category: security
|
||
subcategory: audit
|
||
likelihood: LOW
|
||
impact: MEDIUM
|
||
confidence: LOW
|
||
technology:
|
||
- java
|
||
pattern-either:
|
||
- patterns:
|
||
- pattern: $EMAIL.endsWith("$SUFFIX")
|
||
- metavariable-regex:
|
||
metavariable: $SUFFIX
|
||
regex: ^@
|
||
- patterns:
|
||
- patterns:
|
||
- pattern: String $VAR = "$SUFFIX";
|
||
- metavariable-regex:
|
||
metavariable: $SUFFIX
|
||
regex: ^@
|
||
- pattern: $EMAIL.endsWith($VAR)
|
||
- id: elttam-hibernate-email-annotation-field
|
||
languages: [java]
|
||
severity: INFO
|
||
message: Field annotated with @Email. The default Hibernate validator is not RFC 2047-aware and can accept
|
||
complex syntax (e.g. "\"foo@bar.com\"@example.com"). Review any domain or trust logic that uses this
|
||
field (split/substring/endsWith).
|
||
metadata:
|
||
cwe:
|
||
- 'CWE-20: Improper Input Validation'
|
||
owasp:
|
||
- A04:2021 – Insecure Design
|
||
references:
|
||
- https://elttam.com/blog/jakarta-mail-primitives/
|
||
- https://cwe.mitre.org/data/definitions/20.html
|
||
- https://owasp.org/Top10/A04_2021-Insecure_Design/
|
||
category: security
|
||
subcategory: audit
|
||
likelihood: LOW
|
||
impact: MEDIUM
|
||
confidence: LOW
|
||
technology:
|
||
- java
|
||
pattern: '@Email
|
||
|
||
$TYPE $STRING_VAR'
|
||
- id: elttam-gcm-static-iv
|
||
languages: [java]
|
||
message: GCM IV and key are both same source $KEY_BYTES
|
||
metadata:
|
||
cwe: '# Closer match, but specifically CBC mode, whereas this is GCM mode.
|
||
|
||
#CWE-329: Not Using a Random IV with CBC Mode
|
||
|
||
CWE-330: Use of Insufficiently Random Values
|
||
|
||
'
|
||
references:
|
||
- https://www.elttam.com/blog/key-recovery-attacks-on-gcm
|
||
help:
|
||
- https://github.com/returntocorp/semgrep-rules/pull/382/files
|
||
category: security
|
||
subcategory: audit
|
||
likelihood: MEDIUM
|
||
impact: MEDIUM
|
||
confidence: HIGH
|
||
technology:
|
||
- Java
|
||
- GCM
|
||
severity: WARNING
|
||
patterns:
|
||
- pattern-either:
|
||
- pattern-inside: '$KEY_BYTES = $RAW_KEY.getBytes();
|
||
|
||
...
|
||
|
||
'
|
||
- pattern-inside: 'byte[] $KEY_BYTES = { ... };
|
||
|
||
...
|
||
|
||
'
|
||
- pattern-inside: "class $CLASS {\n byte[] $KEY_BYTES = {...};\n ...\n}\n"
|
||
- pattern-either:
|
||
- pattern: '$GCM_PARAM_SPEC = new GCMParameterSpec($BLOCK_SIZE, $KEY_BYTES);
|
||
|
||
...
|
||
|
||
$KEY = new SecretKeySpec($KEY_BYTES, $ALGO);
|
||
|
||
'
|
||
- pattern: '$KEY = new SecretKeySpec($KEY_BYTES, $ALGO);
|
||
|
||
...
|
||
|
||
$GCM_PARAM_SPEC = new GCMParameterSpec($BLOCK_SIZE, $KEY_BYTES);
|
||
|
||
'
|
||
- id: elttam-randomstringutils-insecure-rng
|
||
languages: [java]
|
||
message: RandomStringUtils uses java.util.Random by default which is not suitable for security
|
||
metadata:
|
||
cwe: 'CWE-338: Use of Cryptographically Weak Pseudo-Random Number Generator (PRNG)'
|
||
owasp: 'A9: Using Components with Known Vulnerabilities'
|
||
references:
|
||
- https://www.elttam.com/blog/cracking-randomness-in-java/
|
||
category: security
|
||
subcategory: audit
|
||
likelihood: LOW
|
||
impact: LOW
|
||
confidence: LOW
|
||
technology:
|
||
- Java
|
||
- Apache Commons Lang
|
||
- RandomStringUtils
|
||
severity: WARNING
|
||
patterns:
|
||
- pattern: 'org.apache.commons.lang3.RandomStringUtils.$X(...)
|
||
|
||
'
|
||
- pattern-not-inside: 'org.apache.commons.lang3.RandomStringUtils.$X(..., new SecureRandom())
|
||
|
||
'
|
||
- id: elttam-UnsafeHttpInvokerServiceExporter-XML
|
||
languages: [generic]
|
||
metadata:
|
||
cve: CVE-2016-1000027
|
||
docs:
|
||
- https://blog.gypsyengineer.com/en/security/detecting-dangerous-spring-exporters-with-codeql.html
|
||
- https://www.tenable.com/security/research/tra-2016-20
|
||
category: security
|
||
subcategory: audit
|
||
likelihood: LOW
|
||
impact: LOW
|
||
confidence: LOW
|
||
technology:
|
||
- spring
|
||
- spring-framework
|
||
- jvm
|
||
paths:
|
||
include:
|
||
- '*.xml'
|
||
severity: INFO
|
||
message: Unsafe Spring Service Exporter XML
|
||
pattern-either:
|
||
- pattern: 'org.springframework.remoting.httpinvoker.HttpInvokerServiceExporter
|
||
|
||
'
|
||
- pattern: 'org.springframework.remoting.httpinvoker.SimpleHttpInvokerServiceExporter
|
||
|
||
'
|
||
- pattern: 'org.springframework.remoting.rmi.RemoteInvocationSerializingExporter
|
||
|
||
'
|
||
- id: elttam-gorilla-cookiestore-default-samesite-none
|
||
languages: [go]
|
||
message: 'gorilla/sessions.NewCookieStore (and NewFilesystemStore) initialise Options.SameSite to http.SameSiteNoneMode
|
||
by default, which allows the session cookie to be sent on cross-site requests and removes a key CSRF
|
||
defence. The existing session-cookie-samesitenone rule only catches an explicit &sessions.Options{SameSite:
|
||
http.SameSiteNoneMode}; this insecure value is also the silent default when you never set Options at
|
||
all. After NewCookieStore, explicitly set store.Options.SameSite to http.SameSiteLaxMode or http.SameSiteStrictMode.'
|
||
severity: WARNING
|
||
patterns:
|
||
- pattern-either:
|
||
- pattern: $STORE := sessions.NewCookieStore(...)
|
||
- pattern: $STORE = sessions.NewCookieStore(...)
|
||
- pattern: $STORE := sessions.NewFilesystemStore(...)
|
||
- pattern: $STORE = sessions.NewFilesystemStore(...)
|
||
- pattern-not-inside: '$STORE := sessions.NewCookieStore(...)
|
||
|
||
...
|
||
|
||
$STORE.Options.SameSite = $V
|
||
|
||
'
|
||
- pattern-not-inside: '$STORE = sessions.NewCookieStore(...)
|
||
|
||
...
|
||
|
||
$STORE.Options.SameSite = $V
|
||
|
||
'
|
||
- pattern-not-inside: '$STORE := sessions.NewCookieStore(...)
|
||
|
||
...
|
||
|
||
$STORE.Options = $OPTS
|
||
|
||
'
|
||
- pattern-not-inside: '$STORE := sessions.NewFilesystemStore(...)
|
||
|
||
...
|
||
|
||
$STORE.Options.SameSite = $V
|
||
|
||
'
|
||
- pattern-not-inside: '$STORE := sessions.NewFilesystemStore(...)
|
||
|
||
...
|
||
|
||
$STORE.Options = $OPTS
|
||
|
||
'
|
||
metadata:
|
||
cwe:
|
||
- 'CWE-1275: Sensitive Cookie with Improper SameSite Attribute'
|
||
owasp:
|
||
- A05:2021 - Security Misconfiguration
|
||
- A02:2025 - Security Misconfiguration
|
||
category: security
|
||
subcategory:
|
||
- audit
|
||
confidence: LOW
|
||
likelihood: LOW
|
||
impact: MEDIUM
|
||
technology:
|
||
- gorilla
|
||
references:
|
||
- https://github.com/gorilla/sessions/blob/v1.4.0/store.go#L59
|
||
- id: elttam-json-decode-without-content-type-check
|
||
languages: [go]
|
||
message: 'An HTTP handler decodes the request body as JSON without validating the Content-Type header.
|
||
Browsers send no CORS preflight for "simple" requests using text/plain or application/x-www-form-urlencoded,
|
||
so a cross-site HTML form can POST a body the server parses as JSON (encoding/json also ignores trailing
|
||
bytes, so a form''s trailing "=" doesn''t break parsing). With cookie auth this is exploitable as CSRF.
|
||
Reject requests whose Content-Type is not application/json, and/or wrap handlers with http.CrossOriginProtection
|
||
(Go 1.25+).
|
||
|
||
v2: handler matching widened to cover method receivers, extra parameters (e.g. ctx), and common framework
|
||
handler signatures (gin, echo, chi/std) — the std-only two-arg pattern missed real handlers like func
|
||
(h *T) handleWrite(w, r, ctx) found in production code.'
|
||
severity: WARNING
|
||
patterns:
|
||
- pattern-either:
|
||
- pattern: json.NewDecoder($R.Body).Decode($X)
|
||
- patterns:
|
||
- pattern: $DEC.Decode($X)
|
||
- pattern-inside: '$DEC := json.NewDecoder($R.Body)
|
||
|
||
...
|
||
|
||
'
|
||
- patterns:
|
||
- pattern: $DEC.Decode($X)
|
||
- pattern-inside: '$DEC := json.NewDecoder($C.Request().Body)
|
||
|
||
...
|
||
|
||
'
|
||
- pattern: json.NewDecoder($C.Request().Body).Decode($X)
|
||
- pattern-either:
|
||
- pattern-inside: 'func $H(..., $W http.ResponseWriter, $R *http.Request, ...) { ... }
|
||
|
||
'
|
||
- pattern-inside: 'func ($RT) $H(..., $W http.ResponseWriter, $R *http.Request, ...) { ... }
|
||
|
||
'
|
||
- pattern-inside: 'func $H($C echo.Context) error { ... }
|
||
|
||
'
|
||
- pattern-inside: 'func ($RT) $H($C echo.Context) error { ... }
|
||
|
||
'
|
||
- pattern-inside: 'func $H($C *gin.Context) { ... }
|
||
|
||
'
|
||
- pattern-inside: 'func ($RT) $H($C *gin.Context) { ... }
|
||
|
||
'
|
||
- pattern-not-inside: "func $H(...) {\n ...\n $R.Header.Get(\"Content-Type\")\n ...\n}\n"
|
||
- pattern-not-inside: "func ($RT) $H(...) {\n ...\n $R.Header.Get(\"Content-Type\")\n ...\n}\n"
|
||
- pattern-not-inside: "func $H(...) $RET {\n ...\n $R.Header.Get(\"Content-Type\")\n ...\n}\n"
|
||
- pattern-not-inside: "func ($RT) $H(...) $RET {\n ...\n $R.Header.Get(\"Content-Type\")\n ...\n}\n"
|
||
- pattern-not-inside: "func $H(...) $RET {\n ...\n $R.Header.Values(\"Content-Type\")\n ...\n}\n"
|
||
- pattern-not-inside: "func $H(...) $RET {\n ...\n $C.Request().Header.Get(\"Content-Type\")\n ...\n\
|
||
}\n"
|
||
- pattern-not-inside: "func $H(...) $RET {\n ...\n $C.GetHeader(\"Content-Type\")\n ...\n}\n"
|
||
- pattern-not-inside: "func $H(...) $RET {\n ...\n $C.ContentType()\n ...\n}\n"
|
||
- pattern-not-inside: "func $H(...) $RET {\n ...\n $C.Bind($Y)\n ...\n}\n"
|
||
metadata:
|
||
cwe:
|
||
- 'CWE-352: Cross-Site Request Forgery (CSRF)'
|
||
owasp:
|
||
- A01:2021 - Broken Access Control
|
||
category: security
|
||
subcategory:
|
||
- audit
|
||
confidence: LOW
|
||
likelihood: LOW
|
||
impact: MEDIUM
|
||
technology:
|
||
- go
|
||
- net/http
|
||
references:
|
||
- https://pkg.go.dev/net/http#CrossOriginProtection
|
||
- https://pkg.go.dev/encoding/json#Decoder.Decode
|
||
- id: elttam-json-marshaler-pointer-receiver
|
||
languages: [go]
|
||
message: 'MarshalJSON is defined on a pointer receiver (*$T). Because encoding/json resolves json.Marshaler
|
||
via reflection under strict method-set rules, a pointer-receiver MarshalJSON is NOT in the method set
|
||
of the value type $T. Encoding a value of $T (or a struct containing a $T field) by value silently skips
|
||
the custom marshaller and uses default marshalling. If the marshaller performs redaction/masking/field-omission,
|
||
that protection disappears silently.
|
||
|
||
AUDIT NOTE: this only becomes a bug if the type is somewhere encoded BY VALUE. On large codebases most
|
||
pointer-receiver MarshalJSON are always encoded by pointer and therefore safe — this rule fires broadly
|
||
and is intended as an audit aid, not a finding. To resolve a hit, check whether the type is ever passed
|
||
by value to json.Marshal/Encode. Fix by moving MarshalJSON to a value receiver, or always storing/encoding
|
||
a pointer.'
|
||
severity: INFO
|
||
patterns:
|
||
- pattern: 'func ($RECV *$T) MarshalJSON() ([]byte, error) { ... }
|
||
|
||
'
|
||
metadata:
|
||
cwe:
|
||
- 'CWE-200: Exposure of Sensitive Information to an Unauthorized Actor'
|
||
owasp:
|
||
- A01:2021 - Broken Access Control
|
||
category: security
|
||
subcategory:
|
||
- audit
|
||
confidence: LOW
|
||
likelihood: LOW
|
||
impact: MEDIUM
|
||
technology:
|
||
- go
|
||
references:
|
||
- https://github.com/golang/go/issues/22967
|
||
- https://go.dev/wiki/MethodSets
|
||
- id: elttam-len-cast-to-narrow-int-overflow
|
||
languages: [go]
|
||
message: 'The result of len() is cast to a narrower fixed-width integer (uint32/int32/uint16/int16/uint8/int8).
|
||
len() returns int (64-bit on amd64/arm64), so a length above the target type''s max silently wraps.
|
||
This is benign for in-memory counts/sizes but dangerous when the value becomes a length/size field in
|
||
a binary or wire format, where a truncated length desynchronises the parser from the payload (data smuggling
|
||
/ boundary confusion). Validate the length before casting, or keep the full-width value and reject oversized
|
||
input.
|
||
|
||
NOTE: this broad rule fires on every narrowing len() cast and is INFO/audit. For the dangerous subset,
|
||
see len-cast-into-binary-length-prefix below.'
|
||
severity: INFO
|
||
patterns:
|
||
- pattern-either:
|
||
- pattern: uint32(len($X))
|
||
- pattern: int32(len($X))
|
||
- pattern: uint16(len($X))
|
||
- pattern: int16(len($X))
|
||
- pattern: uint8(len($X))
|
||
- pattern: int8(len($X))
|
||
- pattern-not-inside: 'if len($X) > $MAX { ... }
|
||
|
||
...
|
||
|
||
'
|
||
- pattern-not-inside: 'if len($X) <= $MAX { ... }
|
||
|
||
...
|
||
|
||
'
|
||
- pattern-not-inside: 'if len($X) >= $MAX { ... }
|
||
|
||
...
|
||
|
||
'
|
||
- pattern-not-inside: 'if $LEN := len($X); $LEN > $MAX { ... }
|
||
|
||
...
|
||
|
||
'
|
||
metadata:
|
||
cwe:
|
||
- 'CWE-190: Integer Overflow or Wraparound'
|
||
owasp:
|
||
- A03:2021 - Injection
|
||
category: security
|
||
subcategory:
|
||
- audit
|
||
confidence: LOW
|
||
likelihood: LOW
|
||
impact: MEDIUM
|
||
technology:
|
||
- go
|
||
references:
|
||
- https://github.com/tinylib/msgp/blob/v1.5.0/msgp/write.go
|
||
- https://blog.trailofbits.com/2025/12/31/detect-gos-silent-arithmetic-bugs-with-go-panikint/
|
||
- id: elttam-len-cast-into-binary-length-prefix
|
||
languages: [go]
|
||
message: 'A narrowing cast of len() is written as a binary length prefix via encoding/binary, then the
|
||
corresponding payload is emitted. This is the exploitable shape from the msgp/DEF CON 32 class: if the
|
||
length exceeds the narrow type''s max it wraps, the on-wire length field desynchronises from the actual
|
||
payload, and a downstream parser can be smuggled extra/short data. Bound the length against the type
|
||
max (or the protocol limit) before writing it, and reject oversized payloads.'
|
||
severity: WARNING
|
||
patterns:
|
||
- pattern-either:
|
||
- pattern: binary.$ORDER.PutUint32($BUF, uint32(len($X)))
|
||
- pattern: binary.$ORDER.PutUint16($BUF, uint16(len($X)))
|
||
- pattern: binary.Write($W, $ORDER, uint32(len($X)))
|
||
- pattern: binary.Write($W, $ORDER, uint16(len($X)))
|
||
- pattern-not-inside: 'if len($X) > $MAX { ... }
|
||
|
||
...
|
||
|
||
'
|
||
- pattern-not-inside: 'if len($X) <= $MAX { ... }
|
||
|
||
...
|
||
|
||
'
|
||
- pattern-not-inside: 'if len($X) >= $MAX { ... }
|
||
|
||
...
|
||
|
||
'
|
||
metadata:
|
||
cwe:
|
||
- 'CWE-190: Integer Overflow or Wraparound'
|
||
owasp:
|
||
- A03:2021 - Injection
|
||
category: security
|
||
subcategory:
|
||
- vuln
|
||
confidence: MEDIUM
|
||
likelihood: LOW
|
||
impact: HIGH
|
||
technology:
|
||
- go
|
||
references:
|
||
- https://media.defcon.org/DEF%20CON%2032/DEF%20CON%2032%20presentations/
|
||
- https://github.com/tinylib/msgp/blob/v1.5.0/msgp/write.go
|
||
- id: elttam-missing-null-byte-check-at-trust-boundary
|
||
languages: [go]
|
||
message: 'A string is compared against a PRIVILEGED account name (admin/root/etc.) and then passed to
|
||
a C-interop / LDAP / exec sink in the same function, with no null-byte rejection. Go strings may contain
|
||
\x00; C-style consumers truncate at the first null byte. An input like "admin\x00x" fails the Go equality
|
||
check yet resolves to "admin" past the boundary, bypassing the gate. Reject null bytes (strings.ContainsRune(s,
|
||
0) / strings.IndexByte(s, 0) != -1) before any comparison or interop call at the trust boundary.
|
||
|
||
v2: the gate must compare against a non-empty privileged-looking literal (not `== ""` or arbitrary config
|
||
values), and the sink must be a real C call, os/exec, or a named LDAP/PAM package — narrowed after real-code
|
||
runs where empty-string defaults and cloud-SDK method names produced false positives.'
|
||
severity: INFO
|
||
patterns:
|
||
- pattern-inside: "func $FN(..., $S string, ...) $RET {\n ...\n}\n"
|
||
- pattern-either:
|
||
- pattern-inside: "func $FN2(...) $RET2 {\n ...\n if $S == \"$PRIV\" { ... }\n ...\n}\n"
|
||
- pattern-inside: "func $FN2(...) $RET2 {\n ...\n if $S == \"$PRIV\" || ... { ... }\n ...\n}\n"
|
||
- pattern-inside: "func $FN2(...) $RET2 {\n ...\n if ... || $S == \"$PRIV\" { ... }\n ...\n}\n"
|
||
- metavariable-regex:
|
||
metavariable: $PRIV
|
||
regex: ^(?i)(admin|administrator|root|superuser|super-user|superadmin|sudo|wheel|sysadmin|operator|privileged)$
|
||
- pattern-either:
|
||
- pattern: C.$CFUNC(...)
|
||
- pattern: exec.Command($S, ...)
|
||
- pattern: exec.CommandContext($CTX, $S, ...)
|
||
- pattern: ldap.EscapeFilter(...)
|
||
- pattern: $LDAP.Search(...)
|
||
- pattern: $LDAP.Bind(...)
|
||
- pattern: pam.$PAMFUNC(...)
|
||
- pattern-not-inside: "func $FN(...) $RET {\n ...\n if strings.ContainsRune(...) { ... }\n ...\n}\n"
|
||
- pattern-not-inside: "func $FN(...) $RET {\n ...\n if strings.ContainsRune(...) || ... { ... }\n ...\n\
|
||
}\n"
|
||
- pattern-not-inside: "func $FN(...) $RET {\n ...\n if ... || strings.ContainsRune(...) { ... }\n ...\n\
|
||
}\n"
|
||
- pattern-not-inside: "func $FN(...) $RET {\n ...\n if strings.ContainsAny(...) { ... }\n ...\n}\n"
|
||
- pattern-not-inside: "func $FN(...) $RET {\n ...\n if strings.IndexByte(...) != -1 { ... }\n ...\n\
|
||
}\n"
|
||
- pattern-not-inside: "func $FN(...) $RET {\n ...\n if strings.IndexByte(...) >= 0 { ... }\n ...\n\
|
||
}\n"
|
||
- pattern-not-inside: "func $FN(...) $RET {\n ...\n if strings.Contains($X, \"\\x00\") { ... }\n ...\n\
|
||
}\n"
|
||
metadata:
|
||
cwe:
|
||
- 'CWE-158: Improper Neutralization of Null Byte or NUL Character'
|
||
owasp:
|
||
- A07:2021 - Identification and Authentication Failures
|
||
category: security
|
||
subcategory:
|
||
- audit
|
||
confidence: LOW
|
||
likelihood: LOW
|
||
impact: HIGH
|
||
technology:
|
||
- go
|
||
references:
|
||
- https://www.elttam.com/blog/golang-codereview
|
||
- id: elttam-net-url-pointer-alias-mutation
|
||
languages: [go]
|
||
message: 'A *url.URL pointer held in a variable or field is aliased (not copied) and then a field of it
|
||
is mutated. Assigning a *url.URL copies the pointer, not the struct, so the write mutates the shared
|
||
original. If that original is package-level, a struct field, or otherwise shared across requests or
|
||
goroutines, this corrupts the URL seen elsewhere (open-redirect / parameter-smuggling / data race).
|
||
|
||
This rule only fires when the alias source is a bare identifier (e.g. `u := s.someURL`) — the shape
|
||
most likely to be a shared pointer. It does NOT fire on fresh allocations, which are safe: value composite
|
||
literals (`url.URL{}`), dereference copies (`*p`), or any function/method call result (`url.Parse(...)`,
|
||
`r.URL()`, `x.Copy()`, `ResolveReference(...)`), because those return a new value/struct that is not
|
||
shared.
|
||
|
||
Fix: copy the struct (`u := *original`) or build a fresh &url.URL{...}.'
|
||
severity: INFO
|
||
patterns:
|
||
- pattern-inside: 'import "net/url"
|
||
|
||
...
|
||
|
||
'
|
||
- pattern: $U := $SRC
|
||
- metavariable-pattern:
|
||
metavariable: $SRC
|
||
patterns:
|
||
- pattern-not: '*$X'
|
||
- pattern-not: $T{...}
|
||
- pattern-not: '&$T{...}'
|
||
- pattern-not: $F(...)
|
||
- pattern-not: $R.$M(...)
|
||
- pattern-not: $R[...]
|
||
- pattern-either:
|
||
- pattern-inside: '$U := $SRC
|
||
|
||
...
|
||
|
||
$U.RawQuery = $V
|
||
|
||
'
|
||
- pattern-inside: '$U := $SRC
|
||
|
||
...
|
||
|
||
$U.Path = $V
|
||
|
||
'
|
||
- pattern-inside: '$U := $SRC
|
||
|
||
...
|
||
|
||
$U.Host = $V
|
||
|
||
'
|
||
- pattern-inside: '$U := $SRC
|
||
|
||
...
|
||
|
||
$U.Scheme = $V
|
||
|
||
'
|
||
- pattern-inside: '$U := $SRC
|
||
|
||
...
|
||
|
||
$U.RawPath = $V
|
||
|
||
'
|
||
- pattern-inside: '$U := $SRC
|
||
|
||
...
|
||
|
||
$U.Fragment = $V
|
||
|
||
'
|
||
- pattern-inside: '$U := $SRC
|
||
|
||
...
|
||
|
||
$U.RawFragment = $V
|
||
|
||
'
|
||
- pattern-either:
|
||
- pattern-inside: '$U := $SRC
|
||
|
||
...
|
||
|
||
$U.Query()
|
||
|
||
'
|
||
- pattern-inside: '$U := $SRC
|
||
|
||
...
|
||
|
||
$U.String()
|
||
|
||
'
|
||
- pattern-inside: '$U := $SRC
|
||
|
||
...
|
||
|
||
$U.Hostname()
|
||
|
||
'
|
||
- pattern-inside: '$U := $SRC
|
||
|
||
...
|
||
|
||
$U.Redacted()
|
||
|
||
'
|
||
- pattern-inside: '$U := $SRC
|
||
|
||
...
|
||
|
||
$U.ResolveReference(...)
|
||
|
||
'
|
||
- pattern-inside: '$U := $SRC
|
||
|
||
...
|
||
|
||
$U.RawQuery = $W
|
||
|
||
'
|
||
- pattern-inside: '$U := $SRC
|
||
|
||
...
|
||
|
||
$U.RawPath = $W
|
||
|
||
'
|
||
metadata:
|
||
cwe:
|
||
- 'CWE-362: Concurrent Execution using Shared Resource with Improper Synchronization (''Race Condition'')'
|
||
owasp:
|
||
- A01:2021 - Broken Access Control
|
||
category: security
|
||
subcategory:
|
||
- audit
|
||
confidence: LOW
|
||
likelihood: LOW
|
||
impact: MEDIUM
|
||
technology:
|
||
- go
|
||
references:
|
||
- https://pkg.go.dev/net/url#URL
|
||
- id: elttam-polymorphic-typing
|
||
languages: [java]
|
||
message: 'Jackson Polymorphic Typing: This rule is to detect any instances of polymorphic typing to aid
|
||
in determining vulnerable Jackson deserialization issues. Check if deserializing untrusted JSON to a
|
||
nominal type such as `java.lang.Object` or permissive tag interfaces such as `java.io.Serializable`
|
||
or `java.lang.Comparable` is occuring.'
|
||
severity: INFO
|
||
metadata:
|
||
cwe: 'CWE-502: Deserialization of Untrusted Data'
|
||
owasp: 'A8: Insecure Deserialization'
|
||
docs:
|
||
- https://github.com/mbechler/marshalsec/blob/master/marshalsec.pdf
|
||
- https://www.nccgroup.trust/globalassets/our-research/us/whitepapers/2018/jackson_deserialization.pdf
|
||
- https://medium.com/@cowtowncoder/on-jackson-cves-dont-panic-here-is-what-you-need-to-know-54cd0d6e8062
|
||
category: security
|
||
subcategory: audit
|
||
likelihood: LOW
|
||
impact: LOW
|
||
confidence: LOW
|
||
technology:
|
||
- jackson
|
||
- jackson-databind
|
||
- spring
|
||
- spring-boot
|
||
- spring-framework
|
||
- JSON
|
||
pattern-either:
|
||
- pattern: '(com.fasterxml.jackson.databind.ObjectMapper $X).enableDefaultTyping(...)
|
||
|
||
'
|
||
- pattern: '(com.fasterxml.jackson.databind.ObjectMapper $X).activateDefaultTyping(...)
|
||
|
||
'
|
||
- pattern: '@JsonTypeInfo(...)
|
||
|
||
'
|
||
- pattern: '@JsonSubTypes(...)
|
||
|
||
'
|
||
- id: elttam-type-resolver-override
|
||
languages: [java]
|
||
message: '$X Jackson Polymorphic Typing: Polymorphic typing may have been introduced through overriding
|
||
the default Jackson type resolver.'
|
||
severity: INFO
|
||
metadata:
|
||
cwe: 'CWE-502: Deserialization of Untrusted Data'
|
||
owasp: 'A8: Insecure Deserialization'
|
||
docs:
|
||
- https://github.com/mbechler/marshalsec/blob/master/marshalsec.pdf
|
||
- https://www.nccgroup.trust/globalassets/our-research/us/whitepapers/2018/jackson_deserialization.pdf
|
||
- https://medium.com/@cowtowncoder/on-jackson-cves-dont-panic-here-is-what-you-need-to-know-54cd0d6e8062
|
||
category: security
|
||
subcategory: audit
|
||
likelihood: LOW
|
||
impact: LOW
|
||
confidence: LOW
|
||
technology:
|
||
- jackson
|
||
- jackson-databind
|
||
- spring
|
||
- spring-boot
|
||
- spring-framework
|
||
- JSON
|
||
pattern-either:
|
||
- pattern: 'com.fasterxml.jackson.databind.jsontype.TypeResolverBuilder $X;
|
||
|
||
'
|
||
- pattern: '(com.fasterxml.jackson.databind.jsontype.TypeResolverBuilder $X) = ...;
|
||
|
||
'
|
||
- id: elttam-default-properties-devmode
|
||
languages: [generic]
|
||
message: default.properties struts.devMode = $MODE
|
||
severity: WARNING
|
||
metadata:
|
||
category: security
|
||
subcategory: audit
|
||
likelihood: LOW
|
||
impact: LOW
|
||
confidence: LOW
|
||
technology:
|
||
- JVM
|
||
- Struts2
|
||
paths:
|
||
include:
|
||
- default.properties
|
||
- default-properties-devmode.properties
|
||
patterns:
|
||
- pattern: 'struts.devMode = $MODE
|
||
|
||
'
|
||
- metavariable-regex:
|
||
metavariable: $MODE
|
||
regex: (true|1)
|
||
- id: elttam-struts-xml-devmode
|
||
languages: [generic]
|
||
message: struts.xml devMode = "$...MODE"
|
||
severity: WARNING
|
||
metadata:
|
||
docs:
|
||
- https://struts.apache.org/core-developers/constant-configuration
|
||
- https://docs.oracle.com/javase/tutorial/essential/environment/sysprop.html
|
||
category: security
|
||
subcategory: audit
|
||
likelihood: LOW
|
||
impact: LOW
|
||
confidence: LOW
|
||
technology:
|
||
- JVM
|
||
- Struts2
|
||
paths:
|
||
include:
|
||
- struts*.xml
|
||
patterns:
|
||
- pattern-either:
|
||
- pattern: '<constant ... name=''struts.devMode'' ... value=''$...MODE'' ... />
|
||
|
||
'
|
||
- pattern: '<constant ... name=''struts.devMode'' ... value="$...MODE" ... />
|
||
|
||
'
|
||
- pattern: '<constant ... name="struts.devMode" ... value=''$...MODE'' ... />
|
||
|
||
'
|
||
- pattern: '<constant ... name="struts.devMode" ... value="$...MODE" ... />
|
||
|
||
'
|
||
- pattern: '<constant ... value=''$...MODE'' ... name=''struts.devMode'' ... />
|
||
|
||
'
|
||
- pattern: '<constant ... value=''$...MODE'' ... name="struts.devMode" ... />
|
||
|
||
'
|
||
- pattern: '<constant ... value="$...MODE" ... name=''struts.devMode'' ... />
|
||
|
||
'
|
||
- pattern: '<constant ... value="$...MODE" ... name="struts.devMode" ... />
|
||
|
||
'
|
||
- metavariable-regex:
|
||
metavariable: $...MODE
|
||
regex: (true|1)
|
||
- id: elttam-web-xml-devmode
|
||
languages: [generic]
|
||
message: web.xml devMode = $MODE
|
||
severity: WARNING
|
||
metadata:
|
||
category: security
|
||
subcategory: audit
|
||
likelihood: LOW
|
||
impact: LOW
|
||
confidence: LOW
|
||
technology:
|
||
- JVM
|
||
- Struts2
|
||
paths:
|
||
include:
|
||
- web.xml
|
||
- web-xml-devmode.xml
|
||
patterns:
|
||
- pattern: "<init-param>\n ...\n <param-name>struts.devMode</param-name>\n ...\n <param-value>$MODE</param-value>\n\
|
||
\ ...\n</init-param>\n"
|
||
- metavariable-regex:
|
||
metavariable: $MODE
|
||
regex: (true|1)
|
||
- id: elttam-struts-xml-action-dmi
|
||
languages: [generic]
|
||
message: struts.xml action $...NAME either using Dynamic Method Invocation or Wildcard Method feature
|
||
severity: WARNING
|
||
metadata:
|
||
docs:
|
||
- https://struts.apache.org/core-developers/action-configuration.html#dynamic-method-invocation
|
||
- https://struts.apache.org/core-developers/action-configuration.html#wildcard-method
|
||
category: security
|
||
subcategory: audit
|
||
likelihood: LOW
|
||
impact: LOW
|
||
confidence: LOW
|
||
technology:
|
||
- JVM
|
||
- Struts2
|
||
paths:
|
||
include:
|
||
- struts*.xml
|
||
patterns:
|
||
- pattern-either:
|
||
- pattern: '<action ... name="$...NAME"
|
||
|
||
'
|
||
- pattern: '<action ... name=''$...NAME''
|
||
|
||
'
|
||
- metavariable-regex:
|
||
metavariable: $...NAME
|
||
regex: .*!.*
|
||
- id: elttam-struts-xml-dmi
|
||
languages: [generic]
|
||
message: struts.xml Dynamic Method Invocation
|
||
severity: WARNING
|
||
metadata:
|
||
docs:
|
||
- https://struts.apache.org/core-developers/action-configuration.html#dynamic-method-invocation
|
||
- https://cwiki.apache.org/confluence/display/WW/S2-019
|
||
category: security
|
||
subcategory: audit
|
||
likelihood: LOW
|
||
impact: LOW
|
||
confidence: LOW
|
||
technology:
|
||
- JVM
|
||
- Struts2
|
||
paths:
|
||
include:
|
||
- struts*.xml
|
||
patterns:
|
||
- pattern-either:
|
||
- pattern: '<constant ... name=''struts.enable.DynamicMethodInvocation'' ... value=''$...MODE'' ...
|
||
/>
|
||
|
||
'
|
||
- pattern: '<constant ... name=''struts.enable.DynamicMethodInvocation'' ... value="$...MODE" ... />
|
||
|
||
'
|
||
- pattern: '<constant ... name="struts.enable.DynamicMethodInvocation" ... value=''$...MODE'' ... />
|
||
|
||
'
|
||
- pattern: '<constant ... name="struts.enable.DynamicMethodInvocation" ... value="$...MODE" ... />
|
||
|
||
'
|
||
- pattern: '<constant ... value=''$...MODE'' ... name=''struts.enable.DynamicMethodInvocation'' ...
|
||
/>
|
||
|
||
'
|
||
- pattern: '<constant ... value=''$...MODE'' ... name="struts.enable.DynamicMethodInvocation" ... />
|
||
|
||
'
|
||
- pattern: '<constant ... value="$...MODE" ... name=''struts.enable.DynamicMethodInvocation'' ... />
|
||
|
||
'
|
||
- pattern: '<constant ... value="$...MODE" ... name="struts.enable.DynamicMethodInvocation" ... />
|
||
|
||
'
|
||
- metavariable-regex:
|
||
metavariable: $...MODE
|
||
regex: (true|1)
|
||
- id: elttam-taglib-action-dmi
|
||
languages: [generic]
|
||
message: JSTL taglib directive either Dynamic Method Invocation (DMI) or Wildcard Method feature prefix="$...PREFIX"
|
||
uri="$...URI" action="$...ACTION"
|
||
severity: INFO
|
||
metadata:
|
||
docs:
|
||
- https://struts.apache.org/core-developers/action-configuration.html#dynamic-method-invocation
|
||
- https://struts.apache.org/core-developers/action-configuration.html#wildcard-method
|
||
category: security
|
||
subcategory: audit
|
||
likelihood: LOW
|
||
impact: LOW
|
||
confidence: LOW
|
||
technology:
|
||
- JVM
|
||
- Struts2
|
||
- JSTL
|
||
- taglib
|
||
paths:
|
||
include:
|
||
- '*.jsp'
|
||
patterns:
|
||
- pattern-either:
|
||
- pattern-inside: '<%@ taglib prefix=''$...PREFIX'' ... uri=''$...URI''
|
||
|
||
...
|
||
|
||
...
|
||
|
||
...
|
||
|
||
...
|
||
|
||
...
|
||
|
||
...
|
||
|
||
...
|
||
|
||
...
|
||
|
||
...
|
||
|
||
...
|
||
|
||
...
|
||
|
||
...
|
||
|
||
...
|
||
|
||
...
|
||
|
||
...
|
||
|
||
...
|
||
|
||
...
|
||
|
||
...
|
||
|
||
...
|
||
|
||
...
|
||
|
||
...
|
||
|
||
...
|
||
|
||
...
|
||
|
||
...
|
||
|
||
...
|
||
|
||
...
|
||
|
||
...
|
||
|
||
...
|
||
|
||
...
|
||
|
||
...
|
||
|
||
...
|
||
|
||
...
|
||
|
||
'
|
||
- pattern-inside: '<%@ taglib prefix="$...PREFIX" ... uri="$...URI"
|
||
|
||
...
|
||
|
||
...
|
||
|
||
...
|
||
|
||
...
|
||
|
||
...
|
||
|
||
...
|
||
|
||
...
|
||
|
||
...
|
||
|
||
...
|
||
|
||
...
|
||
|
||
...
|
||
|
||
...
|
||
|
||
...
|
||
|
||
...
|
||
|
||
...
|
||
|
||
...
|
||
|
||
...
|
||
|
||
...
|
||
|
||
...
|
||
|
||
...
|
||
|
||
...
|
||
|
||
...
|
||
|
||
...
|
||
|
||
...
|
||
|
||
...
|
||
|
||
...
|
||
|
||
...
|
||
|
||
...
|
||
|
||
...
|
||
|
||
...
|
||
|
||
...
|
||
|
||
...
|
||
|
||
'
|
||
- pattern-inside: '<%@ taglib uri=''$...URI'' ... prefix=''$...PREFIX''
|
||
|
||
...
|
||
|
||
...
|
||
|
||
...
|
||
|
||
...
|
||
|
||
...
|
||
|
||
...
|
||
|
||
...
|
||
|
||
...
|
||
|
||
...
|
||
|
||
...
|
||
|
||
...
|
||
|
||
...
|
||
|
||
...
|
||
|
||
...
|
||
|
||
...
|
||
|
||
...
|
||
|
||
...
|
||
|
||
...
|
||
|
||
...
|
||
|
||
...
|
||
|
||
...
|
||
|
||
...
|
||
|
||
...
|
||
|
||
...
|
||
|
||
...
|
||
|
||
...
|
||
|
||
...
|
||
|
||
...
|
||
|
||
...
|
||
|
||
...
|
||
|
||
...
|
||
|
||
...
|
||
|
||
'
|
||
- pattern-inside: '<%@ taglib uri="$...URI" ... prefix="$...PREFIX"
|
||
|
||
...
|
||
|
||
...
|
||
|
||
...
|
||
|
||
...
|
||
|
||
...
|
||
|
||
...
|
||
|
||
...
|
||
|
||
...
|
||
|
||
...
|
||
|
||
...
|
||
|
||
...
|
||
|
||
...
|
||
|
||
...
|
||
|
||
...
|
||
|
||
...
|
||
|
||
...
|
||
|
||
...
|
||
|
||
...
|
||
|
||
...
|
||
|
||
...
|
||
|
||
...
|
||
|
||
...
|
||
|
||
...
|
||
|
||
...
|
||
|
||
...
|
||
|
||
...
|
||
|
||
...
|
||
|
||
...
|
||
|
||
...
|
||
|
||
...
|
||
|
||
...
|
||
|
||
...
|
||
|
||
'
|
||
- pattern-either:
|
||
- pattern: '<$...PREFIX:... ... action=''$...ACTION''
|
||
|
||
'
|
||
- pattern: '<$...PREFIX:... ... action="$...ACTION"
|
||
|
||
'
|
||
- metavariable-regex:
|
||
metavariable: $...ACTION
|
||
regex: .*!.*
|
||
- id: elttam-struts-xml-always-select-full-namespace
|
||
languages: [generic]
|
||
message: struts.xml using alwaysSelectFullNamespace
|
||
severity: WARNING
|
||
metadata:
|
||
docs:
|
||
- https://cwiki.apache.org/confluence/display/WW/S2-057
|
||
- https://nvd.nist.gov/vuln/detail/CVE-2018-11776
|
||
category: security
|
||
subcategory: audit
|
||
likelihood: LOW
|
||
impact: LOW
|
||
confidence: LOW
|
||
technology:
|
||
- JVM
|
||
- Struts2
|
||
paths:
|
||
include:
|
||
- struts*.xml
|
||
patterns:
|
||
- pattern-inside: '<constant $...STUFF />
|
||
|
||
'
|
||
- pattern-either:
|
||
- pattern: '<constant ... name=''struts.mapper.alwaysSelectFullNamespace'' ... value=''$...MODE'' ...
|
||
/>
|
||
|
||
'
|
||
- pattern: '<constant ... name=''struts.mapper.alwaysSelectFullNamespace'' ... value="$...MODE" ...
|
||
/>
|
||
|
||
'
|
||
- pattern: '<constant ... name="struts.mapper.alwaysSelectFullNamespace" ... value=''$...MODE'' ...
|
||
/>
|
||
|
||
'
|
||
- pattern: '<constant ... name="struts.mapper.alwaysSelectFullNamespace" ... value="$...MODE" ... />
|
||
|
||
'
|
||
- pattern: '<constant ... value=''$...MODE'' ... name=''struts.mapper.alwaysSelectFullNamespace'' ...
|
||
/>
|
||
|
||
'
|
||
- pattern: '<constant ... value=''$...MODE'' ... name="struts.mapper.alwaysSelectFullNamespace" ...
|
||
/>
|
||
|
||
'
|
||
- pattern: '<constant ... value="$...MODE" ... name=''struts.mapper.alwaysSelectFullNamespace'' ...
|
||
/>
|
||
|
||
'
|
||
- pattern: '<constant ... value="$...MODE" ... name="struts.mapper.alwaysSelectFullNamespace" ... />
|
||
|
||
'
|
||
- metavariable-regex:
|
||
metavariable: $...MODE
|
||
regex: (true|1)
|
||
- id: elttam-fromXML
|
||
languages: [java]
|
||
metadata:
|
||
cwe: 'CWE-502: Deserialization of Untrusted Data'
|
||
owasp: 'A8: Insecure Deserialization'
|
||
docs:
|
||
- https://x-stream.github.io/javadoc/index.html?com/thoughtworks/xstream/XStream.html
|
||
- https://www.baeldung.com/java-xstream-remote-code-execution
|
||
category: security
|
||
subcategory: audit
|
||
likelihood: LOW
|
||
impact: LOW
|
||
confidence: LOW
|
||
technology:
|
||
- JVM
|
||
- XML
|
||
- XStream
|
||
pattern: (com.thoughtworks.xstream.XStream $XSTREAM).fromXML(...);
|
||
message: 'XStream XML Deserialzation: Check that they have correctly set an allow-list and if an attacker
|
||
can control input.'
|
||
severity: WARNING
|
||
- id: elttam-express-mongodb-nosqli
|
||
languages: [javascript, typescript]
|
||
message: Depending on the context, using (user-controlled) request data directly in a MongoDB query can
|
||
lead to a NoSQLi vulnerability.
|
||
metadata:
|
||
cwe:
|
||
- 'CWE-20: Improper Input Validation'
|
||
owasp:
|
||
- A03:2021 – Injection
|
||
references:
|
||
- https://owasp.org/www-project-web-security-testing-guide/latest/4-Web_Application_Security_Testing/07-Input_Validation_Testing/05.6-Testing_for_NoSQL_Injection
|
||
category: security
|
||
technology:
|
||
- javascript
|
||
subcategory: vuln
|
||
likelihood: LOW
|
||
impact: MEDIUM
|
||
confidence: MEDIUM
|
||
interfile: true
|
||
severity: WARNING
|
||
mode: taint
|
||
pattern-sources:
|
||
- patterns:
|
||
- pattern: function($REQ, ...) { ... }
|
||
- pattern-either:
|
||
- pattern: $REQ.$USERDATA
|
||
- pattern: let { $USERDATA } = $REQ
|
||
- focus-metavariable: $REQ
|
||
- metavariable-regex:
|
||
metavariable: $REQ
|
||
regex: req
|
||
- metavariable-regex:
|
||
metavariable: $USERDATA
|
||
regex: (body|params|query|cookies|headers)
|
||
pattern-sanitizers:
|
||
- patterns:
|
||
- pattern: $X.toString()
|
||
- focus-metavariable: $X
|
||
pattern-sinks:
|
||
- patterns:
|
||
- pattern-inside: '$MODEL = require(''$IMPORT'')
|
||
|
||
...
|
||
|
||
'
|
||
- metavariable-regex:
|
||
metavariable: $IMPORT
|
||
regex: .*(db|models|data|schema|mongo).*
|
||
- pattern-either:
|
||
- pattern: new $MODEL(...)
|
||
- patterns:
|
||
- pattern: $MODEL.$FUNC(...)
|
||
- metavariable-regex:
|
||
metavariable: $FUNC
|
||
regex: (find|delete|update|replace|where|create|insert|map|bulk|aggregate|count).*
|