Cryptojacking ๐
What it is, why it matters, how itโs done, and how to prevent cryptojacking
Cryptojacking is the unexpected and unwanted use of computational resources to mine crypto-currencies. Itโs hijacking resources to mine crypto-currencies.
Donโt confuse it with ransomware doing crypto-locking. Crypto-locking prevents you from accessing your data and uses blackmailing to get money. Cryptojacking uses your computational resources like a parasite, but they donโt touch your data and they might even try to not use too much in order to stay undetected for longer.
Crypto-currencies such as Bitcoin (BTC) and Ethereum (ETH) have gained a lot of popularity in 2021 / 2022. Before 2020, they only were used by few people and the total market capitalization was pretty low. For this reason there wasnโt a lot of money to make with them.
Let me give you a Tweet-length explanation how crypto-currencies allow you to convert computational resources into money: Every crypto-currency needs to ensure that their is a shared ground truth of who owns what over a large network of independent nodes (a consensus protocol). The clearest way how to do that in a secure manner is called โProof of Workโ (PoW): You make a computationally hard task and the first one who solves the task may change the state of the database. To incentivize people, you allow people to spend a bit more of the cryptocurrency than previously existed. The person who solves the computationally hard work is called the โminerโ and the โmining rewardโ is how they get money.
Monero was pretty popular to mine crypto in cryptojacking attacks. One reason might be that most serious Bitcoin / Ethereum mining use so much computational power via GPUs and custom chips (ASICs) that cryptojacking would not be cost-effective enough.
More about that in my articles:
Why Cryptojacking matters
- 2017: Starbucks cafeโs wi-fi made computers mine crypto-currency (source)
- 2018: Hackers Enlisted Teslaโs Public Cloud to Mine Cryptocurrency (source)
- 2018: Unsecured AWS led to cryptojacking attack on LA Times (source)
- 2020: AWS Cryptojacking Worm Spreads Through the Cloud (source)
- 2021: $45,000 AWS Crypto-Mining Hack Generates $800 of Monero (source)
How are Cryptojacking attack executed?
There are two simple and common ways:
- JavaScript injection in Websites: If an attacker can make your website include JavaScript, they can make all users of that website mine crypto-currencies for them. In-Browser cryptojacking is inefficient, but itโs possible. Thatโs what happened to Starbucks users in 2017. Coinhive was famous for being used by cryptojackers.
- Leaked Cloud Secrets: People often accidentally put their AWS secrets into public Github repositories. They might delete the secrets eventually, but they forget that they are still in the git history. Attackers can scrape Github (or other source code hosting sites like Gitlab) and use them. Cryptojacking provides them with a simple way to convert those keys to money without blackmailing.
- Misconfigured servers: Some servers are configured in the wrong way or simply donโt require passwords where they should. This can allow attackers to execute arbitrary code. Maybe it doesnโt directly allow access to confidential data, e.g. when itโs a test system. But with cryptojacking the attacker does not have to steal data to make money. Tesla had the issue of a misconfigured server which was detected in 2018.
- Supply-chain attacks: Instead of going directly for your services, attackers might target commonly used software and include cryptominers in them. Malicious open source maintainers could even include them directly.
What can I do to prevent Cryptojacking attacks?
There are two sides to defending against cryptojacking: Server admins and website users.
When admins are affected by cryptojacking, something else had to be severely broken beforehand. You should have billing alerts, but I would not do anything specifically against cryptojacking. In the end, loosing money due to too many resources being used might be way cheaper and easier to detect than leaking your customers data or being blackmailed as somebody can shut down your servers.
If somebody was able to include a cryptominer into your website, you have an XSS vulnerability:
You should deal with that in the same way as you would with other XSS vulnerabilities. For a business, the cryptojacking attack is way less damaging and easier to detect than leaking customer / business secrets.
As a user, itโs very annoying if websites use too many resources. No matter for which reason. But itโs only annoying and doesnโt really do harm. You might run out of battery sooner and your screen might freeze. Ad-blockers might help with that, e.g. this blocklist seems to have cryptominers on it. However, the location of the cryptominer can easily change and also fingerprints for those scripts can easily be adjusted. The only effective way to prevent cryptomining is to disable JavaScript, but that makes most of the internet unusable nowadays.
How to identify Cryptojacking
You can identify cryptojacking by extreme CPU usage. The network traffic might also help (source, source). Code-complexity was also successfully used to detect in-browser cryptojacking (source).
Whatโs next?
In this series about application security (AppSec) we already explained some of the techniques of the attackers ๐ and also techniques of the defenders ๐:
- Part 1: SQL Injections ๐๐
- Part 2: Donโt leak Secrets ๐
- Part 3: Cross-Site Scripting (XSS) ๐๐
- Part 4: Password Hashing ๐
- Part 5: ZIP Bombs ๐
- Part 6: CAPTCHA ๐
- Part 7: Email Spoofing ๐
- Part 8: Software Composition Analysis (SCA) ๐
- Part 9: XXE attacks ๐๐
- Part 10: Effective Access Control ๐
- Part 11: DOS via a Billion Laughs ๐
- Part 12: Full Disk Encryption ๐
- Part 13: Insecure Deserialization ๐
- Part 14: Docker Security ๐
- Part 15: Credential Stuffing ๐๐
- Part 16: Multi-Factor Authentication (MFA/2FA) ๐
- Part 17: ReDoS ๐
- Part 18: Secure and Private Instant Messaging ๐
- Part 19: Cryptojacking ๐
- Part 20: Backups ๐
- Part 21: Cryptotrojans ๐
- Part 22: Single-Sign-On ๐
- Part 23: Clipboard Hijacking ๐
- Part 24: Certificates ๐
- Part 25: Race Condition Attacks in Blockchains ๐
- Part 26: Mobile Device Management (MDM) ๐
- Part 27: Server-Side Request Forgery (SSRF) ๐
- Part 28: Network Separation ๐
- Part 29: Social Engineering (including Phising) ๐
- Part 30: Virtual Private Networks (VPNs) ๐
- Part 31: CSRF ๐
- Part 32: ??
- Part 33: Ransomware and Crypto-locking
Let me know if you are interested in more articles around AppSec / InfoSec!
I love writing about software development and technology ๐คฉ Donโt miss updates: Get my free email newsletter ๐ง or sign up for Medium โ๏ธ if you havenโt done it yet โ both encourage me to write more ๐ค
New to trading? Try crypto trading bots or copy trading





