<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Hakim Luqman Muhammad on Medium]]></title>
        <description><![CDATA[Stories by Hakim Luqman Muhammad on Medium]]></description>
        <link>https://medium.com/@hakim.luqman.muhammad?source=rss-6cc458f20648------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*kORCSTqZr7rbhfGk</url>
            <title>Stories by Hakim Luqman Muhammad on Medium</title>
            <link>https://medium.com/@hakim.luqman.muhammad?source=rss-6cc458f20648------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Fri, 04 Dec 2026 13:14:10 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@hakim.luqman.muhammad/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Exploiting JWT Vulnerabilities with Burp Suite JWT Editor]]></title>
            <link>https://medium.com/fmisec/exploiting-jwt-vulnerabilities-with-burp-suite-jwt-editor-c1e955c74f24?source=rss-6cc458f20648------2</link>
            <guid isPermaLink="false">https://medium.com/p/c1e955c74f24</guid>
            <category><![CDATA[web-app-pentesting]]></category>
            <category><![CDATA[jwt-hacking]]></category>
            <category><![CDATA[jwt]]></category>
            <category><![CDATA[jwt-vulnerabilities]]></category>
            <category><![CDATA[red-team]]></category>
            <dc:creator><![CDATA[Hakim Luqman Muhammad]]></dc:creator>
            <pubDate>Tue, 13 Oct 2026 15:41:31 GMT</pubDate>
            <atom:updated>2026-10-24T13:56:50.737Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*i-b6DScECpxuJk5TnvZnYw.png" /></figure><p>In this article, we will explore JWT attacks using the <a href="https://portswigger.net/bappstore/26aaa5ded2f74beea19e2ed8345a93dd">JWT Editor</a> extension for Burp Suite. We will demonstrate these attacks using the following PortSwigger labs:</p><ol><li><a href="https://portswigger.net/web-security/jwt/lab-jwt-authentication-bypass-via-weak-signing-key">JWT authentication bypass via weak signing key</a></li><li><a href="https://portswigger.net/web-security/jwt/lab-jwt-authentication-bypass-via-jwk-header-injection">JWT authentication bypass via JWK header injection</a></li><li><a href="https://portswigger.net/web-security/jwt/algorithm-confusion/lab-jwt-authentication-bypass-via-algorithm-confusion">JWT authentication bypass via algorithm confusion</a></li></ol><p>Each lab provides the credentials wiener:peter, and the objective is to access the /admin endpoint by exploiting JWT vulnerabilities.</p><h3>JWT Authentication Bypass via Weak Signing Key</h3><p>In this lab, the application uses a weak, guessable secret key to sign JWTs with the symmetric HS256 algorithm. This allows an attacker to discover the secret through a dictionary attack. Once the secret is recovered, the attacker can modify JWT claims, such as changing the sub claim from wiener to administrator, and re-sign the token to gain access to the admin interface.</p><p>After logging in with the wiener:peter credentials and accessing /admin, we receive an unauthorized response: Admin interface only available if logged in as an administrator.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*aOOknnWq0qaGS2yTexnhAw.png" /><figcaption>Unauthorized Response</figcaption></figure><p>First we need to guess the JWT secret:</p><ol><li>Send the request to /admin to Repeater, then open the <strong>JSON Web Token</strong> tab.</li><li>Select <strong>Attack → Weak HMAC Secret.</strong></li><li>The HMAC secret is successfully recovered: secret1.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*o2pWV6iC2gXWOc6Bvw8Bvg.png" /><figcaption>Guess HS256 Secret with JWT Editor</figcaption></figure><p>Once the secret has been recovered, we need to create a key using that secret in the JWT Editor tab:</p><ol><li>Select <strong>New Symmetric Key</strong>.</li><li>Enter the recovered secret, secret1, in the <strong>Specify secret</strong> field.</li><li>Generate the key.</li><li>Note the generated key ID, ff43e26c-6efc-4a0b-a068-6753c36dc58d, and click <strong>OK</strong>.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/868/1*cB_M7ISX2RkRv1CtgF6ycA.png" /><figcaption>Generate Key</figcaption></figure><p>Finally, we can exploit the vulnerability by modifying the JWT claim and signing the token with the recovered secret. Return to the <strong>JSON Web Token</strong> tab in Repeater:</p><ol><li>Change the sub claim in the JWT payload from wiener to administrator.</li><li>Click <strong>Sign</strong> to sign the modified token using the key we created earlier.</li><li>Select the signing key with the ID ff43e26c-6efc-4a0b-a068-6753c36dc58d.</li><li>Select <strong>Don’t modify header</strong>.</li><li>Click <strong>OK</strong>, then send the request to /admin.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*T-gmjC07-euc6vzyblXlfw.png" /><figcaption>Signing JWT Token</figcaption></figure><p>The newly signed JWT can now be used to access /admin.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ROCjrD9cWW2PDFYpjBVQ4g.png" /><figcaption>Authentication Bypassed</figcaption></figure><h3>JWT Authentication Bypass via JWK Header Injection</h3><p>In this lab, the server trusts a public key embedded directly in the JWT header through the <strong>JWK</strong> parameter. An attacker can generate their own key pair, modify the JWT claims, and sign the token using their private key. If the server fails to verify whether the supplied public key is trusted, the attacker can use the forged JWT to gain access to the admin interface.</p><p>After logging in with the wiener:peter credentials and accessing /admin, we receive the following unauthorized response Admin interface only available if logged in as an administrator. To perform a JWK header injection attack, we first need to generate an RSA key in JWT Editor:</p><ol><li>Select <strong>New RSA Key</strong>.</li><li>Select <strong>JWK</strong>, then click <strong>Generate</strong>.</li><li>Note the generated key ID, 08815736-733b-44af-9295-c6e912051972, and click <strong>OK</strong>.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/848/1*Vw4Dipm3MqaR-G1Eg7zYhA.png" /><figcaption>Generate RS256 Key</figcaption></figure><p>Return to the <strong>JSON Web Token</strong> tab in Repeater. We will perform an embedded JWK attack by injecting our public key into the JWT header and signing the modified token with the corresponding private key.</p><ol><li>Change the sub claim in the JWT payload from wiener to administrator.</li><li>Select <strong>Attack → Embedded JWK</strong>.</li><li>Select the key we generated earlier with the ID 08815736-733b-44af-9295-c6e912051972.</li><li>Click <strong>OK</strong>, then send the request.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*W0CCqGYEUXHY0S2df2QgCA.png" /><figcaption>Embedded JWK Attack</figcaption></figure><p>The <strong>Attack → Embedded JWK</strong> feature automatically inject our public key, modifies the JWT header, and signs the token using corresponding private key. The resulting JWT can now be used to access /admin.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*RISYNeEO0t-SOAHq5DxR8g.png" /><figcaption>Authenticatioin Bypassed</figcaption></figure><h3>JWT Authentication Bypass via Algorithm Confusion</h3><p>In this lab, the server uses the RS256 algorithm to verify JWT signatures. However, it incorrectly handles the RS256 public key as an HMAC secret. This implementation flaw allows an attacker to modify JWT claims and re-sign the token without knowing the server’s private key, potentially gaining access to the admin interface.</p><p>After logging in with the wiener:peter credentials and accessing /admin, we receive the following unauthorized response: Admin interface only available if logged in as an administrator. We can retrieve the public key from /jwks.json. The key has the ID b98fa760-e80d-4979-a902-fa2ea91f5344.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/948/1*VH-438mPEUx2dUvOGyUA_Q.png" /><figcaption>Public Key on /jwks.json</figcaption></figure><p>Note that we only need to extract the public key object shown below, rather than the entire JSON response:</p><pre>{<br>  &quot;kty&quot;: &quot;RSA&quot;,<br>  &quot;e&quot;: &quot;AQAB&quot;,<br>  &quot;use&quot;: &quot;sig&quot;,<br>  &quot;kid&quot;: &quot;b98fa760-e80d-4979-a902-fa2ea91f5344&quot;,<br>  &quot;alg&quot;: &quot;RS256&quot;,<br>  &quot;n&quot;: &quot;st0Wb1r75-noLvBO_F5e1AWQNfrqbA-2InNJVHA1N75bbFtuP6a5VY1k-tIPHRo6A4GqSmfJFk7QyodZ-KuQIfLgqc2YrtmH0R0OwIQIRGpSJGe-C4YDSAeA-tEsD58GZyy7Ksj0nGfg210INLOAP_YMnu59dLnGX8bg6pxA6QDIZ2-6k3phUbF9S0xngqPTRlWfRwLJQxy_G5nLRlOorrE-GqA19Wy00cHZ_hY9AqpWiefR6bs_JuPzEx6mfxNujs3NlRspTiwvJb2087uGGPBrCQJCcqz_J0eSfRyCpwvYkZ8tEGy9unXaWLhB1-pypE0oG9fP8W_ChQRPGJRYgw&quot;<br>}</pre><p>We then need to import the public key into JWT Editor:</p><ol><li>Select <strong>New RSA Key</strong>.</li><li>Paste the public key.</li><li>Confirm that the key ID is b98fa760-e80d-4979-a902-fa2ea91f5344, then click <strong>OK</strong>.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/846/1*2tPgCAyAzPF6KGDDg-_qEg.png" /><figcaption>Create RSA Public Key</figcaption></figure><p>Return to the <strong>JSON Web Token</strong> tab for the /admin request in Repeater. After importing the key, we can perform an HMAC key confusion attack by using the public key as the HS256 signing secret.</p><ol><li>Change the sub claim in the JWT payload from wiener to administrator.</li><li>Select <strong>Attack → HMAC Key Confusion</strong>.</li><li>Select the imported key with the ID b98fa760-e80d-4979-a902-fa2ea91f5344.</li><li>Keep the default options. If the attack fails, try different options.</li><li>Click <strong>OK</strong>, then send the request.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*7KTIWOxD41Qs49QsBIimew.png" /><figcaption>Algorithm Confusion Attack</figcaption></figure><p>The <strong>Attack → HMAC Key Confusion</strong> feature automatically signs the modified token using the HS256 algorithm, treating the imported public key as the HMAC secret. The resulting JWT can now be used to access /admin.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*HEA2JmprvuMWODZE7-O6Ng.png" /><figcaption>Authentication Bypassed</figcaption></figure><h3>Conclusion</h3><p>These three labs demonstrate how weak signing secrets, improper public key validation, and JWT algorithm confusion can allow attackers to forge tokens and bypass authentication. Using JWT Editor in Burp Suite makes it easier to test these attack scenarios.</p><p>To mitigate these vulnerabilities, applications should use strong cryptographic keys, enforce an explicit allowlist of permitted algorithms, validate the source of signing keys, and implement proper server-side authorization checks.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c1e955c74f24" width="1" height="1" alt=""><hr><p><a href="https://medium.com/fmisec/exploiting-jwt-vulnerabilities-with-burp-suite-jwt-editor-c1e955c74f24">Exploiting JWT Vulnerabilities with Burp Suite JWT Editor</a> was originally published in <a href="https://medium.com/fmisec">FMI Cyber Security Consulting Services</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Server Side Prototype Pollution]]></title>
            <link>https://medium.com/fmisec/server-side-prototype-pollution-f89ccfb8c849?source=rss-6cc458f20648------2</link>
            <guid isPermaLink="false">https://medium.com/p/f89ccfb8c849</guid>
            <category><![CDATA[web-hacking]]></category>
            <category><![CDATA[pentesting]]></category>
            <category><![CDATA[red-team]]></category>
            <category><![CDATA[web-app-pentesting]]></category>
            <dc:creator><![CDATA[Hakim Luqman Muhammad]]></dc:creator>
            <pubDate>Sun, 26 Apr 2026 13:59:49 GMT</pubDate>
            <atom:updated>2026-04-29T18:34:15.153Z</atom:updated>
            <content:encoded><![CDATA[<p>In this article, we will discuss the prototype pollution vulnerability, starting from its root cause and impact, all the way to a practical exploitation demo using the PortSwigger lab: <a href="https://portswigger.net/web-security/prototype-pollution/server-side/lab-remote-code-execution-via-server-side-prototype-pollution">Remote code execution via server-side prototype pollution</a>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*q6B7wQ4mUDd8gHHG5IynUw.png" /><figcaption>Server Side Prototype Pollution</figcaption></figure><h3>Prototype in JavaScript</h3><p>Prototype is a feature that allows JavaScript objects to inherit properties from other objects. Every object in JavaScript has a prototype that can be accessed through the hidden __proto__ attribute.</p><pre>// String prototype<br>&#39;str&#39;.__proto__<br><br>// Number prototype<br>(1337).__proto__<br><br>// Object prototype<br>({}).__proto__</pre><h3>Prototype Pollution</h3><p>If we observe closely, every object shares the same global parent prototype.</p><pre>// Both point to Object.prototype<br>&#39;str&#39;.__proto__.__proto__<br>(1337).__proto__.__proto__</pre><p>This becomes interesting because if there is a prototype injection vulnerability in one object, properties in other objects will also be affected.</p><p>In the following example, the global prototype is polluted with the property foo from a string object, but the impact also appears in Number and Object.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/416/1*6NZK9Y9BjVgymwMuj_b9dA.png" /><figcaption>Property foo appears in Number and Object</figcaption></figure><p>In the wild, prototype pollution usually occurs because developers use code or libraries that merge objects without proper sanitization, for example:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/475/1*bzFz9HlCz7xyo6SZLOJhsA.png" /><figcaption>The “__proto__” Payload Polluting Global Object Including Number Object</figcaption></figure><p>The merge function does not perform sanitation, which causes the global prototype to become polluted, resulting in the polluted property appearing in other objects such as numbers. This unsafe merge behaviour is common in outdated javascript utility library like <a href="https://security.snyk.io/vuln/SNYK-JS-LODASH-608086">lodash</a>.</p><h3>Server-Side Impact</h3><p>If prototype pollution happens on the server side, it could have critical consequences because an attacker can easily cause Denial of Service (DoS) by polluting built-in JavaScript properties.</p><p>If the attacker has access to the source code, they could search for gadgets properties that affect Confidentiality, Integrity, or Availability (CIA)</p><p>In the following PortSwigger lab walkthrough, server-side prototype pollution can be chained into Remote Code Execution (RCE).</p><p><strong>Note:</strong> Server-side prototype pollution is highly prone to causing DoS. Avoid testing the following payloads in production environments.</p><h3>Portswigger lab: Remote code execution via server-side prototype pollution</h3><p>Lab Description</p><pre>This lab is built on Node.js and the Express framework. It is vulnerable to server-side prototype pollution because it unsafely merges user-controllable input into a server-side JavaScript object.<br><br>Due to the configuration of the server, it&#39;s possible to pollute Object.prototype in such a way that you can inject arbitrary system commands that are subsequently executed on the server.<br><br>To solve the lab:<br><br>Find a prototype pollution source that you can use to add arbitrary properties to the global Object.prototype.<br>Identify a gadget that you can use to inject and execute arbitrary system commands.<br>Trigger remote execution of a command that deletes the file /home/carlos/morale.txt.<br>In this lab, you already have escalated privileges, giving you access to admin functionality. You can log in to your own account with the following credentials: wiener:peter</pre><p>After logged in with given user, we discovered that the application provides a feature to update billing and delivery addresses using JSON.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*GqmO-mhExWvk_9uHE5Ngaw.png" /><figcaption>Update Billing and Delivery Address Feature</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/967/1*LAMqPW6eeiU0Fh9QR9OYLA.png" /><figcaption>Observed Request from Burp</figcaption></figure><h3>Detecting prototype pollution</h3><p>The following payload is used to confirm prototype pollution. It was observed that the property foo also appeared in the returned object response, which indicates that prototype pollution exists.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/979/1*IddlaQW7DwsQj1ACElQPHA.png" /><figcaption>Property `foo` Reflected in Returned Object Indicating a Prototype Pollution</figcaption></figure><p>If the response does not provide direct feedback, the techniques discussed in the following article can be used:</p><p><a href="https://portswigger.net/research/server-side-prototype-pollution">Server-side prototype pollution: Black-box detection without the DoS</a></p><p>Using the <strong>JSON spaces</strong> technique described in that article, notice that after sending the payload, additional spaces appear between the semicolon and JSON properties in the raw response. This behavior indicates the presence of prototype pollution.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*yF9o8Q8HAt6XuYlOs8xYtQ.png" /><figcaption>Raw Response Before `json spaces` Payload</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/883/1*91ssJFih83y3EeVmI_YSEA.png" /><figcaption>Raw Response with Additional Spaces Between the Semicolon and JSON Properties</figcaption></figure><h3>Remote Code Execution (RCE)</h3><p>The following payload is used to trigger out-of-bound (OOB) connection to Burp Collaborator. We used this payload to identify which endpoint spawns a child process and could triggers RCE if pollute the shell and NODE_OPTIONS properties.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*L914Vc9xf3fbFM4j2yIdfg.png" /><figcaption>OOB Payload to Identify RCE Sink</figcaption></figure><p>After sending the payload, a lookup to Burp Collaborator was observed when using the <strong>Run Maintenance Jobs</strong> feature in the admin panel. This indicates that the feature spawns a child process and can be used as an execution sink.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*hWipk4J1lN5-G77cJ_Qo9Q.png" /><figcaption>Run Maintenance Jobs Feature</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*y9wblrNIbwkLLbTgo6OYfw.png" /><figcaption>OOB Connection Detected from Run Maintenance Jobs Feature</figcaption></figure><p>Additional property of execArgv is then used to achieve RCE and solve the lab by deleting the file /home/carlos/morale.txt. After sending the payload, usethe <strong>Run Maintenance Jobs</strong> feature again to trigger the payload.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*qbeIQX2kVLhBm7Jl4fIZsw.png" /><figcaption>RCE Prototype Pollution Payload</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*fkpJvcrXv7kV2NrAG30fyw.png" /><figcaption>The Lab is Solved After Run Maintenance Jobs feature Trigger the RCE Payload</figcaption></figure><p>And with that, the lab is successfully solved.</p><h3>Closing</h3><p>This vulnerability is critical because it can easily lead to Denial of Service (DoS) and, in certain cases, even Remote Code Execution (RCE), as demonstrated in this lab.</p><p>Preventive measures include properly sanitizing dangerous prototype-related keys such as __proto__, constructor, and prototype during object merging, as well as freezing or restricting modifications to these properties whenever possible.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f89ccfb8c849" width="1" height="1" alt=""><hr><p><a href="https://medium.com/fmisec/server-side-prototype-pollution-f89ccfb8c849">Server Side Prototype Pollution</a> was originally published in <a href="https://medium.com/fmisec">FMI Cyber Security Consulting Services</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Web Cache Poisoning via Host Header Injection — A PortSwigger Lab Walkthrough]]></title>
            <link>https://medium.com/fmisec/web-cache-poisoning-via-host-header-injection-a-portswigger-lab-walkthrough-7e03027ea74d?source=rss-6cc458f20648------2</link>
            <guid isPermaLink="false">https://medium.com/p/7e03027ea74d</guid>
            <category><![CDATA[web-hacking]]></category>
            <category><![CDATA[portswigger-lab]]></category>
            <category><![CDATA[writeup]]></category>
            <category><![CDATA[web-penetration-testing]]></category>
            <category><![CDATA[red-team]]></category>
            <dc:creator><![CDATA[Hakim Luqman Muhammad]]></dc:creator>
            <pubDate>Mon, 09 Mar 2026 05:33:14 GMT</pubDate>
            <atom:updated>2026-03-11T16:03:45.157Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*1qC8VH-ks6cT9ROR7P63ug.png" /></figure><p>In this article, I will walk through an interesting lab from PortSwigger titled <a href="https://portswigger.net/web-security/host-header/exploiting/lab-host-header-web-cache-poisoning-via-ambiguous-requests"><strong>“Web cache poisoning via ambiguous requests”</strong></a> .<strong> </strong>We will walk through the exploit process involving <strong>Host Header Injection, JavaScript injection, and Web Cache Poisoning</strong>.</p><h3>Lab Overview</h3><p>The goal of this lab is to poison the cache server with XSS so everyone visiting the home page will execute`(document.cookie). Here is the lab description:</p><pre>This lab is vulnerable to web cache poisoning due to discrepancies in how the cache and the back-end application handle ambiguous requests. An unsuspecting user regularly visits the site&#39;s home page.<br>To solve the lab, poison the cache so the home page executes alert(document.cookie) in the victim&#39;s browser.</pre><h3>Understanding the Attack Chain</h3><p>The exploit can be split into three step :</p><ol><li>Host Header Injection</li><li>XSS via tracking.js</li><li>Web Cache Poisoning</li></ol><p>Let’s break them down, one by one.</p><h3>Step 1 — Host Header Injection</h3><p>The first interesting behavior is how the application handles multiple Host headers in the same request. Normally, HTTP request should only contain <strong>one Host header</strong>, but many servers do not strictly enforce this rule. Here is our request:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*pUXTvvp6V8qFDPBy33r3yQ.png" /></figure><p>After observing the response, we could conclude:</p><ul><li><strong>Frontend (cache/CDN)</strong> prioritizes the <strong>first Host header</strong> to route the request to backend server</li><li><strong>Backend application</strong> prioritizes the <strong>second Host header</strong> to dynamically create the page.</li></ul><p>This discrepancy creates an opportunity for the next two exploit.</p><pre>Note For some reason you need to use the given `session` and `_lab` cookie to make this double host header injection to work</pre><h3>Step 2 — XSS via tracking.js</h3><p>It’s turns out that, the backend application uses the <strong>Host header value to build the URL for a tracking script</strong>.</p><p>Here is response snippet from previous request:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*aB1p5Ij2Kk6C8qlPdGbNyA.png" /></figure><p>So what happened here?</p><ul><li>The script source now points to the <strong>attacker-controlled exploit server</strong></li><li>The browser will load tracking.js from our exploit server</li></ul><p>This already gives us control over the JavaScript executed in the page. So here is what we do in exploit server:</p><ul><li>Change the path to /resources/js/tracking.js so it match the injected javascript path</li><li>Add our own javascript payload, in this case alert(document.cookie)</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/748/1*KpmfSamKwqu3Iljp40Bbwg.png" /></figure><p>Let’s store our exploit and resend the double host header again.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*pi6HpkP3iSCp4CZ9dQE9ig.png" /></figure><p>Now, we successfully trigger the XSS payload. However, this still requires the victim to receive this modified response. That’s where the final step comes in.</p><h3>Step 3 — Web Cache Poisoning</h3><p>The response from the application contains Cache-Control: max-age=30 header. This means the response can be <strong>cached for 30 seconds</strong>.</p><p>Because the cache only considers the <strong>first Host header</strong>, it will automatically serve response from our double host header request to other user. If the response not poisoned yet, just request everytime the cache about to expired so our request will result in miss cache like so.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*R8Xjl2Z8OIsZuU0TUEXRhw.png" /></figure><p>So, At this point, the lab objective is complete — <strong>everyone accessing the home page executes attacker-controlled JavaScript due to cache poisoning.</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*9FskU7pHIwsUN8PzK478sg.png" /></figure><h3>Why This Vulnerability Is Dangerous</h3><p>What makes this lab particularly interesting is that <strong>none of the individual issues seem critical on their own</strong>.</p><p>However, when combined:</p><ol><li>Ambiguous request parsing</li><li>Host header trust</li><li>Cacheable responses</li></ol><p>They produce a powerful stored attack affecting all users behind the cache. In real-world environments, this type of issue may affect thousands of users simultaneously. Here is several important lessons can be learned from this lab:</p><ol><li>Never trust the Host header: Applications should not rely on the Host header for constructing URLs or loading resources without strict validation.</li><li>Normalize requests at the edge: Caches and backends should process requests consistently to avoid ambiguity.</li><li>Avoid caching dynamic responses: Responses containing user-influenced data should generally not be cached.</li></ol><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7e03027ea74d" width="1" height="1" alt=""><hr><p><a href="https://medium.com/fmisec/web-cache-poisoning-via-host-header-injection-a-portswigger-lab-walkthrough-7e03027ea74d">Web Cache Poisoning via Host Header Injection — A PortSwigger Lab Walkthrough</a> was originally published in <a href="https://medium.com/fmisec">FMI Cyber Security Consulting Services</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>