SECURITY ALERT: Bitcoin Hashrate Hijacking Detected on Stratum V1

· Braiins ·

14 min read Original article ↗

‍At a glance:

  • Braiins services were not compromised.
  • The attack is widespread and still a live threat which targets the connections between miners and the pools hijacking the unsecure connection from the miners side.
  • Target: vast majority of bitcoin hashrate globally which uses unsecure Stratum V1 pool connection.
  • Fixes exist and must be applied now across the entire mining industry.

Recently, somebody stole hashrate from bitcoin miners without touching the miners or Braiins Pool, neither the ASICs nor Braiins Pool was compromised. They rerouted the internet traffic between the two, impersonated the pool, and submitted their own work to the miners.

On November 20th this happened to more than a thousand mining sites, spread over hundreds of networks, in the same second.

The weakness they used is not newly discovered.

‍Stratum V1 sends everything in plain text, and a miner has no way to verify that the party on the other end of the connection is who they say they are. That has been true since the protocol appeared in 2012. In 2014, Dell SecureWorks documented an attacker who used the same routing trick to take about $83,000 in mining rewards.

In 2020 we wrote about hashrate hijacking when we explained why Stratum V2 encrypts and authenticates the connection. For years the industry treated the attack as rare enough to live with.

It is now happening at scale, and public routing data shows the same technique aimed at address blocks that host the Stratum endpoints of most of the large pools.

If you only have a minute:

  • This is a weakness in Stratum V1. It works against any pool that accepts plain Stratum V1. Braiins Pool's systems were not compromised.
  • If any pool URL on your miner starts with stratum+tcp://, that connection can be hijacked. This includes backup pools.
  • The fix is Stratum V2, or Stratum V1 over TLS on firmware that verifies the pool's certificate.
  • Miners that can do neither can connect through a small proxy in your own network. We released one today.
  • The attack happens on the network between the miner and the pool. Pool accounts, balances, and payout settings are not affected.
  • Braiins Pool offers all three fixes today: Stratum V2, TLS, and the free proxy.

What happened

The first reports

In early November, miners started to report a share difficulty in the hundreds of millions, far above anything a pool sets for a single machine. Logs from three Antminer S19s in Brazil showed the same sequence on each one: the pool connection dropped, the miner reconnected to the same hostname and the same IP address, and the difficulty then climbed in steps to 536,870,912. The machines kept hashing at full speed, while the miner’s pool dashboard showed zero hashrate. By this point, we had already detected these strange occurrences and started our investigation.

Pool-side records for the previous 30 days contain no records that difficulty this high was ever sent to any miner. So the values came from somewhere else. The next step was to look for other miners that had disappeared and returned in the same seconds as these three.

Dates Where Episodes Size of one episode Length
Nov 7th - 12th Latin America, mostly Brazil and Argentina 19 120 to 400 miner sites, 36 to 174 PH/s 1.5 minutes to 3 hours
Nov 16th Brazil 1, captured packet by packet 3 miners in the capture 3 minutes
Nov 20th Mostly Europe 4 1,050 to 1,600 miner sites, 0.6 to 1.9 EH/s 6 to 49 minutes

What a hijacked miner sees

  1. All affected miners receive a TCP network reset on their pool connection in the same second. The pool receives nothing, and on the pool side the sessions terminate due to a timeout more than two minutes later.
  2. The miners reconnect within a second, to the same hostname and the same IP address. DNS is not touched, so this type of attack is not a case of DNS spoofing, where an attacker makes the same domain resolve to a different IP address.
  3. A different server answers instead of the legitimate one. From Brazil it replied to the Stratum handshake in about 30 ms, whereas the real pool server would need about 280 ms. It accepts any username and password.
  4. The server sends real bitcoin mining jobs and raises the difficulty step by step, up to 2,147,483,640 in one log. The miners hash at full power and report the pool as alive.
  5. When the attacker stops, the miners receive a second reset and reconnect to the real pool. Hundreds of sites return in the same second.

Where the hashrate went

On November 16th, a miner in Brazil who had set up his own monitoring recorded a full episode of this attack in action. The recording shows two different servers answering on the same IP address. The second one was six network hops closer to the miner, answers faster, and accepts any username and password.

The jobs handed out by the server were ordinary jobs from a different large public pool, with the tag and payout addresses belonging to said pool in the coinbase. Therefore, we know the attacker was not solo mining or running their own pool in these cases. They run a proxy that has a worker account at the pool in question, relays the pool's jobs to the hijacked miners, and submits their shares under their own account. The pool where the attacker terminates stolen hashrate is not a part of the attack, it is just the place where the attacker chose to point the hashrate, and every pool should assume its accounts can be used in the same way.

