|
|
Subscribe / Log in / New account

Weaponizing middleboxes

By Jake Edge
September 21, 2021

Middleboxes are, unfortunately in many ways, a big part of today's internet. While middleboxes inhabit the same physical niche as routers, they are not aimed at packet forwarding; instead they are meant to monitor and manipulate the packets that they see. The effects of those devices on users of the networks they reign over may be unfortunate as well, but the rest of the internet is only affected when trying to communicate with those users—or so it was thought. Based on some recently reported research, it turns out that middleboxes can be abused to inflict denial-of-service (DoS) attacks elsewhere on the net.

Though it lacks the catchy nickname and logo that have come to dominate security research reporting over the last few years, the "Weaponizing Middleboxes for TCP Reflected Amplification" web site describes a potent threat. The researchers, Kevin Bock, Abdulrahman Alaraj, Yair Fax, Kyle Hurley, Eric Wustrow, and Dave Levin, found flaws in the TCP/IP implementation of various middleboxes that allow DoS attacks via amplification. The middleboxes they studied are those deployed by government organizations for the purposes of censorship, but "even benign deployments of firewalls and intrusion prevention systems in non-censoring nation-states can be weaponized using the techniques we discovered".

It is important to note that the problems found are in the TCP/IP implementations of these middleboxes and not in the protocol itself. Those problems could be fixed, perhaps, but the researchers are skeptical that will happen:

Completely fixing this problem will require countries to invest money in changes that could weaken their censorship infrastructure, something we believe is unlikely to occur.

Background

Amplification is a technique used in denial-of-service attacks that allows an attacker to send a relatively small amount of data which causes a larger amount of data to reach the victim. Typically, this is done by spoofing the IP address of the victim while making a request to a service that will respond with a larger reply. The ratio between the sizes of the response and request is known as the "amplification factor"; historically, those have ranged from low single digits to as much as 50,000x for the memcached amplification flaw that was fixed in 2018.

In the past, DoS amplifications have used UDP because TCP requires a three-way handshake to establish a connection. Spoofing a victim's IP address and trying to establish a TCP connection does not work because the information in the SYN-ACK response from the destination (i.e. step 2 of the handshake) gets sent to the victim. That means that the attacker does not receive what is needed to complete the handshake, thus the connection never gets established. But the researchers found that the censorship middleboxes ignore the fact that there is no TCP connection established and respond (to the victim IP) with an HTML page indicating that the content is censored (i.e. a "block page").

Middleboxes are often not TCP-compliant by design: many middleboxes attempt [to] handle asymmetric routing, where the middlebox can only see one direction of packets in a connection (e.g., client to server). But this feature opens them to attack: if middleboxes inject content based only on one side of the connection, an attacker can spoof one side of a TCP 3-way handshake, and convince the middlebox there is a valid connection.

Methodology

In order to find packet sequences that would elicit the misbehavior, the researchers developed Geneva, which is a program that employs a genetic algorithm to "automatically discover new ways to evade censorship". The genetic algorithm is used to refine the results, "but at its core, Geneva is a packet-level network fuzzer". They gathered a list of 184 censorship middleboxes from around the world using data gathered by the Quack tool from Censored Planet. Then they turned Geneva loose with a goal of finding amplifications: "We modified Geneva’s fitness function to reward it for making the elicited response as large as possible, and then trained Geneva against all 184 middleboxes."

That fuzzing resulted in finding five packet sequences that would elicit amplified responses, as well as five ways to increase the amplification for a small subset of the middleboxes, which could be used in targeted attacks. The packet sequences abuse the TCP protocol in various ways, which should result in the packets being ignored, but the middleboxes tested would instead respond with a block page.

As might be guessed, these censoring middleboxes need to find something "objectionable" in the packet before they will respond with a block page. Using the data gathered by Quack, the researchers put together a list of the five most-blocked domains. As it turned out, those domains covered five different subject areas that governments like to censor (e.g. pornography, file sharing, social media). Those domains were used in well-formed HTTP GET requests in a packet (or packets) that caused the censor boxes to send the block page.

