Supply Chain Attack on Axios Pulls Malicious Dependency from NPM
Detection stack
- AIDR
- Alert
- ETL
- Query
Summary
A malicious npm package, plain-crypto-js@4.2.1, was published and later pulled in as a transitive dependency through compromised releases of the widely used JavaScript HTTP client Axios. The package uses a post-install script to deliver a multi-stage remote access trojan targeting Windows, macOS, and Linux. The attack appears to have relied on long-lived npm tokens, allowing threat actors to push malicious versions outside the project’s usual release workflow. Detecting the tampered dependency early can stop the RAT before execution on affected systems.
Investigation
Socket Research carried out static analysis of the setup.js dropper and deobfuscated encoded strings to expose the C2 domain, payload delivery logic, and targeted file system paths. The researchers identified three compromised Axios versions and two additional npm packages that contained the same malicious code. They also extracted network indicators, file paths, and user-agent strings that can be used for detection engineering and rule creation.
Mitigation
Organizations should revoke any long-lived npm tokens and rotate credentials for all potentially affected accounts. Compromised Axios versions and any packages that depend on plain-crypto-js@4.2.1 should be removed or downgraded immediately. Teams should also review lockfiles, CI/CD pipelines, and software supply-chain security controls to identify unauthorized publishing activity and reduce the chance of future package compromise.
Response
Security teams should monitor npm install logs for references to plain-crypto-js@4.2.1 and the affected Axios versions. Detection rules should be created for execution of the postinstall hook, network access to sfrclak.com, and the malicious user-agent string. If compromise is confirmed, affected systems should be quarantined, volatile memory collected for analysis, and the host reimaged if the RAT is found.
"graph TB %% Class definitions classDef technique fill:#c2e0ff classDef tool fill:#ffd9b3 classDef malware fill:#f5b7b1 classDef process fill:#d5f5e3 %% Technique nodes tech_t1195_002["<b>Technique</b> – <b>T1195.002</b> Supply Chain Compromise: Compromise Software Supply Chain<br/><b>Description</b>: Adversaries compromise software update or package distribution to deliver malicious code."] class tech_t1195_002 technique tech_t1127_003["<b>Technique</b> – <b>T1127.003</b> Trusted Developer Utilities Proxy Execution: JamPlus postu2011install hook<br/><b>Description</b>: Malicious code is run via a postu2011install script inserted into a trusted developer utility."] class tech_t1127_003 technique tech_t1059_004["<b>Technique</b> – <b>T1059.004</b> Command and Scripting Interpreter: Unix Shell<br/><b>Description</b>: Use of Unix shell commands (curl, chmod, nohup) to download and launch payloads."] class tech_t1059_004 technique tech_t1059_001["<b>Technique</b> – <b>T1059.001</b> Command and Scripting Interpreter: PowerShell<br/><b>Description</b>: Execution of PowerShell commands to run a Windows based payload."] class tech_t1059_001 technique tech_t1059_005["<b>Technique</b> – <b>T1059.005</b> Command and Scripting Interpreter: Visual Basic<br/><b>Description</b>: Launch of a VBScript based payload."] class tech_t1059_005 technique tech_t1059_003["<b>Technique</b> – <b>T1059.003</b> Command and Scripting Interpreter: Windows Command Shell<br/><b>Description</b>: Execution of batch commands via cmd.exe."] class tech_t1059_003 technique tech_t1027_014["<b>Technique</b> – <b>T1027.014</b> Obfuscated Files or Information: Polymorphic Code<br/><b>Description</b>: Custom Base64 + XOR encoding used to hide malicious code."] class tech_t1027_014 technique tech_t1070_004["<b>Technique</b> – <b>T1070.004</b> Indicator Removal on Host: File Deletion<br/><b>Description</b>: Deleting setup.js and package.json to erase evidence."] class tech_t1070_004 technique tech_t1195_001["<b>Technique</b> – <b>T1195.001</b> Supply Chain Compromise: Compromise Software Dependencies and Development Tools<br/><b>Description</b>: Injecting plainu2011cryptou2011js into the Axios dependency."] class tech_t1195_001 technique tech_t1127["<b>Technique</b> – <b>T1127</b> Trusted Developer Utilities Proxy Execution (npm lifecycle hook)<br/><b>Description</b>: Exploiting npm lifecycle hooks to execute malicious code during package install."] class tech_t1127 technique tech_t1082["<b>Technique</b> – <b>T1082</b> System Information Discovery<br/><b>Description</b>: Gathering OS version, hostname, current user and other system details."] class tech_t1082 technique tech_t1219["<b>Technique</b> – <b>T1219</b> Remote Access Tools<br/><b>Description</b>: Use of a macOS Machu2011O RAT for remote control."] class tech_t1219 technique tech_t1102_002["<b>Technique</b> – <b>T1102.002</b> Web Service: Bidirectional Communication<br/><b>Description</b>: HTTP POST requests to sfrclak.com for commandu2011andu2011control traffic."] class tech_t1102_002 technique tech_t1570["<b>Technique</b> – <b>T1570</b> Lateral Tool Transfer<br/><b>Description</b>: Downloading platformu2011specific binaries or scripts to the compromised host."] class tech_t1570 technique tech_t1036_005["<b>Technique</b> – <b>T1036.005</b> Masquerading: Match Legitimate Resource Name or Location<br/><b>Description</b>: Renaming package.md to package.json and using a legitimateu2011looking name wt.exe."] class tech_t1036_005 technique tech_t1036_003["<b>Technique</b> – <b>T1036.003</b> Masquerading: Rename Legitimate Utilities<br/><b>Description</b>: Renaming powershell.exe to wt.exe to blend in with normal utilities."] class tech_t1036_003 technique %% Process / tool nodes (optional illustrative nodes) process_curl["<b>Process</b> – curl command"] class process_curl process process_chmod["<b>Process</b> – chmod command"] class process_chmod process process_nohup["<b>Process</b> – nohup command"] class process_nohup process malware_rat["<b>Malware</b> – macOS Machu2011O RAT"] class malware_rat malware %% Connections showing attack flow tech_t1195_002 –>|leads_to| tech_t1127_003 tech_t1127_003 –>|uses| tech_t1059_004 tech_t1059_004 –>|executes| tech_t1059_001 tech_t1059_004 –>|executes| tech_t1059_005 tech_t1059_004 –>|executes| tech_t1059_003 tech_t1059_004 –>|employs| tech_t1027_014 tech_t1059_004 –>|leverages| tech_t1195_001 tech_t1059_004 –>|leverages| tech_t1127 tech_t1059_004 –>|collects| tech_t1082 tech_t1027_014 –>|enables| tech_t1070_004 tech_t1082 –>|enables| tech_t1219 tech_t1219 –>|communicates via| tech_t1102_002 tech_t1102_002 –>|facilitates| tech_t1570 tech_t1570 –>|results in| tech_t1036_005 tech_t1570 –>|results in| tech_t1036_003 %% Optional illustrative process links tech_t1059_004 –>|downloads| process_curl tech_t1059_004 –>|sets permissions| process_chmod tech_t1059_004 –>|runs background| process_nohup malware_rat –>|is the| tech_t1219 "
Attack Flow
Detections
Suspicious MacOS – Plist Locations and Names (via file_event)
View
Suspicious NodeJS Child Processes [Windows] (via cmdline)
View
Remote File Upload / Download via Standard Tools (via cmdline)
View
MacOS Suspicious Tmp Folder File Permissions Modification (via cmdline)
View
Suspicious CURL Usage (via cmdline)
View
Possible Execution by Use of chmod and nohup in Single Command (via cmdline)
View
Downloads to Suspicious Folders (via cmdline)
View
LOLBAS WScript / CScript (via process_creation)
View
The Possibility of Execution Through Hidden PowerShell Command Lines (via cmdline)
View
Nohup Usage (via cmdline)
View
IOCs (SourceIP) to detect: Supply Chain Attack on Axios Pulls Malicious Dependency from npm
View
IOCs (DestinationIP) to detect: Supply Chain Attack on Axios Pulls Malicious Dependency from npm
View
IOCs (Emails) to detect: Supply Chain Attack on Axios Pulls Malicious Dependency from npm
View
PowerShell and VBScript Evasion Tactics in Supply Chain Attack [Windows Process Creation]
View
Detection of Malicious npm Package Postinstall Hook Execution [Linux Process Creation]
View
Detection of Malicious Python Script and Temporary File in Linux Supply Chain Attack [Linux File Event]
View
Renamed Windows Terminal and Self-Deleting VBScript Detected [Windows File Event]
View
PowerShell Script Execution with Hidden and Bypass Flags [Windows Powershell]
View
Simulation Execution
Prerequisite: The Telemetry & Baseline Pre‑flight Check must have passed.
Rationale: This section details the precise execution of the adversary technique (TTP) designed to trigger the detection rule. The commands and narrative MUST directly reflect the TTPs identified and aim to generate the exact telemetry expected by the detection logic.
-
Attack Narrative & Commands:
An attacker who has gained limited user privileges on a compromised workstation wishes to download a malicious VBScript payload via a legitimate npm package (supply‑chain scenario). To avoid generic PowerShell detection, the attacker copies
powershell.exeto a new file namedpowershell_renamed.exebut keeps the substring “powershell” in the filename (so theImage|containscheck still matches). The attacker then runs a “where powershell” lookup to enumerate the renamed binary’s path and finally launches the VBScript payload withcscript //nologoto suppress the logo banner. -
Regression Test Script:
# ------------------------------------------------- # Step 1: Create a renamed copy of powershell.exe # ------------------------------------------------- $src = "$env:SystemRootSystem32WindowsPowerShellv1.0powershell.exe" $dst = "$env:Temppowershell_renamed.exe" Copy-Item -Path $src -Destination $dst -Force # ------------------------------------------------- # Step 2: Use 'where' to reference the renamed binary # ------------------------------------------------- $whereOutput = & where.exe powershell_renamed Write-Host "Located renamed PowerShell at: $whereOutput" # ------------------------------------------------- # Step 3: Create a simple malicious VBScript payload # ------------------------------------------------- $vbsPath = "$env:Tempmalicious.vbs" @" Set objShell = CreateObject("WScript.Shell") objShell.Run "cmd.exe /c echo pwned > $env:Temppwned.txt", 0, False "@ | Set-Content -Path $vbsPath -Encoding ASCII # ------------------------------------------------- # Step 4: Execute the VBScript silently using cscript //nologo # ------------------------------------------------- & $dst -Command "cscript //nologo `"$vbsPath`"" # ------------------------------------------------- # End of simulation # ------------------------------------------------- -
Cleanup Commands:
# Remove the renamed PowerShell binary Remove-Item -Path "$env:Temppowershell_renamed.exe" -Force -ErrorAction SilentlyContinue # Delete the malicious VBScript file Remove-Item -Path "$env:Tempmalicious.vbs" -Force -ErrorAction SilentlyContinue # Remove evidence of execution Remove-Item -Path "$env:Temppwned.txt" -Force -ErrorAction SilentlyContinue