XSSit
Challenge:

Source:
Checking for the Dompurify version.

Application uses the latest version of DOMPurify, so the version is not vulnerable to any CVE's.

Applications parse the HTML input and make it in the blob.


DOMPurify Strips dangerous HTML<img src='x' onerror=alert(1)/> to the <img src='x'>. So, we can't able to popup the XSS.
In the type field, they didn't include charset.
The
charsetattribute tells the browser that UTF-8 was used to encode the HTTP response body. A character encoding like UTF-8 defines a mapping between characters and bytes. When a web server serves an HTML document, it maps the characters of the document to the corresponding bytes and transmits these in the HTTP response body. This process turns characters into bytes (encode).
Three common ways that a browser uses to determine the character encoding of an HTML document, ordered by priority:
Byte-Order Mark at the beginning of the HTML document
charsetattribute in theContent-Typeheader<meta>tag in the HTML document

If no charset is provided in the response Content-Type header,Use Byte Order Mark to bypass DOMPurify.
Run this POC in locally:

The XSS poped up properly, so trying the same payload in the challenge.

Payload breaks our payload not escapes properly and not converted as Japanese language like happened in local.
While checking the charset of the blob.

Charset is in default windows-1252.

Change the charset using the escape sequence.

Now the Charset changed to ISO-2022-JP.
So change the payload \x1b(B to %1b(B so we can escape it.
Boom we got a XSS 🎉.


Extras:
While looking for this challenge, read about the similar issue in the chromium.
POC:
Chrome vulnerable version:
Version 85.0.4156.0 (Official Build) canary (64-bit)
POC:


Chrome ignores the type attribute's charset and auto-detects it from the Blob content. If auto-detected as "ISO-2022-JP" instead of UTF-8, decoding differences cause unexpected HTML rendering, executing JavaScript instead of displaying a textarea with "<script>".
Chrome fixed version:

Thank you.
Last updated
