Socket’s Threat Research Team has identified a remote access trojan (RAT) distributed through several PHP packages published on Packagist by the actor behind the username nhattuanbl.
These malicious packages, disguised as useful Laravel utilities, have been observed installing a persistent backdoor that allows remote access to web servers.
The identified packages, nhattuanbl/lara-helper and nhattuanbl/simple-queue, contain the RAT payload. In contrast, nhattuanbl/lara-swagger serves as a dependency that silently installs the malicious code.
The threat actor nhattuanbl has been active on Packagist since 2015, but began uploading the malicious packages in mid-2024.
The malicious payload is contained in the helper.php file, which is included in both lara-helper and simple-queue. When these packages are installed, they load this file into the application, which then executes the RAT.
The lara-swagger package doesn’t contain malicious code on its own. However, it lists lara-helper as a dependency, meaning that installing lara-swagger will also pull in the RAT automatically.
The RAT connects to a command-and-control (C2) server at helper.leuleu.net on port 2096, where it waits for commands from the attacker.
At the time of writing, the C2 server is not responding, but affected systems still have the RAT installed and will continue to attempt reconnection.
The Payload and Its Functionality
The helper.php file in both malicious packages is heavily obfuscated to avoid detection. The file uses three techniques for evading analysis:
- Goto Spaghetti: It creates hundreds of random labeled jumps, making it difficult to follow the execution path.
- Hex/Octal Encoding: All string literals, including domain names and file paths, are encoded, preventing any meaningful text from being visible.
- Randomized Identifiers: Variable and function names are randomly generated, making static analysis more challenging.
Once activated, the RAT attempts to spawn a background process using system commands. It checks whether it’s running with command-line arguments, and if not, it triggers itself to run in the background, as reported by Socket’s Threat Research Team.
The RAT then establishes an encrypted C2 connection using AES-128-CTR, during which it transmits system reconnaissance data, including OS type, version, and unique machine identifiers.
Because the RAT runs in the same process as the Laravel application, it has the same access to system files, environment variables, database credentials, and API keys, increasing the risk of data exfiltration and further compromise.
Recommended Actions
For anyone who has installed any of these malicious packages, it is crucial to treat the host as compromised. Steps to take include:
- Rotate all sensitive secrets, such as database passwords and API keys.
- Remove the infected packages and check for any other malware uploaded to the server.
- Audit outbound traffic to helper.leuleu.net:2096.
- For security teams: Focus on scrutinizing transitive dependencies and avoid using development branches like dev-master in production.
| Command | Behavior |
|---|---|
| ping | Heartbeat every 60s |
| info | Full system profile |
| cmd/powershell | Shell/PowerShell exec |
| run | Background shell |
| screenshot | Base64 PNG capture |
| download | Base64 file read |
| upload | Base64 file write (0777 perms) |
| stop | Exit |
Socket’s tools, including the GitHub App and CLI, can help detect these types of malicious dependencies before they reach production, providing an added layer of defense against similar threats.
Follow us on Google News , LinkedIn and X to Get More Instant Updates. Set Cyberpress as a Preferred Source in Google.