{"id":1390,"date":"2024-08-16T00:43:01","date_gmt":"2024-08-16T00:43:01","guid":{"rendered":"https:\/\/hacking.cool\/?p=1390"},"modified":"2024-09-11T03:32:02","modified_gmt":"2024-09-11T03:32:02","slug":"web-cache-poisoning-via-host-header","status":"publish","type":"post","link":"https:\/\/hacking.cool\/atomanya\/web-cache-poisoning-via-host-header\/","title":{"rendered":"Web Cache Poisoning via Host Header"},"content":{"rendered":"<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"768\" src=\"http:\/\/hacking.cool\/wp-content\/uploads\/2024\/08\/poisoning8-1024x768.png\" alt=\"\" class=\"wp-image-1428\" srcset=\"https:\/\/hacking.cool\/atomanya\/wp-content\/uploads\/2024\/08\/poisoning8-1024x768.png 1024w, https:\/\/hacking.cool\/atomanya\/wp-content\/uploads\/2024\/08\/poisoning8-300x225.png 300w, https:\/\/hacking.cool\/atomanya\/wp-content\/uploads\/2024\/08\/poisoning8-768x576.png 768w, https:\/\/hacking.cool\/atomanya\/wp-content\/uploads\/2024\/08\/poisoning8.png 1366w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure><\/div>\n\n\n<p>Web Cache Poisoning might sound like something straight out of a security conference talk, but it&#8217;s a real threat that can cause serious headaches. Recently, a vulnerability was found on the Shopify theme store website, <code>https:\/\/themes.shopify.com<\/code>, where an attacker could poison the cache by manipulating the <strong>Host header<\/strong>.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">What Is Web Cache Poisoning?<\/h4>\n\n\n\n<p>Let\u2019s break it down:<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong>Web Caching<\/strong>: Websites use caching to store copies of web pages or resources, so they can be delivered quickly to users without regenerating them each time.<\/li>\n\n\n\n<li><strong>The Problem<\/strong>: If an attacker can trick the cache into storing a manipulated version of a page, users might end up seeing this tampered content instead of what they were supposed to get.<\/li>\n\n\n\n<li><strong>Host Header Exploit<\/strong>: The Host header in an HTTP request tells the server which domain it should respond to. By altering this header, the attacker can force the server to cache a version of the website that includes a fake port number, leading to a dysfunctional site experience.<\/li>\n<\/ol>\n\n\n\n<h4 class=\"wp-block-heading\">How the Attack Works<\/h4>\n\n\n\n<p>Here\u2019s how the attack was executed:<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">The Attack: Step-by-Step Breakdown<\/h3>\n\n\n\n<p>In this attack, the attacker used a terminal to send repeated requests to <code>https:\/\/themes.shopify.com<\/code> by running the following command:<\/p>\n\n\n\n<p><code>while true; do curl -ik \"https:\/\/themes.shopify.com:443\/?g4mm4=hitthecache\" -H \"Host: themes.shopify.com:1337\" | grep \":1337\"; sleep 0; echo 1; done<\/code><\/p>\n\n\n\n<p>This command repeatedly requests the page with an invalid Host header (in this case, using port 1337) and checks if the response includes this poisoned Host header.<\/p>\n\n\n\n<p>If the server and caching system do not properly validate the Host header, they might store this incorrect version in the cache. This means that when other users request the page, they could be served the corrupted version instead of the proper one.<\/p>\n\n\n\n<p>To verify if the cache had been poisoned, the attacker would run the following command in another terminal:<\/p>\n\n\n\n<p><code>while true; do curl -ik \"https:\/\/themes.shopify.com:443\/\" | grep \":1337\"; done<\/code><\/p>\n\n\n\n<p>This command checks if the corrupted Host header (using port 1337) is being served to users.<\/p>\n\n\n\n<p>As a result, users visiting <code>https:\/\/themes.shopify.com<\/code> might now see broken images, missing styles, or incorrect links because the website is being served with a port that doesn&#8217;t actually exist (e.g., themes.shopify.com:1337). This can cause the site to fail to load resources correctly, leading to a degraded user experience.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">The Technical Implications<\/h3>\n\n\n\n<p>This attack exploits a misconfiguration in how the web server and caching system handle HTTP headers. If the server does not properly validate or sanitize the Host header, it can lead to the entire cache being poisoned. The result is that every user who accesses the site during the period of poisoning receives a broken or manipulated version of the website.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Defense Against Web Cache Poisoning<\/h3>\n\n\n\n<p>To protect against this kind of attack, it is essential to:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Validate Host Headers: Ensure that the server only accepts valid Host headers corresponding to the domain name.<\/li>\n\n\n\n<li>Sanitize Inputs: Carefully check and sanitize all inputs, including HTTP headers, to prevent malicious data from being processed.<\/li>\n\n\n\n<li>Configure Cache Properly: Ensure the caching mechanism is correctly configured to prevent it from storing poisoned or invalid data.<\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\">Conclusion<\/h3>\n\n\n\n<p>Web Cache Poisoning via the Host header is a serious issue because it can degrade the user experience and disrupt the normal operation of a website. For site administrators and developers, it highlights the importance of securing caching mechanisms to prevent such vulnerabilities.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Author of the Finding<\/h3>\n\n\n\n<p>This is an article I wrote about the following bug bounty &#8211; https:\/\/hackerone.com\/reports\/1096609 &#8211; reported by <strong>g4mm4<\/strong> (<a href=\"https:\/\/hackerone.com\/g4mm4?type=user\">https:\/\/hackerone.com\/g4mm4?type=user<\/a>). Bounty: $2,900.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Web Cache Poisoning might sound like something straight out of a security conference talk, but it&#8217;s a real threat that can cause serious headaches. Recently, a vulnerability was found on the Shopify theme store website, https:\/\/themes.shopify.com, where an attacker could poison the cache by manipulating the Host header. What Is Web Cache Poisoning? Let\u2019s break<span class=\"post-excerpt-end\">&hellip;<\/span><\/p>\n<p class=\"more-link\"><a href=\"https:\/\/hacking.cool\/atomanya\/web-cache-poisoning-via-host-header\/\" class=\"themebutton\">Read More<\/a><\/p>\n","protected":false},"author":3,"featured_media":1428,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_mi_skip_tracking":false,"footnotes":""},"categories":[1],"tags":[],"class_list":["post-1390","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-uncategorized"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v19.3 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Web Cache Poisoning via Host Header - hacking.cool<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/hacking.cool\/atomanya\/web-cache-poisoning-via-host-header\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Web Cache Poisoning via Host Header - hacking.cool\" \/>\n<meta property=\"og:description\" content=\"Web Cache Poisoning might sound like something straight out of a security conference talk, but it&#8217;s a real threat that can cause serious headaches. Recently, a vulnerability was found on the Shopify theme store website, https:\/\/themes.shopify.com, where an attacker could poison the cache by manipulating the Host header. What Is Web Cache Poisoning? Let\u2019s break&hellip;Read More\" \/>\n<meta property=\"og:url\" content=\"https:\/\/hacking.cool\/atomanya\/web-cache-poisoning-via-host-header\/\" \/>\n<meta property=\"og:site_name\" content=\"hacking.cool\" \/>\n<meta property=\"article:published_time\" content=\"2024-08-16T00:43:01+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2024-09-11T03:32:02+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/hacking.cool\/atomanya\/wp-content\/uploads\/2024\/08\/poisoning8.png\" \/>\n\t<meta property=\"og:image:width\" content=\"1366\" \/>\n\t<meta property=\"og:image:height\" content=\"1024\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"author\" content=\"Atom\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Atom\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"3 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebSite\",\"@id\":\"https:\/\/hacking.cool\/atomanya\/#website\",\"url\":\"https:\/\/hacking.cool\/atomanya\/\",\"name\":\"hacking.cool\",\"description\":\"is the hacking school \ud83d\udc69\ud83c\udffb\u200d\ud83d\udcbb\ud83e\uddd1\ud83c\udffb\u200d\ud83d\udcbb\ud83d\uddfa\ud83d\udcda\ud83d\udcd6\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/hacking.cool\/atomanya\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"en-US\"},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/hacking.cool\/atomanya\/web-cache-poisoning-via-host-header\/#primaryimage\",\"url\":\"https:\/\/hacking.cool\/atomanya\/wp-content\/uploads\/2024\/08\/poisoning8.png\",\"contentUrl\":\"https:\/\/hacking.cool\/atomanya\/wp-content\/uploads\/2024\/08\/poisoning8.png\",\"width\":1366,\"height\":1024},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/hacking.cool\/atomanya\/web-cache-poisoning-via-host-header\/\",\"url\":\"https:\/\/hacking.cool\/atomanya\/web-cache-poisoning-via-host-header\/\",\"name\":\"Web Cache Poisoning via Host Header - hacking.cool\",\"isPartOf\":{\"@id\":\"https:\/\/hacking.cool\/atomanya\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/hacking.cool\/atomanya\/web-cache-poisoning-via-host-header\/#primaryimage\"},\"datePublished\":\"2024-08-16T00:43:01+00:00\",\"dateModified\":\"2024-09-11T03:32:02+00:00\",\"author\":{\"@id\":\"https:\/\/hacking.cool\/atomanya\/#\/schema\/person\/804a839cfa61d89d69fb2cf1d2f0adc2\"},\"breadcrumb\":{\"@id\":\"https:\/\/hacking.cool\/atomanya\/web-cache-poisoning-via-host-header\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/hacking.cool\/atomanya\/web-cache-poisoning-via-host-header\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/hacking.cool\/atomanya\/web-cache-poisoning-via-host-header\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/hacking.cool\/atomanya\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Web Cache Poisoning via Host Header\"}]},{\"@type\":\"Person\",\"@id\":\"https:\/\/hacking.cool\/atomanya\/#\/schema\/person\/804a839cfa61d89d69fb2cf1d2f0adc2\",\"name\":\"Atom\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/hacking.cool\/atomanya\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/ac4d05ec7d617e7f2dee5855900a855a?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/ac4d05ec7d617e7f2dee5855900a855a?s=96&d=mm&r=g\",\"caption\":\"Atom\"},\"url\":\"https:\/\/hacking.cool\/atomanya\/author\/atom\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Web Cache Poisoning via Host Header - hacking.cool","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/hacking.cool\/atomanya\/web-cache-poisoning-via-host-header\/","og_locale":"en_US","og_type":"article","og_title":"Web Cache Poisoning via Host Header - hacking.cool","og_description":"Web Cache Poisoning might sound like something straight out of a security conference talk, but it&#8217;s a real threat that can cause serious headaches. Recently, a vulnerability was found on the Shopify theme store website, https:\/\/themes.shopify.com, where an attacker could poison the cache by manipulating the Host header. What Is Web Cache Poisoning? Let\u2019s break&hellip;Read More","og_url":"https:\/\/hacking.cool\/atomanya\/web-cache-poisoning-via-host-header\/","og_site_name":"hacking.cool","article_published_time":"2024-08-16T00:43:01+00:00","article_modified_time":"2024-09-11T03:32:02+00:00","og_image":[{"width":1366,"height":1024,"url":"https:\/\/hacking.cool\/atomanya\/wp-content\/uploads\/2024\/08\/poisoning8.png","type":"image\/png"}],"author":"Atom","twitter_card":"summary_large_image","twitter_misc":{"Written by":"Atom","Est. reading time":"3 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebSite","@id":"https:\/\/hacking.cool\/atomanya\/#website","url":"https:\/\/hacking.cool\/atomanya\/","name":"hacking.cool","description":"is the hacking school \ud83d\udc69\ud83c\udffb\u200d\ud83d\udcbb\ud83e\uddd1\ud83c\udffb\u200d\ud83d\udcbb\ud83d\uddfa\ud83d\udcda\ud83d\udcd6","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/hacking.cool\/atomanya\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"en-US"},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/hacking.cool\/atomanya\/web-cache-poisoning-via-host-header\/#primaryimage","url":"https:\/\/hacking.cool\/atomanya\/wp-content\/uploads\/2024\/08\/poisoning8.png","contentUrl":"https:\/\/hacking.cool\/atomanya\/wp-content\/uploads\/2024\/08\/poisoning8.png","width":1366,"height":1024},{"@type":"WebPage","@id":"https:\/\/hacking.cool\/atomanya\/web-cache-poisoning-via-host-header\/","url":"https:\/\/hacking.cool\/atomanya\/web-cache-poisoning-via-host-header\/","name":"Web Cache Poisoning via Host Header - hacking.cool","isPartOf":{"@id":"https:\/\/hacking.cool\/atomanya\/#website"},"primaryImageOfPage":{"@id":"https:\/\/hacking.cool\/atomanya\/web-cache-poisoning-via-host-header\/#primaryimage"},"datePublished":"2024-08-16T00:43:01+00:00","dateModified":"2024-09-11T03:32:02+00:00","author":{"@id":"https:\/\/hacking.cool\/atomanya\/#\/schema\/person\/804a839cfa61d89d69fb2cf1d2f0adc2"},"breadcrumb":{"@id":"https:\/\/hacking.cool\/atomanya\/web-cache-poisoning-via-host-header\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/hacking.cool\/atomanya\/web-cache-poisoning-via-host-header\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/hacking.cool\/atomanya\/web-cache-poisoning-via-host-header\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/hacking.cool\/atomanya\/"},{"@type":"ListItem","position":2,"name":"Web Cache Poisoning via Host Header"}]},{"@type":"Person","@id":"https:\/\/hacking.cool\/atomanya\/#\/schema\/person\/804a839cfa61d89d69fb2cf1d2f0adc2","name":"Atom","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/hacking.cool\/atomanya\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/ac4d05ec7d617e7f2dee5855900a855a?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/ac4d05ec7d617e7f2dee5855900a855a?s=96&d=mm&r=g","caption":"Atom"},"url":"https:\/\/hacking.cool\/atomanya\/author\/atom\/"}]}},"jetpack_featured_media_url":"https:\/\/hacking.cool\/atomanya\/wp-content\/uploads\/2024\/08\/poisoning8.png","_links":{"self":[{"href":"https:\/\/hacking.cool\/atomanya\/wp-json\/wp\/v2\/posts\/1390","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/hacking.cool\/atomanya\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/hacking.cool\/atomanya\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/hacking.cool\/atomanya\/wp-json\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/hacking.cool\/atomanya\/wp-json\/wp\/v2\/comments?post=1390"}],"version-history":[{"count":11,"href":"https:\/\/hacking.cool\/atomanya\/wp-json\/wp\/v2\/posts\/1390\/revisions"}],"predecessor-version":[{"id":1560,"href":"https:\/\/hacking.cool\/atomanya\/wp-json\/wp\/v2\/posts\/1390\/revisions\/1560"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/hacking.cool\/atomanya\/wp-json\/wp\/v2\/media\/1428"}],"wp:attachment":[{"href":"https:\/\/hacking.cool\/atomanya\/wp-json\/wp\/v2\/media?parent=1390"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/hacking.cool\/atomanya\/wp-json\/wp\/v2\/categories?post=1390"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/hacking.cool\/atomanya\/wp-json\/wp\/v2\/tags?post=1390"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}