Detect JavaScript in CrowdStrike LogScale
Adversaries may abuse various implementations of JavaScript for execution. JavaScript (JS) is a platform-independent scripting language commonly associated with web pages, but can also execute in runtime environments outside the browser. JScript is Microsoft's implementation interpreted via the Windows Script engine. JavaScript for Automation (JXA) is a macOS scripting language based on JavaScript, included in Apple's Open Scripting Architecture. Adversaries abuse JS for drive-by compromises, malicious email attachments (.js files), HTA-based payloads, and post-exploitation on macOS via JXA. Threat actors including APT32, TA505, Contagious Interview, and FIN6 use JavaScript extensively.
MITRE ATT&CK
- Tactic
- Execution
- Technique
- T1059 Command and Scripting Interpreter
- Sub-technique
- T1059.007 JavaScript
- Canonical reference
- https://attack.mitre.org/techniques/T1059/007/
LogScale Detection Query
#event_simpleName=ProcessRollup2
| ImageFileName = /(?i)(wscript\.exe|cscript\.exe|mshta\.exe|node\.exe|osascript)$/
| CommandLine = /(?i)(\.(js|jse|wsf|hta)(\s|"|'|$)|activexobject|wscript\.createobject|getobject|wscript\.shell|shell\.application|adodb\.stream|msxml2\.xmlhttp|winhttp\.winhttprequest|eval\(|new\s+function\(|runhtmlapplication|certutil|bitsadmin|powershell|cmd\.exe|cmd\s+\/c|scriptengine|-l\s+javascript|javascript:)/
| eval IsJScript = if(CommandLine = /(?i)\.(js|jse|wsf)/, "true", "false")
| eval IsNodeJS = if(ImageFileName = /(?i)node\.exe$/, "true", "false")
| eval IsJXA = if(ImageFileName = /(?i)osascript$/ AND CommandLine = /(?i)-l javascript/, "true", "false")
| eval ActiveXUse = if(CommandLine = /(?i)(activexobject|wscript\.createobject|getobject)/, 1, 0)
| eval ShellExec = if(CommandLine = /(?i)(wscript\.shell|shell\.application|powershell|cmd\s+\/c)/, 1, 0)
| eval NetworkDownload = if(CommandLine = /(?i)(msxml2\.xmlhttp|winhttp|adodb\.stream|xmlhttprequest)/, 1, 0)
| eval SuspicionScore = ActiveXUse * 2 + ShellExec * 2 + NetworkDownload * 2 + if(IsJScript = "true", 1, 0)
| where SuspicionScore > 0
| table [@timestamp, ComputerName, UserName, ImageFileName, CommandLine, ParentBaseFileName, IsJScript, IsNodeJS, IsJXA, ActiveXUse, ShellExec, NetworkDownload, SuspicionScore]
| sort(field=@timestamp, order=desc) CrowdStrike LogScale (CQL) query using ProcessRollup2 events to detect JavaScript interpreter abuse. Applies weighted suspicion scoring across JScript execution, ActiveX object instantiation, shell spawn chains, and in-script network download patterns associated with T1059.007. Covers wscript, cscript, mshta, node, and osascript.
Data Sources
Required Tables
False Positives & Tuning
- Legitimate use of Windows Script Host by enterprise software vendors for installation, licensing checks, or diagnostic scripts included in their products
- Node.js-based monitoring agents such as Datadog or New Relic that use child_process.exec to collect system metrics and perform health checks
- Red team or penetration testing tooling executing JavaScript payloads in authorized assessments without exclusions configured in the Falcon policy
Other platforms for T1059.007
Testing Methodology
Validate this detection against 3 adversary techniques from Atomic Red Team. Each test below lists the behaviour to exercise and the telemetry you should expect to see. Executable commands and cleanup steps are available with Pro.
- Test 1JScript Execution via wscript.exe
Expected signal: Sysmon Event ID 1: Process Create for wscript.exe executing .js file. Child process event for cmd.exe spawned by wscript.exe. AMSI Event: JScript content inspection.
- Test 2Node.js Command Execution
Expected signal: Sysmon Event ID 1: Process Create for node.exe with child_process in CommandLine. Child process event for cmd.exe spawned by node.exe.
- Test 3JXA Execution on macOS
Expected signal: Unified Log: osascript process with '-l JavaScript' flag. Process tree shows osascript spawning child process for whoami. MDE DeviceProcessEvents on managed macOS endpoints.
References (6)
- https://attack.mitre.org/techniques/T1059/007/
- https://github.com/redcanaryco/atomic-red-team/blob/master/atomics/T1059.007/T1059.007.md
- https://nodejs.org/
- https://posts.specterops.io/persistent-jxa-66e1c3cd1cf5
- https://redcanary.com/blog/clipping-silver-sparrows-wings/
- https://lolbas-project.github.io/
Unlock Pro Content
Get the full detection package for T1059.007 including response playbook, investigation guide, and atomic red team tests.