Long Base64 Encoded Command via Scripting Interpreter

Identifies oversized command lines used by Python, PowerShell, Node.js, or Deno that contain base64 decoding or encoded-command patterns. Adversaries may embed long inline encoded payloads in scripting interpreters to evade inspection and execute malicious content across Windows, macOS, and Linux systems.

Elastic rule (View on GitHub)

  1[metadata]
  2creation_date = "2026/03/27"
  3integration = ["endpoint"]
  4maturity = "production"
  5updated_date = "2026/09/18"
  6
  7[rule]
  8author = ["Elastic"]
  9description = """
 10Identifies oversized command lines used by Python, PowerShell, Node.js, or Deno that contain base64 decoding or
 11encoded-command patterns. Adversaries may embed long inline encoded payloads in scripting interpreters to evade
 12inspection and execute malicious content across Windows, macOS, and Linux systems.
 13"""
 14from = "now-9m"
 15language = "esql"
 16license = "Elastic License v2"
 17name = "Long Base64 Encoded Command via Scripting Interpreter"
 18note = """## Triage and analysis
 19
 20### Investigating Long Base64 Encoded Command via Scripting Interpreter
 21
 22This rule detects process start events where the original `process.command_line` field was ignored at index time due to
 23its size, but the full command line remains available in `process.command_line.text`. Attackers commonly use very long
 24base64-encoded inline commands with interpreters such as Python, PowerShell, Node.js, and Deno to conceal payloads and
 25avoid straightforward command-line inspection.
 26
 27### Possible investigation steps
 28
 29- Review `process.command_line.text` to determine whether the encoded content includes shell commands, scripts, URLs, or embedded payloads.
 30- Inspect the parent process and execution chain to understand how the interpreter was launched and whether it originated from a browser, office application, archive utility, or remote access tool.
 31- Check whether the same host or user generated additional suspicious process, network, or file events around the same time.
 32- If the payload can be safely decoded in an isolated environment, inspect the decoded content for follow-on execution, credential access, persistence, or download behavior.
 33
 34### False positive analysis
 35
 36- Administrative automation, packaging workflows, or developer tooling may legitimately pass large encoded blobs to scripting interpreters.
 37- PowerShell remoting, software deployment frameworks, or internal bootstrap scripts can occasionally use encoded commands; validate the source, user, and expected automation context.
 38
 39### Response and remediation
 40
 41- Isolate the affected host if the decoded content or surrounding activity indicates malicious execution.
 42- Terminate the suspicious interpreter process and any spawned child processes.
 43- Preserve the full command line and related process tree for forensic analysis before making changes on the host.
 44- Reset or revoke any credentials, tokens, or secrets exposed by the decoded payload or subsequent attacker activity.
 45"""
 46risk_score = 73
 47rule_id = "74d31cb7-4a2c-44fe-9d1d-f375b9f3cb61"
 48severity = "high"
 49tags = [
 50    "Domain: Endpoint",
 51    "OS: Windows",
 52    "OS: macOS",
 53    "OS: Linux",
 54    "Use Case: Threat Detection",
 55    "Tactic: Defense Evasion",
 56    "Tactic: Execution",
 57    "Data Source: Elastic Defend",
 58    "Resources: Investigation Guide",
 59    "Noise: Unknown",
 60    "Performance: Normal",
 61    "Profile: Recommended",
 62    "Threat: Encoding-Based Obfuscation",
 63    "Threat: Script-Based Execution",
 64    "Rule Type: ES|QL",
 65    "Platform: Windows",
 66    "Platform: Linux",
 67    "Platform: macOS",
 68]
 69timestamp_override = "event.ingested"
 70type = "esql"
 71
 72query = '''
 73FROM logs-endpoint.events.process-* METADATA _id, _index, _version, _ignored
 74| MV_EXPAND _ignored
 75| WHERE _ignored == "process.command_line"
 76| WHERE event.category == "process" and event.type == "start"
 77| EVAL command_line = TO_LOWER(process.command_line.text), pname = TO_LOWER(process.name)
 78| WHERE 
 79(
 80    (
 81        /* Python: inline exec with base64 decode or -c flag with encoded payload */
 82        pname like "python*" and
 83        (
 84            command_line like "*b64decode*" or
 85            (command_line like "*-c*" and command_line like "*base64*")
 86        )
 87    ) or
 88    (
 89        /* PowerShell: encoded command flag — require trailing space to avoid matching
 90           -Encoding, -EncryptionType, -EncryptionProvider, etc. */
 91        (pname like "powershell*" or pname like "pwsh*") and
 92        (
 93            command_line rlike ".* -(e|en|enc|enco|encod|encode|encoded|encodedcommand) .+" or
 94            command_line like "*-encodedcommand*" or
 95            command_line like "*frombase64string*"
 96        )
 97    ) or
 98    (
 99        /* Node.js: buffer.from must be paired with base64 to avoid matching
100           general Buffer usage; atob is always base64 */
101        pname like "node*" and
102        (
103            (command_line like "*buffer.from*" and command_line like "*base64*") or
104            command_line like "*atob(*"
105        )
106    ) or
107    (
108        /* Deno: eval( (not eval/evaluate/evaluation), atob, or buffer+base64 */
109        pname like "deno*" and
110        (
111            command_line like "*atob(*" or
112            (command_line like "*buffer.from*" and command_line like "*base64*") or
113            command_line like "*eval(*"
114        )
115    )
116)
117| EVAL Esql.length_cmdline = LENGTH(command_line)
118| WHERE Esql.length_cmdline >= 4000
119| KEEP *
120'''
121
122[[rule.threat]]
123framework = "MITRE ATT&CK"
124
125[[rule.threat.technique]]
126id = "T1027"
127name = "Obfuscated Files or Information"
128reference = "https://attack.mitre.org/techniques/T1027/"
129
130[[rule.threat.technique]]
131id = "T1140"
132name = "Deobfuscate/Decode Files or Information"
133reference = "https://attack.mitre.org/techniques/T1140/"
134
135[rule.threat.tactic]
136id = "TA0005"
137name = "Defense Evasion"
138reference = "https://attack.mitre.org/tactics/TA0005/"
139
140[[rule.threat]]
141framework = "MITRE ATT&CK"
142
143[[rule.threat.technique]]
144id = "T1059"
145name = "Command and Scripting Interpreter"
146reference = "https://attack.mitre.org/techniques/T1059/"
147
148[[rule.threat.technique.subtechnique]]
149id = "T1059.001"
150name = "PowerShell"
151reference = "https://attack.mitre.org/techniques/T1059/001/"
152
153[[rule.threat.technique.subtechnique]]
154id = "T1059.006"
155name = "Python"
156reference = "https://attack.mitre.org/techniques/T1059/006/"
157
158[[rule.threat.technique.subtechnique]]
159id = "T1059.007"
160name = "JavaScript"
161reference = "https://attack.mitre.org/techniques/T1059/007/"
162
163[rule.threat.tactic]
164id = "TA0002"
165name = "Execution"
166reference = "https://attack.mitre.org/tactics/TA0002/"

