Page cover

swordsXSSit

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.

circle-info

DOMPurify will strip out everything that contains dangerous HTML and thereby prevent XSS attacks.

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 charset attribute 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:

  1. Byte-Order Mark at the beginning of the HTML document

  2. charset attribute in the Content-Type header

  3. <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.

circle-info

A single occurrence of one of these escape sequences is usually enough to convince the auto-detection algorithm that the HTTP response body is encoded with ISO-2022-JP.

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.

https://game0v3r.in/challenges/XSSit/?html=%3Ca%20id=%22%1b$B%22%3E%3C/a%3E%1b(B%3Ca%20id=%22%3E%3Cimg%20src=x%20onerror=alert(1)%3E%22%3E%3C/a%3Earrow-up-right

Boom we got a XSS 🎉.

Extras:

While looking for this challenge, read about the similar issue in the chromium.

circle-info

Chrome ignores the charset specified in the type attribute. This behavior could introduce XSS via the charset auto-detection.

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