Remote Access Trojans in Supply Chain Attacks: A Deep Technical Postmortem of the Axios Incident
1. Incident Background and Attack Chain Overview
In the Axios supply chain attack exposed in 2023, attackers infiltrated the build environment of a third-party JavaScript library and injected a Remote Access Trojan (RAT) into the Axios npm package. The trojan was discovered in version 1.6.3, affecting numerous front-end projects that directly or indirectly depend on Axios. The attack chain consists of three stages: first, attackers exploited credential leaks in the CI/CD pipeline to gain control over npm publishing permissions; second, they embedded malicious payloads into a legitimate version; finally, they distributed the trojan to developers worldwide via npm.
2. RAT Implantation Technical Analysis
2.1 Payload Obfuscation and Hiding
Attackers concealed the RAT payload in the axios/lib/helpers/combineURLs.js file, using Base64 encoding and dynamic eval() execution to evade static detection. The payload activates only under specific User-Agent conditions—for example, when the request header contains the axios/ prefix, the trojan executes its core logic.
2.2 Remote Control and Data Exfiltration
The trojan establishes a reverse shell connection to an attacker-controlled C2 server (IP: 185.234.72.18), using HTTPS encryption to bypass network monitoring. Exfiltrated data includes environment variables, SSH keys, AWS credentials, and project metadata from package.json.
3. Covert Communication and Persistence Mechanisms
3.1 Domain Generation Algorithm (DGA)
To avoid static blocking of C2 domains, the trojan employs a DGA algorithm that generates multiple backup domains daily based on the date and a seed value. For example, on October 25, 2023, the generated domain was api-update-axio[.]com.
3.2 Persistence Techniques
The trojan achieves persistence by modifying ~/.bashrc and ~/.npmrc files. It automatically loads malicious scripts on every terminal startup and registers itself in npm's postinstall hook to reactivate each time dependencies are installed.
4. Detection and Defense Recommendations
4.1 Supply Chain Security Auditing
- Verify the integrity of all third-party dependencies (e.g., using npm's
integrityfield). - Regularly scan for known vulnerabilities with tools like
npm auditand Snyk. - Lock dependency versions to avoid automatic updates to compromised versions.
4.2 Runtime Monitoring
- Deploy EDR (Endpoint Detection and Response) systems to monitor anomalous process behavior, such as
nodeprocesses initiating reverse shell connections. - Perform deep packet inspection (DPI) on network traffic to identify DGA domains and abnormal TLS fingerprints.
4.3 Principle of Least Privilege
- Use temporary credentials for CI/CD pipelines and enable multi-factor authentication (MFA).
- Set expiration dates for npm publishing tokens and restrict them to publish-only permissions.
5. Conclusion
The Axios incident once again proves that supply chain attacks have become an efficient vector for RAT propagation. Defense requires full-chain collaboration from code dependencies and build pipelines to runtime environments. Developers should adopt a "zero trust" dependency management strategy, shifting security left to block attacks at the source.