Triage and analysis

Investigating Long Base64 Encoded Command via Scripting Interpreter

This rule detects process start events where the original process.command_line field was ignored at index time due to its size, but the full command line remains available in process.command_line.text. Attackers commonly use very long base64-encoded inline commands with interpreters such as Python, PowerShell, Node.js, and Deno to conceal payloads and avoid straightforward command-line inspection.

Possible investigation steps

  • Review process.command_line.text to determine whether the encoded content includes shell commands, scripts, URLs, or embedded payloads.
  • Inspect the parent process and execution chain to understand how the interpreter was launched and whether it originated from a browser, office application, archive utility, or remote access tool.
  • Check whether the same host or user generated additional suspicious process, network, or file events around the same time.
  • If the payload can be safely decoded in an isolated environment, inspect the decoded content for follow-on execution, credential access, persistence, or download behavior.

False positive analysis

  • Administrative automation, packaging workflows, or developer tooling may legitimately pass large encoded blobs to scripting interpreters.
  • PowerShell remoting, software deployment frameworks, or internal bootstrap scripts can occasionally use encoded commands; validate the source, user, and expected automation context.

Response and remediation

  • Isolate the affected host if the decoded content or surrounding activity indicates malicious execution.
  • Terminate the suspicious interpreter process and any spawned child processes.
  • Preserve the full command line and related process tree for forensic analysis before making changes on the host.
  • Reset or revoke any credentials, tokens, or secrets exposed by the decoded payload or subsequent attacker activity.

Related rules

to-top