How the traffic was redirected

The internet is a collection of independent networks that tell each other which IP addresses they can reach. The protocol used for this is called BGP (Border Gateway Protocol), and it runs largely on trust. It works like road signs that anyone along the road can put up: a network announces a block of addresses, its neighbors forward the announcement, and routers follow the most specific matching sign.

Stratum addresses of pools belong to a larger block that is announced by the pool's network provider. In the case of November 20th that block holds 4,096 addresses. Somebody announced a smaller block of 256 addresses, and that block included the pool's address.

The smaller block is more specific, so every network that accepted the announcement sent the miners' traffic to the attacker.

‍

The forged route appeared four times that day, for periods between 6 and 49 minutes. Each time, more than a thousand mining sites lost their pool connection in the same second. The owner of the address block, confirmed that it never announced this route and that the diverted connections never reached its network. That evening the provider blocked the network that had propagated the forged route, and the route has not come back since.

It worked for two reasons. Networks that check announcements against the official registry of address owners (RPKI) rejected the forged route, but many networks do not validate routes, and so the miners behind those were vulnerable to the redirection attack. The forged route announcement also listed the real owner as its origin, so hijack monitors that rely solely on origin validation didn’t raise any alarm.

The first wave in Latin America is not confirmed in the same detail yet. Public route data also shows the same kind of announcement for several address blocks that contain Stratum endpoints of other large pools. Those blocks host thousands of unrelated services too, so the data does not suggest that mining was the only target in every case. Some of them were still receiving these forged announcements on November 22nd.

What we ruled out

The pool did not send these difficulty values. This issue does not originate with Braiins Pool, Braiins OS and our infrastructure, or the infrastructure of other pools.

Furthermore, there was no change in answers from DNS servers. The affected miners run at least 12 different firmware types, so no single firmware is the cause. The affected sites are spread over hundreds of networks, so no single internet provider is the cause either.

What it means for mining

This attack does not require compromising the pool or the miner. It relies on hijacking internet routes delivering messages of an unencrypted plain-text protocol. Most of the internet is encrypted today, so rerouted web traffic is useless to an attacker. Stratum V1 is one of the few plain-text protocols left used to carry money, and the proceeds are paid out by a pool to whoever holds the account. Any miner on plain Stratum V1 is a target, on any pool.

The episodes so far were short, but they grew from under 175 PH/s to 1.9 EH/s in two weeks, the attacker changed the method between the two waves, and it moved from one continent to another. We interpret this as testing the waters.

Three things make this attack hard to catch on site. The miner reports normal hashrate, normal temperature, and a live pool, so the drop is only visible on the pool dashboard. Backup URLs do not help when they resolve to the same address as the primary. In fact, one stock miner in the logs we examined did fail over to a backup on a different address, but then switched back to the hijacked primary two minutes later because the fake pool looked stable enough.

Encryption does not prevent the resets. Somebody who controls the route can still cut the connection, and your miner will reconnect or move to its next pool. The difference is that the miner refuses to work for servers that cannot prove legitimately that they are the pool. The attacker does not earn any bitcoin, which removes a major incentive (but not the only possible incentive) for such attacks.

How to protect your miners by using Braiins Pool

Here’s the basic rule: Ensure that no pool entry on the miner starts with stratum+tcp://, including the backups. The attacker can make protected connections fail on purpose, and miners with plain-text unencrypted backups will then walk straight into the fake pool.

Stratum V2

This is the first and best choice for miners that support it. The last part of the URL is the pool's public key, and miners drop servers that cannot prove they have the matching private key.

stratum2+tcp://stratum.braiins.com:3333/9awtMD5KQgvRUh2yFbjVeT7b6hjipWcAsQHd6wEhgtDT9soosna

Stratum V1 over TLS

In Braiins, we have pioneered Stratum V2 since 2020, and we believe it to be the best long term solution for security, privacy, and effectiveness. However, for miners who cannot upgrade yet, we also offer Stratum V1 over TLS, which is a stop-gap measure supported by many miners. Most firmwares write the scheme as stratum+ssl://, but some firmware also writes the scheme as stratum+tls://. These are our links:

stratum+ssl://stratum.braiins.com:3443
stratum+ssl://stratum.braiins.com:33443

You can use the second URL as a fallback, or if your ISP blocks port 3443.

