Nesta seção
How Cryptojacking Works and How to Defend Against It

Snyk Team
Key takeaways
Cryptojacking is a stealthy and resource-draining attack that hijacks devices for unauthorized crypto mining.
It can occur via malicious scripts in browsers, infected software, cloud infrastructure abuse, or phishing.
Prevention relies on secure coding practices, strong cloud configuration, and awareness of social engineering techniques.
Detection requires monitoring for unusual system behavior, mining pool connections, and anomalous resource consumption.
Snyk provides developer-first tools like Snyk Code and Snyk Container to help identify, prevent, and remediate vulnerabilities linked to cryptojacking attacks.
It’s easy to overlook what’s happening under the surface of our devices. Most of us don’t question a slightly slower laptop or a phone that runs hotter than usual. Some lag feels routine with constant updates, background processes, and heavy workloads. But those subtle signs sometimes hint at something more than everyday wear.
Attackers don’t always need to steal data to make money. Sometimes, they’re after your system’s processing power, quietly turning everyday devices into tools for their own gain.
What is cryptojacking?
Cryptojacking is the unauthorized use of someone else’s device, such as a laptop, server, smartphone, or cloud environment, to mine cryptocurrency. Unlike traditional cyberattacks that aim to steal data or cause disruption, cryptojacking quietly hijacks system resources, often without the user’s knowledge. The goal is simple: profit without paying for the hardware or electricity.
Legitimate crypto mining requires permission, specialized equipment, and substantial energy. Miners willingly undertake a resource-intensive process, hoping the digital coins they earn outweigh the operational costs. Cryptojacking flips this model. By sneaking mining code into unsuspecting systems, attackers reap the rewards while victims absorb the wear, tear, and energy consumption.
This form of cybercrime has become increasingly popular with threat actors for a few reasons. It’s relatively low-risk. Most victims never even realize their machines have been compromised. There’s no need to exfiltrate data, no ransom note, and often no immediate red flags. Once in place, cryptojacking can generate passive income for months or even years, making it an appealing long-term strategy for financially motivated attackers.

Crypto mining hijacking vs legitimate cryptocurrency mining
Legitimate cryptocurrency mining is a resource-heavy process where individuals or organizations use their own hardware, like GPUs or ASICs, to validate blockchain transactions. It requires permission, investment, and ongoing maintenance, with miners hoping the rewards outweigh the cost of electricity and equipment.
Cryptojacking skips all of that. Instead of building infrastructure, attackers hijack other people’s devices like servers, laptops, and cloud instances by secretly running mining software in the background. Victims often absorb the performance hits, energy drain, and potential hardware damage without realizing it.
For organizations, the toll can be significant. Hijacked cloud resources lead to bloated bills, sluggish systems, and added strain on IT teams. Worse, cryptojacking often hides in plain sight, quietly draining resources and exposing systems to further compromise.
How does cryptojacking work?
Cryptojacking typically happens in one of two ways: through browser-based scripts or malware infections.
Browser-based attacks use JavaScript, often embedded in websites or ads, to mine cryptocurrency directly in a visitor’s browser. Tools like Coinhive made this tactic easy to deploy. While these scripts usually stop when the browser closes, some are designed to persist or restart automatically.
Malware-based attacks are more invasive. Delivered via phishing links or malicious downloads, these crypto miners install directly on a device and run in the background, often with stealth features to avoid detection.
Both methods hijack system resources, maxing out CPUs, draining GPUs, and overloading memory. Meanwhile, infected machines quietly connect to mining pools, sending earnings to the attacker without the victim’s knowledge.
Cryptojacking attack vectors and techniques
Cryptojacking can enter through multiple doors, some hiding in plain sight, others embedded deep within the infrastructure. Attackers adapt their methods based on the environment, from individual browsers to sprawling cloud deployments. Here’s how they get in and stay in.
Web-based cryptojacking is one of the more subtle approaches. It relies on in-browser mining scripts, often injected into compromised websites, online ads, or third-party plugins. These scripts kick in as soon as the page loads, tapping into a visitor’s CPU for as long as the tab remains open. More advanced versions attempt to persist after the browser closes or evade detection by obfuscating their code and bypassing ad blockers.
Malware-based attacks are more persistent and dangerous. These involve Trojanized applications or downloads that install crypto-mining malware on a device. Some crypto miners are wormable and capable of spreading laterally across networks. Others operate without leaving files behind, using fileless techniques or hijacking native tools like PowerShell to run in memory and avoid traditional defenses.
Cloud and server environments have also become prime targets. Attackers exploit misconfigured cloud services, steal exposed API keys, or escape from containers to access the broader infrastructure. Even serverless environments aren’t immune. Threat actors have been known to deploy crypto miners in functions like AWS Lambda, taking advantage of on-demand resources that scale automatically and often unnoticed.
Social engineering plays a supporting role in many of these attacks. Phishing emails deliver cryptojacking payloads, often disguised as crypto wallets, mining tools, or legitimate software. Misleading ads and fake downloads further broaden the reach, tricking users into running mining code on their own systems.
What ties all of these techniques together is stealth. Cryptojacking doesn’t need to break data or hold systems hostage to be effective. It just needs to quietly blend in and keep running.

