Introduction
The presentation discusses the Cache Key Injection technique, which allows for the manipulation of cache keys in Nginx servers. The author explains how specifically formatting requests can grant unauthorized access to resources or enable DoS attacks.
Key takeaways 5
The gist of the content in a few sentences
- It involves manipulating parts of the cache key, enabling the bypass of ACL rules and access to protected pages, such as the admin panel.
- By intentionally splitting key fragments, the homepage can be linked to a 404 error response, blocking access to the application.
- Adding an HTTP Authorization header causes requests to bypass the edge cache and be forwarded directly to the origin server.
- Under certain conditions, it is possible to poison the cache by manipulating the Host header, leading to the execution of malicious code.
- Instead of simple separators, each key fragment should be hashed separately before being combined into the final identifier.
Video chapters 13Click and the video will play from the selected moment
- 0:38Cache Basics
- 5:00Differences Between Poisoning and Key Injection
- 6:00Cache Key Injection Mechanism in Nginx
- 6:51Cache Key Injection Mechanism in Nginx
- 9:57Using the Vulnerability for Denial of Service Attacks
- 10:42Cache Poisoning and DoS Attacks
- 12:51Bypassing Cloudflare Protection
- 13:30Bypassing Cache and Response Analysis
- 14:44Requirements for Cache Key Injection and XSS
- 19:10Vulnerability Mechanism in Nginx Configuration
- 19:39Attack Flow and Cache Poisoning
- 20:14Vulnerability Mitigation Methods
- 20:48Detection and Specifics of Cache Key Injection
Summary
First 3 of 13 partsCache Basics
Alex (also known as Broomman) introduces the topic of Cache Key Injection, describing it as "smuggling poison through the door." In his presentation, he plans to cover the detection and exploitation of cache key injection, user-interaction-free web cache deception, cache poisoning, as well as cache store access issues and denial of service attacks. To illustrate the potential impact of these vulnerabilities, the speaker demonstrates gaining access to the admin page via an AD request.
The cache mechanism can be visualized as a system where a user communicates with a server, such as Nginx, which in turn mediates contact with a backend application written in any language, such as Python or JavaScript. When a user requests the homepage, Nginx forwards the request to the backend and stores the received response in the cache, assigning it a unique key. Consequently, the next user requesting the same page will receive the same response directly from Nginx, without the need to query the backend application again.
The cache key serves as an identifier that allows the server to link a specific response to a specific request. In the provided example, the key consists of the HTTP protocol, the example.com domain, and the /home endpoint. In modern security environments, this infrastructure may be further supplemented by an edge layer, although for the sake of simplicity, the speaker focuses on a setup with Nginx on the backend.
Cache Key Injection Mechanism in Nginx
In the standard request handling process of an Nginx server, a request for the homepage generates a specific key (Key A), which is linked to a specific response (Response A) and returned directly from the cache. The main goal of the presentation is to analyze the phenomenon of Cache Key Injection, which allows for retrieving response data that the user did not actually request.
This vulnerability often stems from the proxy_cache_key variable configuration, where values such as the host, request URI, or specific cookies (e.g., user) are combined into a single string. The speaker notes that many developers add specific headers or cookies to the cache key to separate language versions or authorization, making the addition of headers to the key a common practice in public repositories.
Differences Between Poisoning and Key Injection
The speaker distinguishes between two approaches to cache manipulation. While classic cache poisoning involves modifying non-keyed values stored in the response, key injection directly targets fragments of the key itself.
An example of such an attack is user-interaction-free web cache deception. In the analyzed case, Nginx combines the scheme, host, and URI into one string, adding the HTTP accept header at the end. If the /admin resource is protected by ACL and accessible only via localhost, a direct request will be blocked. The attack therefore consists of formulating the request in such a way as to bypass ACL rules without sending the request in a manner that would be directly identified as an attempt to access /admin.
Read the full summary – for free
10 parts of text left, key takeaways, facts, questions and answers, action items – with the source minute for every passage. Plus search, collections and the AI assistant.
Keep reading for freeFree, in a minute. Have an account? Log in
