Let us consider having an application which is user specific and non-cached, and contains a profile section (https://www.example.com/my_profile
).
And the attacker lures the victim to open the malicious crafted link (https://www.example.com/my_profile/test.css
), where the file “test.css” does not exist on the web server.
Since it is a non-existent file, the application ignores the “test.css” part of the URL and loads the victim’s profile page. Also, the caching mechanism identifies the resource as a style sheet, and caches it.
Then the attacker sends a GET request to the cached page (https://www.example.com/my_profile/test.css
), and the victim profile page will be returned.
The web cache deception attack works only when all the following conditions are met:
When https://www.example.com/my_profile/test.css
is requested, the content of https://www.example.com/my_profile
should be returned as the response.
The web caching functionality is configured to cache files based on their extensions.
And the victim must be authenticated while accessing the maliciously crafted URL.
Web cache deception is easier to exploit and hence it belongs to the group of the most critical vulnerabilities.
The best part is that there are plenty of ways to implement security in the sensitive content of the website from being cached and from getting revealed to the unauthorized users.
The following are the most opted mitigation methodologies:
The cache server should run based on the cache-control headers set by your application, and only cache the files if their HTTP caching headers allow it.
Cache the files only depending upon their Content-Type header, rather than solely checking the file extensions.
The server should return HTTP-errors such as 302, or 404 based on the non-existent files being requested.