In a fairly eye-opening experiment—one that would, of course, be impossible for IPv6—the researchers scanned the entire IPv4 address space 35 separate times. They used the five domains of "interest", plus no domain and example.com as controls, with each of the five packet sequences and recorded the amplification found for each. Below is a graph from the web site that shows the amplification factors found:

[Amplification graph]

Amplification

Generally, the amount of amplification from a country's censorship middlebox is fairly low, though there are exceptions. "Most of these nation-states are weak amplifiers (the Great Firewall of China only offers about 1.5x amplification, for example), but some of them offer more damaging amplifications, such as Saudi Arabia (~20x amplification)." Certain types of attacks can actually lead to effectively infinite amplification, however, either because of a routing loop where the time-to-live (TTL) value is not decremented correctly or one where the victim system's default response sustains the attack:

We found amplifiers that, once triggered by a single packet sequence from the attacker, will send an endless stream of packets to the victim. In our testing, some of these packet streams lasted for days, often at the full bandwidth the amplifier’s link could supply.

A factor that makes these attacks even more pernicious is that when the censorship middleboxes block a connection to a host, they spoof the IP address of that host as the source address in their response. That way, it appears that the response is coming from the host and not from the middlebox. Normally, an amplified response has the source IP address of the amplifier, which might make it easier to filter when a DoS attack is underway. That is not the case here:

The real challenge of nation-states is that their censorship infrastructure usually processes all traffic entering or exiting the country. This means that unlike other amplification attacks, where the source IP address of the traffic received by the victim is the amplifier itself, every IP address behind a middlebox can appear as the source of traffic. Said another way: every IP address within an amplifying nation-state can be an amplifier.

The full damage that attacker could do using this technique is not known. The amplification factor is only one part of the equation, as it also depends on the bandwidth available to the amplifier, which the researchers were unwilling to try to measure:

Unfortunately, this is the hardest to study ethically. To measure the maximum capacity of a given amplifier, we would have to completely saturate the link for each network, which could have real negative consequences on the users of that network. For now, the true capacity available to attackers from this attack is unknown.

This mechanism has not been seen in the wild, at least yet, but the researchers are working with companies that monitor and mitigate distributed DoS (DDoS) attacks in order to keep an eye out for it—and assist in mitigation. In September 2020, the flaws were reported to "several country-level CERTs [computer emergency response teams], DDoS mitigation services, and firewall manufacturers" in an effort at responsible disclosure. But, as noted, the changes needed to actually fix the problems would potentially threaten the reasons for deploying the middleboxes (i.e. censorship), so are rather unlikely to ever occur.

There is a lot more information available, including the full paper, which was presented at the 30th USENIX Security Symposium in August; it received a Distinguished Paper award from the conference. A YouTube video of the presentation is also available. Beyond that, there are GitHub repositories for the code used in the research and for Geneva.

[Thanks to Paul Wise for giving us a heads-up on this topic.]

Index entries for this article
SecurityInternet/Censorship
SecurityVulnerabilities/Amplification


to post comments

Weaponizing middleboxes

