repositories

daemon-sec-cheatsheet

The cheatsheet vault for operators: AD, enumeration, exploitation, priv-esc, web, DFIR

clonegit clone https://git.daemon-sec.xyz/daemon-sec-cheatsheet.git
cache-poisoning-via-url-discrepancies.mdMarkdown64 lines5.7 KiBsource raw download

title: "Cache Poisoning via URL discrepancies" section: "Web Pentesting" sectionSlug: "pentesting-web" sourcePath: "src/pentesting-web/cache-deception/cache-poisoning-via-url-discrepancies.md" sourceUrl: "https://github.com/HackTricks-wiki/hacktricks/blob/188de82beb54e70956b2952367a0af91d26758b8/src/pentesting-web/cache-deception/cache-poisoning-via-url-discrepancies.md" sha: "188de82beb54e70956b2952367a0af91d26758b8" isIndex: false modified: true license: "CC-BY-NC-4.0"#

Cache Poisoning via URL discrepancies#

This is a summary of the techniques proposed in the post https://portswigger.net/research/gotta-cache-em-all in order to perform cache poisoning attacks abusing discrepancies between cache proxies and web servers.[1]

[!TIP] The goal is to make the cache classify a request as cacheable while the origin routes the same URL to a dynamic endpoint. If the cache key preserves a suffix or normalized path that the origin discards, the attacker may store a personalized response, an XSS/redirect response, or a reference to attacker-controlled JavaScript under a reusable key.

Delimiters#

URL delimiters vary by framework and server, impacting how requests are routed and responses are handled.[1] Some common origin delimiters are:

Other specific delimiters might be found following this process:

Normalization & Encodings#

Encodings#

Different HTTP servers and proxies like Nginx, Node, and CloudFront decode delimiters differently, leading to inconsistencies across CDNs and origin servers that could be exploited. For example, if the web server perform this transformation /myAccount%3Fparam → /myAccount?param but the cache server keeps as key the path /myAccount%3Fparam, there is an inconsistency.[1]

A way to check for these inconsistencies is to send requests URL encoding different chars after loading the path without any encoding and check if the encoded path response came from the cached response.[1]

Dot segment#

Dot-segment normalization is another source of discrepancies. For /static/../home/index or /aaa..\home/index, one component may key the literal path while another resolves dot segments or backslashes. Compare a cache-busted baseline with the normalized and non-normalized variants, and use only non-sensitive test accounts because a successful cache-deception probe may publish a response.[1]

Static Resources#

Many caches apply default or configured rules that make apparently static resources cacheable.[1] Common classifiers include:

References#