Braiins OS 26.11, released today, adds TLS with certificate and hostname verification, and prevents fallbacks to plain Stratum. To get this protection, upgrade to 26.11 and then change all of your pool URLs to TLS. The upgrade alone changes nothing. On 26.10 and older, use only Stratum V2 URLs for all of your pool entries. 

TLS protects you only if the firmware on the miner checks the certificate.

We tested seven different firmware implementations in our lab on November 20th and November 23rd. Braiins OS 26.11 rejected every bad certificate. Two other widely used firmwares have a TLS option but still accepted invalid ones.. This is a critical vulnerability for a firmware to have, since it makes a feature intended for security provide almost no security at all. Other firmwares have no TLS for third-party pools at all.

On such miners a TLS URL will encrypt the connection, but the miner will still work for whoever answers the network requests.

Do not assume. The Connection Security page on Braiins Academy has a step-by-step test that shows in a few minutes whether your firmware rejects a bad certificate.

Miners that cannot validate the pool

If your firmware fails the test, or has no TLS and no Stratum V2, use the Braiins SV2 Proxy, which we released today.

It is a single free program that you run on a computer in your own network: Linux or Windows through WSL. Your miners talk Stratum V1 to the proxy inside your LAN, and the proxy communicates using Stratum V2 to the pool. It is a first release, so start with a few miners and tell our support if something misbehaves.

Download it from downloads.braiins.com/braiins-proxy. If your hardware is supported, installing Braiins OS removes the need for a proxy.

How to check your miners

Braiins Pool never sets share difficulty above 16,777,216, so higher values mean the miner is not talking to the pool. Look in your miner logs for connection resets followed by a difficulty in the hundreds of millions, and for periods where the miner hashed but the pool dashboard showed nothing.

On Whatsminers, consider searching for this line:

JSON-RPC unexpected mining.configure value: subscribe-extranonce

In the log we examined it appeared on every connection to the fake server, but never on connections to a real pool. However, it is possible to encounter this line even with legitimate pools, so it is not a surefire way to detect you have been attacked.

The full setup for each connection type is on the Connection Security page.

What the whole industry should do now

Pools

The best stop-gap measure you can do is to offer Stratum V1 over TLS on a port that accepts only TLS, with a certificate from a public authority. Self-signed certificates cannot be verified by miners unless the operator installs it by hand, which is not a good option for most miners. When we checked the public endpoints of the largest pools on November 23rd, most offered just plain-text Stratum V1, only a few served Stratum over TLS with a valid certificate.

Here are some tips:

  1. Add Stratum V2 support to your pool.
  2. Then look at your own addresses in RIPE RIS or RouteViews since 1 November. 
  3. Search for more-specific prefixes and for unexpected networks next to your provider in the path, because an origin-change alert will not catch this.
  4. Ask your hosting or DDoS protection provider to announce a /24 containing your Stratum endpoint, with a corresponding RPKI ROA limited to that prefix length. This reduces (but does not fully prevent) exposure to more-specific prefix hijacking, since most networks reject IPv4 announcements longer than /24.

On your own side, you can detect that these attacks are happening if you see many of your clients in many networks whose sessions end due to a timeout in the same minute and who later return in the same second.

Firmware makers

If you are a firmware developer, the most important thing you should do is to verify the certificate and the hostname by default. TLS without verification gives the miner an encrypted connection to the thief. Furthermore:

  1. Ship current root certificates and let operators add pools’ certificates.
  2. Implement Stratum V2 and make sure your implementation validates the pool key. 
  3. Prevent automatic fallbacks to plain text, especially without notifying the operator.

Miners and hosting providers

As a miner, start by asking your pool for its TLS or Stratum V2 endpoint today. If it does not have one, put a proxy or an encrypted tunnel between yourself and the pool, if the pool supports it. If not, switch to a pool which supports TLS or, better, Stratum V2, such as Braiins Pool. For Stratum V2, you can use our proxy. Then:

  1. Validate that your installed firmware refuses bad certificates.
  2. Remove every plain-text backup.
  3. If possible, set an alert for a share difficulty above your pool's maximum, and set up monitoring for significant gaps between the hashrate reported by your miners and the hashrate credited by your pool.

Braiins Pool offers both TLS and Stratum V2 and setup takes only a few minutes. Sign up here:

https://pool.braiins.com/signup

Network operators

Turn on RPKI route origin validation, this would have prevented the attacks on your network. The forged route on November 20th was invalid, and it reached only miners behind networks that do not check.

Reach out to us

  • Miners: if you have questions about this incident or your setup, contact our support team.
  • Industry peers: if you run a pool, build firmware, or work on mining infrastructure and want to talk about this incident, reach out through our support or your usual Braiins contact.

‍