Description: The HTTP response Content-Encoding header allows for chained compression algorithms. A server can exploit this by providing a response with a large number of compression links in the chain (e.g., gzip, br), leading to excessive resource consumption (CPU and memory) on the client attempting to decompress the content. This vulnerability can cause denial of service or performance degradation.
How to Test:
- Set up a server that serves a small amount of raw data (e.g., 50000 bytes) compressed with a specified encoding algorithm (e.g., Brotli) multiple times (e.g., 5000 layers). The server should expose the compressed content via HTTP.
- Configure a client to request the resource from the server and automatically decompress the response content.
- Monitor the client's resource usage (CPU, memory) during the decompression process. Increase the number of compression layers and the size of the raw data to exacerbate the issue.
- Example Payload (Content-Encoding header):
Content-Encoding: br, br, br, br, br, br, br, br, br, br(and so on, up to a large number of repetitions)
Impact: Denial of service, excessive CPU usage, memory exhaustion, and performance degradation on the client. Potentially, resource exhaustion can lead to system instability or crashes.
Remediation: Implement a limit on the maximum number of content-encoding layers allowed in an HTTP response. Validate and restrict the number of compression algorithms used in the Content-Encoding header, adhering to a reasonable maximum value (e.g., 5). Implement throttling or resource limits on decompression processes to prevent excessive consumption.