Posted Sep 21, 2021 20:44 UTC (Tue) by rgmoore (✭ supporter ✭, #75) [Link] (1 responses)

Certain types of attacks can actually lead to effectively infinite amplification, however, either because of a routing loop where the time-to-live (TTL) value is not decremented correctly or one where the victim system's default response sustains the attack

One would hope the countries involved would at least be willing to fix this kind of flaw. It doesn't help their censorship mission and costs them bandwidth.

Weaponizing middleboxes

Posted Sep 22, 2021 17:27 UTC (Wed) by ballombe (subscriber, #9523) [Link]

It also allow anyone to start a DDOS war between them...

Weaponizing middleboxes

Posted Sep 21, 2021 21:21 UTC (Tue) by marcH (subscriber, #57642) [Link]

The video is short (12 minutes) and excellent. The simple animations get the point across even for people who are not familiar with networking.

Weaponizing middleboxes

Posted Sep 22, 2021 0:50 UTC (Wed) by bferrell (subscriber, #624) [Link] (9 responses)

Oh goody! CDNs have been weaponized.

sigh

Weaponizing middleboxes

Posted Sep 22, 2021 1:52 UTC (Wed) by ttuttle (subscriber, #51118) [Link] (8 responses)

These aren't CDNs, they're middleboxes. There's a big difference; sites delegate content serving to CDNs and CDNs serve content in consensual, above-board protocol ways, while middleboxes hijack connections and monitor or modify content in nonconsensual, sketchy protocol ways. It sounds like at least some of the attacks target those sketchy protocol behaviors, so they wouldn't apply to legitimate CDNs.

Weaponizing middleboxes

Posted Sep 22, 2021 2:18 UTC (Wed) by pabs (subscriber, #43278) [Link] (7 responses)

CDNs are just consensual middleboxes, I expect some aspects of CDNs are sketchy.

Weaponizing middleboxes

Posted Sep 22, 2021 2:22 UTC (Wed) by ttuttle (subscriber, #51118) [Link] (6 responses)

I would expect their DNS, TCP/IP, and (perhaps a bit less so) SSL stacks to be relatively above-board, and any sketchiness to be at the HTTP and above levels.

Nobody *wants* to do the kind of horrid TCP/UDP/IP hacks that middleboxes do; it's only necessary because they're not formally delegated to handle the connections and answer the requests they want to.

Weaponizing middleboxes

Posted Sep 22, 2021 2:37 UTC (Wed) by pabs (subscriber, #43278) [Link] (5 responses)

As an example, ISTR reading about a CDN that was offering TLS encrypted connections, but either doing plain-text connections to the backend infrastructure or doing TLS connections but not verifying the certificates.

Weaponizing middleboxes

Posted Sep 22, 2021 4:52 UTC (Wed) by ttuttle (subscriber, #51118) [Link]

That's terrible, but that's an application-layer problem -- their policies for the upstream HTTP(ideally-S) connections are wrong. It might be exploitable, but not in the way described here.

Weaponizing middleboxes

Posted Sep 22, 2021 12:07 UTC (Wed) by james (subscriber, #1325) [Link] (3 responses)

As an example, ISTR reading about a CDN that was offering TLS encrypted connections, but either doing plain-text connections to the backend infrastructure or doing TLS connections but not verifying the certificates.
You could well be describing Cloudflare.

They support either:

  • no encryption between Cloudflare and the "real" server;
  • a self-signed certificate on the "real" server;
  • a Cloudflare-signed certificate on the "real" server that is valid for up to 15 years; or
  • a "real" TLS certificate
all while (normally) presenting the end-user with a valid TLS certificate.

The site does get to control which option Cloudflare will use: it's the first thing you'll see under TLS in the Cloudflare configuration site (and you have to go past that to enable user-to-Cloudflare TLS).

Rather more sketchy is their description of this as "end-to-end encryption" when Cloudflare is very obviously decrypting and re-encrypting the traffic.

Weaponizing middleboxes

Posted Sep 25, 2021 11:32 UTC (Sat) by nilsmeyer (guest, #122604) [Link] (2 responses)

> Rather more sketchy is their description of this as "end-to-end encryption" when Cloudflare is very obviously decrypting and re-encrypting the traffic.

I agree, this also seems to evade the privacy policy that all supposedly encrypted (there's a padlock in front of the URL!) data is shared with the CDN provider or whoever provides the load balancer.

Weaponizing middleboxes

Posted Sep 25, 2021 12:57 UTC (Sat) by mbunkus (subscriber, #87248) [Link] (1 responses)

Yeah sure. But that's just how it is. Most of the services offered by CDNs are inherently incompatible with end-to-end encryption (e.g. you cannot cache the content without having access to the content; you likely cannot do effective DDoS protection without inspecting at least parts of the content etc.). If your site gets enough traffic that you cannot handle it on your own with simple setups like haproxy/nginx in front of several backend servers, you have to bite the bullet somehow: either implement your own distributed infrastructure & keep all control or hire someone else & give them access to the unencrypted content in the middle (not in transit). As the former requires a lot of knowledge in all stages (design, implementation, management) it isn't something you can do within a short amount of time, often requiring hiring extra people, too. Using a CDN is the logical step, especially if you're in any way time-constrained.

And to be honest, I really have no quarrels with that kind of a model. I'm much more concerned about the myriad of half-incompetent people not configuring their data storage correctly & having my credit card information in world-readable databases or S3 buckets. 'cause that happens all the time, whereas one of the big CDNs somehow leaking your data… not so much.

Weaponizing middleboxes

Posted Sep 29, 2021 15:31 UTC (Wed) by nilsmeyer (guest, #122604) [Link]

The problem usually isn't even legitimate traffic, it's (D)DoS attacks and the scrubbing requires the CDN to at least have access to some metadata.

Weaponizing middleboxes

Posted Sep 22, 2021 6:49 UTC (Wed) by wujj123456 (guest, #84680) [Link]

> "Most of these nation-states are weak amplifiers (the Great Firewall of China only offers about 1.5x amplification, for example), but some of them offer more damaging amplifications, such as Saudi Arabia (~20x amplification)."

Then from the paper

> The fingerprint returned by the most IP addresses is a sequence of three 54-byte RST+ACKs, which we received from approximately 154 million IPs. This is a well-known censorship pattern produced by the Great Firewall of China (GFW) [6, 42], and using the MaxMind database [21], we find 99.9% of these IPs geolocate to China.

It seems that a relatively simple mitigation that could significantly reduce the potential impact is to do what GFW does...

Weaponizing middleboxes

Posted Sep 22, 2021 16:45 UTC (Wed) by wtarreau (subscriber, #51152) [Link] (4 responses)

Well, I think that an efficient fix might simply be to use one to DoS the other until they're fixed or removed. Sure it's temporarily bad for those having to pass through them but when such devices are deployed at extremely large scale, they cannot resist long against social pressure when the whole 'net is down.

Weaponizing middleboxes

Posted Sep 23, 2021 1:43 UTC (Thu) by NYKevin (subscriber, #129325) [Link]

You are proposing deliberately taking control of somebody else's computers, and causing them to deliberately interfere with a third entity's computers. In other words, you are describing the creation of a botnet. This is generally regarded as unethical, and in most jurisdictions, it is also illegal.

(Sadly, the black hats don't care about ethics and only marginally care about legality, to the extent that they are actually likely to get caught. As a result, I fully expect to see this weaponized in the near future.)

Weaponizing middleboxes

Posted Sep 25, 2021 11:31 UTC (Sat) by nilsmeyer (guest, #122604) [Link] (1 responses)

I'd say just disconnect them from the internet in which they don't really want to participate anyways, as evidenced by their censorship.

Weaponizing middleboxes

Posted Sep 25, 2021 17:32 UTC (Sat) by Wol (subscriber, #4433) [Link]

The problem is that, by disconnecting the middle-boxes from the internet, all the people who DO wamt to be part of the internet but are behind those middleboxes, are collateral damage ...

Cheers,
Wol

Weaponizing middleboxes

Posted Sep 25, 2021 13:02 UTC (Sat) by mbunkus (subscriber, #87248) [Link]

I find this kind of vigilantism to be completely immoral and unacceptable, not to mention most likely illegal in a lot of jurisdictions.


Copyright © 2021, Eklektix, Inc.
This article may be redistributed under the terms of the Creative Commons CC BY-SA 4.0 license
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds