Zafran’s research team discovered a pervasive misconfiguration bug in the implementation of popular web application firewall (WAF) services by Akamai, Cloudflare, Fastly, Imperva and others. The impacted WAF vendors are responsible for 90% of protected web applications worldwide.
The misconfiguration can allow threat actors to bypass WAF protections and directly target web applications and load balancers over the Internet. By doing so, attackers may perform distributed denial-of-service (DDoS) attacks on exposed web applications, or alternatively exploit vulnerabilities in the apps themselves that would have otherwise been identified or blocked by the WAF. The misconfiguration stems from an architectural weakness of WAF providers that also act as CDN (content delivery network) providers. In the architecture of such CDN/WAF services, protected web applications are instructed to validate Internet traffic routed to them originated by the CDN/WAF provider. Failure to do so may lead to the discovered bypass.
To assess the pervasiveness of this type of misconfiguration, this research focused on assessing a large sample of domains – the domains of Fortune 1000 companies.
We first identified 700K domains that we were able to map to ~700 of the Fortune 1000 companies. Through a combination of Internet-wide scans and novel fingerprinting techniques, we identified more than 140K domains that were protected by a CDN/WAF provider. From these, we were able to map 8K domains to 36K backend servers which are directly accessible over the Internet and consequently exposed to DDoS attacks. These findings prove the pervasiveness of the misconfiguration, as the impacted domains are distributed across high percentages of the Fortune 1000 companies (our original sample set). The impacted domains are owned by nearly 40% of Fortune 100 companies, and 20% of Fortune 1000.
This blog offers a technical deep dive on how the research to obtain these stats was conducted. For a higher-level overview on the impact and mitigation recommendations of this bypass technique, please refer to Breaking WAF overview blog.
Unlike traditional load balancers and web application firewalls (WAFs) that are deployed as physical or virtual applications on customer’s premises, CDNs are designed as a large network of Internet servers that handle web traffic close to the edge (to the end user), and ultimately route traffic to a web application over the Internet. A majority of web applications today do not expose their front end servers directly to the Internet, and will generally use a CDN service in front of their own servers.
There are a number of companies offering CDN services, the most popular ones being Akamai, Cloudflare, Fastly and Imperva. The main functionality of a CDN is to maintain data centers in diverse geographic locations in order to provide lower latency and higher download speeds for the static content of customer web applications.
However, while the primary service of these companies is CDN, they also offer protective features, which a customer can choose to activate (or not). These are usually:
A CDN is typically configured for a domain or subdomain as follows:
The communication between the reverse proxy and the origin servers needs to be TLS encrypted as well. However, the type of certificate to be used is the customer’s choice, as – CDN providers support multiple options.
More importantly, if the IP/port of the origin server has leaked, an attacker could now target the origin server directly, bypassing the CDN protections entirely.
To mitigate this issue, beyond keeping the origin server IP address secret, CDN providers recommend a best practice, usually including the following steps:
While the above mitigations are generally good solutions, prior research has shown that in certain cases these methods can be bypassed as well. For example, it has been demonstrated that by creating an attacker-controlled Cloudflare account that is configured to talk to the same origin server as the victim, an attacker can masquerade as ‘Cloudflare’ – utilize Cloudflare IPs and Cloudflare certificates while reaching out to the victim’s origin server. At the same time the attacker can control the DoS and WAF protection settings on the malicious account and simply turn them off. Using a custom HTTP header with a pre-shared secret circumvents this sophisticated bypass.
In any point, it is important to stress that the additional mitigations that prevent an attacker from talking to an Origin Server directly, depend on configuration changes that customers are required to implement on each of their Origin Servers. Unsurprisingly, our scans have shown that these measures are rarely implemented, as we’ll show below.
Therefore, this leaves the secrecy of the Origin Server IP/port as the primary (and potentially only) line of defense against this kind of bypass.
An interesting tidbit is the Cloudflare option of using a Cloudflare issued Origin Server Certificate for the origin server TLS connections.
Evidently, Censys finds more than 200K hosts on the Internet responding with this certificate. Meaning, each of these is an exposed Origin Server that an attacker can discover and is able to talk to directly, unless the mTLS mitigation is used.
Out of a random sampling of 1000 of such origin servers, which were open to port 443, a total of 780 provided a successful response status code. Only 130 answered with a 400, 403 or a TLS handshake error which would be expected due to a mTLS failure. Therefore it seems that only about 13% of these origin servers implement Authenticated Origin Pulls, even though this figure is probably an overestimation (there could be other reasons for these HTTP error codes).
As explained above, in order to assess the pervasiveness of the CDN/WAF bypass described above, this research focused on assessing a large sample of domains – the domains of Fortune 1000 companies. The first task at hand was to gather the list of all the domains owned by Fortune 1000 companies.
Attackers and security researchers have a number of ways to discover domains belonging to a target organization, as part of normal recon steps that can be taken at the start of an evaluation. One of the best and easiest ways to do this, is to use Certificate Transparency logs.
Companies such as Censys provide access to CT logs, but so does https://crt.sh which is a free (yet slow) service. A CT log is generated whenever a browser-trusted CA issues a certificate these days. They were designed as a way to enable domain owners to notice rogue certificates being issued in their name. However, services such as crt.sh listen to those CT logs, and then store them forever. This enables you to discover domains for organizations such as IBM, since the string “IBM” appears in the Subject field of their issued certificates:
Additionally, one can then take domains returned by querying crt.sh for domains that contain certain companies’ domains (such as “IBM”), gather the unique second level domains that belong to the organization, and then recursively query additional subdomains, in the second level domain. This discovers additional domains, since TLS certificates can have multiple Subject Alternative Names in each certificate. SANs are a list of additional domains a certificate is valid for. This can now be used to link domains to other domains, as it’s unlikely that a single certificate will have Subject Alternate Names that belong to different organizations. Almost always, it will be a single organization that owns all of the domains in a single certificate.
As we’d like to discover all CDN-related domains that belong to Fortune 1000 companies, with a huge list of domains in hand we now need to check each of them and classify whether the domain points to a CDN server, and to which one.
We identified a few techniques to identify and classify domains that point to CDN servers:
The 3rd bullet above resulted in the most effective fingerprinting technique, and the fingerprint technique is detailed in the next section.
The fingerprinting techniques above resulted in a list of about 700K domains that resolve successfully, of which 140k are CDN-related. For each of those, the identifier of the CDN provider was noted and classified.
It should be noted that the initial acquisition of domain names from the CT logs, does include a significant amount of “garbage domains” as well. By “garbage”, we refer to domains that do not actually belong to the organization they were discovered for. However, following this discovery stage, there are multiple verification steps for the domains that disproportionately filter out these “garbage” domains.
As detailed above, the most effective technique we found to fingerprint a CDN server is to observe a suspected server’s response to an HTTP request. Let’s first observe the domain resolution of a CDN-related domain (images.jpmorganchase.com, protected by Akamai):
When a request is sent to a CDN-related domain, it is usually a rather transparent thing to the user. The request gets processed at the edge (at the CDN server), or is proxied to the Origin Server at the back end (in case of an API request, for example). As such, it would be somewhat hard to identify if an A record points to a CDN proxy or not. However, when it comes to Akamai or Cloudflare, the same proxy servers are used for many different domains. To demonstrate:
How does the Akamai proxy server know what is the hostname/domain of the request if both arrive at the same server?
As such, a CDN proxy server will appear to behave in a peculiar way if a request is sent to it without an SNI or Host header, and this can be identified:
While regular (non-proxy) servers may also depend on TLS SNI to know which certificate to serve, the plain HTTP request to the same IP is a dead giveaway. By making such a request to the A record IP of cloud.oracle.com, for example, we can tell for certain that it uses Akamai.
Having a list of CDN-related domains in hand, we now need to actually find the directly exposed Origin Servers that serve the same domains.
As described in the previous section, the TLS-SNI header is used by CDN servers to route requests based on the Server Name in the header. However, a typical front end server, or even a load balancer (LB), belongs to a single app or organization, and does not typically need to handle the SNI header. The easy and reasonable way to configure TLS certificates on such a server, is to either:
In both of these common cases, sending a HTTPS request directly to the IP of a front end server, without any SNI, will present us with a default server certificate. This certificate will reveal what domains are being served by this server.
We chose the naive approach of scanning only for TLS certificates on port 443, as scanning non-standard ports might have been time consuming. This means the results below are actually representing only a subset of the full scope of the WAF bypass, since many origin servers might be bound to on a non-standard port.
The scan is simply a classic one where all Internet IPv4 addresses are sampled for port 443 being open. This resulted in about 45M servers, which is close to the Censys estimate.
Following this, zgrab2 was used to obtain the TLS certificates served by all of these servers:
After processing the obtained TLS certificates, it is possible to reduce them to about 45M entries such as the one shown below:
At this point we can match the 140K CDN-related domains to these newly obtained 45M Internet servers. The matching is done by comparing the domain names while also respecting wildcards that can appear in the SANs.
This initial mapping resulted in 36K matched servers, across 8.1k unique Fortune 1000 related domains! Each of these 36K matches is potentially a directly accessible Origin Server that belongs to a Fortune 1000 company. These numbers are quite significant, yet they do include false positives. Additional verification and filtering steps need to be performed, such as:
At this point, the final step of verification is left. For each domain/origin server pair, we need to compare the HTTP response from the CDN server, to the response from the newly found Origin Server for the same domain. This ensures that the same web-app is being served from both locations, making it highly likely that we found a bypass.
In the above example, a bypass finding is displayed. Both requests to the CDN and to the newly discovered origin server return what appears to be the same webpage. The domain agreements.apple.com resolves to an Akamai CDN proxy server (ASN is “AKAMAI-AS”), and the server at 17.32.214.239 belongs to the ASN “APPLE-ENGINEERING”, and returns an “Apple” server header
The above method was automated via a verification script that performs the following steps:
After mapping, verifying and cleaning the data, we were able to find interesting results about the vulnerability of Fortune 1000 companies to the WAF bypass misconfiguration.
Out of Fortune 1000, we have mapped domains of 670 companies. For these companies 2367 exposed Origin Servers were identified. Among them, 2028 domains belonging to 135 different Fortune 1000 companies are assessed with high confidence to have at least one impacted domain/server.
It is worth noting that the WAF bypass bug seems to be especially a concern for very large companies placed at the top of the Fortune 1000 list. For example, the first 100 companies of the list represent 35% of the potentially impacted ones. Likewise, companies with over $50 billion annual revenue are over-represented among the affected organizations.
Looking at impacted companies by industry, Financial Services were the most prevalent, representing over a third of all impacted companies.
Furthermore, our findings show that Akamai CDNs might be slightly more impacted than its competitors, such as Cloudflare and other: while Akamai represents only 42% of the CDN-related domains operated by Fortune 1000 companies (at least the 140K domains we have been able to identify and map), it shares 59% of the companies impacted by the WAF bypass misconfiguration. This does not mean that Akamai is inherently more vulnerable than other CDNs - just that companies using Akamai relatively tend to “forget” mitigating this risk.
Below is a list of some notable domains that were found to be affected by the ‘Breaking WAF’ bypass:
While the results above appear significant, many potential cases of exposed origin servers were not included in this analysis:
Even after the automatic verification that resulted in our list of 2.3k exposed servers, it’s still likely some of these are false positives. In our manual analysis, we observed some of the following cases:
While we don’t know the extent of the potential false-positive cases above, it is unlikely that they outweigh the more significant number of false-negative cases.
To assess the potential impact of the bypass technique detailed above, let’s consider which denial-of-service protections are offered by popular CDN providers:
From the documentation of various CDN providers we can learn what are the advantages that their offering can provide to customers:
Basically, a large CDN provider has extensive visibility on large amounts of traffic on the web. In addition, they have the ability to take immediate action in the form of new rules that can be applied within their edge network. This allows them to mitigate even the largest DDoS attacks, if not immediately, then in relatively short order.
If one chooses not to use dedicated DDoS protection for one's servers, what could they expect from their standard issue Linux/nginx server in terms of attack resilience? There are a few features that are designed for this purpose:
Notably, for a default configuration Linux/nginx server that does not expect a DoS attack to hit it, there is very little to no protection. Origin Servers that expect to be protected by the CDN, are not likely to run fail2ban or implement any custom measures. Therefore, they are bound to be quite vulnerable to DoS if targeted directly.
Some common configurations on typical Linux servers can even be harmful for DoS resilience. To illustrate this and the above points, consider the following example of a typical iptables configuration:
The problem here lies with the conntrack rule that allows established connections through the firewall. First of all, this line is not needed for this configuration. Since the OUTPUT policy is ACCEPT, it has no effect, as no outgoing traffic will be blocked anyway. Second, conntrack has limitations in the kernel, specifically:
The number of tracked connections may be limited to a very low value by default! In this extreme example, 15k of connections can be opened by a single IP DoS node. Once this number of tracked connections is reached, the kernel will start dropping legitimate connections, resulting in a hard DoS.
Having a list of verified, directly addressable Origin Servers and their corresponding CDN-related domains. To validate our results dynamically, we decided to carefully DoS some affected servers for a brief interval, while measuring the impact on the CDN-related domain through the CDN. If an impact is measurable through the CDN while DoS’ing the Origin Server, the bypass is 100% confirmed.
Our chosen DoS method is a simple CPU/connection pool exhaustion attempt by way of establishing a massive amount of TLS connections from a single IP to the target server using zgrab2. While the DoS TLS connections were made directly to the origin server IP, the measurement connections were made to the real CDN-related domain, through the CDN, just as a normal user would connect.
Importantly, the test endpoint chosen on each server was something like “/dummy1234”, with the number being random and unique to every request. This makes sure that the CDN has to forward the request to the origin server every time. A 404 response should be affected the same as 200 with regards to RTT.
These results above are quite evident. The timeout for the RTT measurement was set to 1 second. Therefore the last 3 instances are more likely to be caused by a connection pool exhaustion of some kind, such as the conntrack issue discussed above.
The above tests are the ‘worst-case scenario’ of the discovered bypass, as the targeted servers are single IPs that handle all traffic of a certain web application. Despite this, it is quite common for web-applications to be protected by handful servers, so an attacker would only need to expand an attack in a linear fashion. A well-organized attacker can also create a botnet, harvesting the bandwidth, the geo-location, and the CPUs of tens of thousands of machines, to carry out simple but much more powerful DDoS attacks even against the largest web-applications setups available – where a CDN is bypassed.
Finally, we performed a similar DoS test on an BHHC domain, and demonstrated how a user accessing the domain would experience such an attack:
This research uncovered the wide spread of misconfigured security tools, that are considered the best type of protection for web-applications - CDN based WAFs.
While this research included some novel techniques for identifying Origin Servers, and mapping them to CDN-protected domains, the weakness of CDN-based WAFs is actually well known in the industry for almost 10 years. An article by Imperva from 2015 (!!!) details methods of protecting Imperva customers from this type of bypass.
Nevertheless, it seems the architectural weakness of CDN/WAFs have created a long-lasting misconfiguration issue that doesn’t seem to be going away anytime soon.
Misconfigurations of security tools can have an extremely serious effect, as enterprises walk around with a false sense of security, while gapping holes might be lurking in their ‘defense-in-depth’ strategy. Further analysis of similar systemic issues are required to strengthen the walls.