#@ck3r
  • Welcome
  • Administrator
    • ActiveDirectory
      • Methodology
    • LDAP
    • Kerberos
  • HTB_CTF
    • It's Oops PM
  • πŸ•ΈοΈ Pentesting Web
    • Web Vulnerabilities Methodology
      • Reflecting Techniques - PoCs and Polygloths CheatSheet
        • Web Vulns List
    • 2FA/MFA/OTP Bypass
    • Account Takeover
    • Browser Extension Pentesting Methodology
      • BrowExt - ClickJacking
      • BrowExt - permissions & host_permissions
      • BrowExt - XSS Example
    • Bypass Payment Process
    • Captcha Bypass
    • Cache Poisoning and Cache Deception
      • Cache Poisoning via URL discrepancies
      • Cache Poisoning to DoS
    • Clickjacking
    • Client Side Template Injection (CSTI)
    • Client Side Path Traversal
    • Command Injection
    • Content Security Policy (CSP) Bypass
    • Cookies Hacking
      • Cookie Tossing
    • CORS - Misconfigurations & Bypass
    • CRLF (%0D%0A) Injection
    • CSRF (Cross Site Request Forgery)
  • Dangling Markup - HTML scriptless injection
  • Dependency Confusion
  • Deserialization
    • NodeJS - __proto__ & prototype Pollution
      • Client Side Prototype Pollution
      • Express Prototype Pollution Gadgets
      • Prototype Pollution to RCE
    • CommonsCollection1 Payload - Java Transformers to Rutime exec() and Thread Sleep
    • Java DNS Deserialization, GadgetProbe and Java Deserialization Scanner
    • Basic .Net deserialization (ObjectDataProvider gadget, ExpandedWrapper, and Json.Net)
    • Exploiting __VIEWSTATE without knowing the secrets
    • Python Yaml Deserialization
    • JNDI - Java Naming and Directory Interface & Log4Shell
    • Ruby Class Pollution
  • Page 1
Powered by GitBook
On this page
  • Delimiters
  • Normalization & Encodings
  • Static Resources
  1. πŸ•ΈοΈ Pentesting Web
  2. Cache Poisoning and Cache Deception

Cache Poisoning via URL discrepancies

PreviousCache Poisoning and Cache DeceptionNextCache Poisoning to DoS

Last updated 3 months ago

This is a summary of the techniques proposed in the post in order to perform cache poisoning attacks abusing discrepancies between cache proxies and web servers.

The goal of this attack is to make the cache server think that a static resource is being loaded so it caches it while the cache server stores as cache key part of the path but the web server responds resolving another path. The web server will resolve the real path which will be loading a dynamic page (which might store sensitive information about the user, a malicious payload like XSS or redirecting to lo load a JS file from the attackers website for example).

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

  • Semicolon: Used in Spring for matrix variables (e.g. /hello;var=a/world;var1=b;var2=c β†’ /hello/world).

  • Dot: Specifies response format in Ruby on Rails (e.g. /MyAccount.css β†’ /MyAccount)

  • Null Byte: Truncates paths in OpenLiteSpeed (e.g. /MyAccount%00aaa β†’ /MyAccount).

  • Newline Byte: Separates URL components in Nginx (e.g. /users/MyAccount%0aaaa β†’ /account/MyAccount).

Other specific delimiters might be found following this process:

  • Step 1: Identify non-cacheable requests and use them to monitor how URLs with potential delimiters are handled.

  • Step 2: Append random suffixes to paths and compare the server's response to determine if a character functions as a delimiter.

  • Step 3: Introduce potential delimiters before the random suffix to see if the response changes, indicating delimiter usage.

  • Purpose: URL parsers in both cache and origin servers normalize URLs to extract paths for endpoint mapping and cache keys.

  • Process: Identifies path delimiters, extracts and normalizes the path by decoding characters and removing dot-segments.

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.

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.

The path normalization where dots are involved is also very interesting for cache poisoning attacks. For example, /static/../home/index or /aaa..\home/index, some cache servers will cache these paths with themselves ad the keys while other might resolve the path and use /home/index as the cache key. Just like before, sending these kind of requests and checking if the response was gathered from the cache helps to identify if the response to /home/index is the response sent when those paths are requested.

Several cache servers will always cache a response if it's identified as static. This might be because:

  • The extension: Cloudflare will always cache files with the following extensions: 7z, csv, gif, midi, png, tif, zip, avi, doc, gz, mkv, ppt, tiff, zst, avif, docx, ico, mp3, pptx, ttf, apk, dmg, iso, mp4, ps, webm, bin, ejs, jar, ogg, rar, webp, bmp, eot, jpg, otf, svg, woff, bz2, eps, jpeg, pdf, svgz, woff2, class, exe, js, pict, swf, xls, css, flac, mid, pls, tar, xlsx

    • It's possible to force a cache storing a dynamic response by using a delimiter and a static extension like a request to /home$image.png will cache /home$image.png and the origin server will respond with /home

  • Well-known static directories: The following directories contains static files and therefore their response should be cached: /static, /assets, /wp-content, /media, /templates, /public, /shared

    • It's possible to force a cache storing a dynamic response by using a delimiter, a static directory and dots like: /home/..%2fstatic/something will cache /static/something and the response will be/home

    • Static dirs + dots: A request to /static/..%2Fhome or to /static/..%5Chome might be cached as is but the response might be /home

  • Static files: Some specific files are always cached like /robots.txt, /favicon.ico, and /index.html. Which can be abused like /home/..%2Frobots.txt where the cace might store /robots.txt and the origin server respond to /home.

https://portswigger.net/research/gotta-cache-em-all
Delimiters
Normalization & Encodings
Encodings
Dot segment
Static Resources