How to prevent cryptojacking
Preventing cryptojacking means closing the gaps that attackers exploit through insecure code, misconfigured infrastructure, or untrained users. A layered approach is the most effective.
Here’s where to focus:
Secure your code and dependencies
Use trusted packages, scan early for vulnerabilities, and avoid outdated libraries. Many attacks start with compromised third-party code.
Harden containers and cloud environments
Apply the least privilege, scan images, and audit configurations regularly. Patching known issues across cloud and ephemeral systems limits attacker access.
Educate your users
Train teams to spot phishing emails, fake downloads, and suspicious tools. A single click can trigger a hidden miner.
Protect the browser
Use script blockers or security-focused browser extensions to block or flag in-browser mining attempts.
Together, these steps help reduce your exposure and stop cryptojacking before it starts.

Detection techniques for crypto mining hijacking
Preventive controls are essential, but cryptojacking can still sneak through. That’s where detection comes in, spotting the signs that something isn’t right.
Watch for unusual CPU or GPU usage
Sudden spikes can signal mining activity, especially on idle machines.
Track power consumption
Unexplained increases in energy use, particularly in cloud or data center environments, are worth investigating.
Monitor network traffic
Find connections to known mining pools, whether encrypted or obfuscated.
Use behavioral signatures
Detect suspicious patterns tied to hashing algorithms or system resource use.
Apply forensic tools
Memory and disk analysis can uncover hidden or fileless miners that evade traditional scans.
Layering these techniques improves visibility and helps catch mining operations that try to stay under the radar.
The future of cryptojacking
Cryptojacking is getting smarter. What once relied on basic scripts now uses obfuscated code that hides inside legitimate browser activity, making detection more difficult.
Attackers also turn to AI-generated malware, using tools that can adapt to different environments and evade traditional defenses. At the same time, LLM-generated code, while helpful, can introduce insecure patterns or misconfigurations, giving cryptojackers new paths.
Cloud-native and serverless platforms add to the risk. Misconfigurations, idle resources, and automatic scaling create opportunities for mining at scale, often without immediate signs of compromise.
As these techniques evolve, defenders must stay just as agile. Cryptojacking is no longer just a browser nuisance. It’s a full-stack security concern.

How Snyk can help stop cryptojacking
Detecting and preventing cryptojacking starts with visibility into your code, configurations, and every change’s risks. That’s where Snyk comes in.
Snyk Code helps developers catch malicious snippets, risky functions, and vulnerable dependencies before they ever make it into production. Whether you’re importing a third-party library or reviewing AI-generated code, Snyk identifies issues early, right in the developer workflow.
Snyk Container and Snyk IaC extend that protection into cloud-native environments. Misconfigured permissions, exposed secrets, and insecure infrastructure definitions are all potential cryptojacking entry points. Snyk scans your containers and infrastructure as code to spot these weaknesses early, helping prevent costly cloud resource abuse.
For teams integrating AI into their development process, DeepCode AI Fix brings proactive defense. It goes beyond highlighting risks by suggesting secure fixes based on context, helping developers move faster without trading off security. It also plays a key role in guarding against threats like agent hijacking and offers a powerful security companion for AI-generated code.
Cryptojacking may be subtle, but with the right tools, it doesn’t have to be invisible. Snyk helps teams stay ahead by securing code, hardening infrastructure, and empowering developers to build without compromise.
FAQ
Can cryptojacking damage hardware?
Yes, sustained high CPU or GPU usage from cryptojacking can cause overheating, reduced lifespan, and degraded performance of affected systems.
Is cryptojacking illegal?
Yes, unauthorized use of computing resources for crypto mining is considered illegal in most jurisdictions and can lead to criminal prosecution or civil penalties.
How do I know if my system is infected with cryptomining malware?
Unexplained slowdowns, overheating, spikes in fan activity, and high CPU/GPU usage, especially when idle, can all be signs of cryptojacking.
Can mobile devices be affected?
Yes, cryptojacking scripts and apps can target smartphones and tablets, often through malicious apps or compromised websites.
Build defense into every layer
Cryptojacking may not be as loud as a data breach or ransomware attack, but its impact can be just as costly. It drains resources, inflates cloud bills, slows systems, and quietly erodes performance across environments.
Preventing these attacks requires a proactive mindset: secure your code and dependencies, harden cloud and container configurations, educate users, and monitor for abnormal activity. Detection is just as critical. Watch for unusual CPU/GPU spikes, track outbound connections, and investigate behavioral patterns indicating mining.
Most importantly, build security into every stage of the development lifecycle. When tools are integrated into the SDLC, from code to cloud, you reduce the chances of cryptojacking slipping through unnoticed.
Start securing your environment with Snyk and stay ahead of hidden threats before they mine your resources in the background.
Empower developers to build secure applications
Snyk enables developers to build securely from the start, while giving security teams complete visibility and comprehensive controls.