Posts Tagged ‘escape’

sanitize-html-react Vulnerability

21 Nov 2020


At work, we tend to test our near-complete features internally as a team to capture any bugs before they are shipped to customers. We call this process a ‘blitz’ and it has successfully caught many bugs for us that can be addressed before shipping a feature.

In this case, I was testing a sanitization library we had used to sanitize some use provided input (as HTML) called sanitize-html-react. After testing some common payloads from the OWASP XSS Cheat Sheet I discovered the library was flawed.

This library was selected because it was already in use in other parts of the codebase. For this reason, we believed it to be safe as we assumed it has passed the required security checks and standards we have set in place. However, in this case, it wasn’t.

sanitize-html-react library

The sanitize-html-react library is a fork at some point in time off the sanitize-html library.
However, it has no dependencies on sanitize-html and therefore it will not benefit from security updates.
The sanitize-html library is actively maintained where as sanitize-html-react library has not been updated for more than four years!

sanitize-html-react Github Repo

Proof of Concept

The discovered bug was found using the recursive XSS payload above.
The above config states we should discard all tags (as allowedTags list is empty).
In the above example the inner <u> in <<u>u>underlined is stripped away which forms a new <u> element resulting in the final string <u>underlined.

The same concept can be used to render <script> tags (or any other tag).

External Usage

Many open-source public repositories are or have used this library, potentially opening themselves up to security vulnerabilities.


An issue has been created on the Github repo here:

Proposed Solutions

✅ sanitize-html

Replace package with sanitize-html (
This is a maintained, up to date, drop-in replacement.

✅ DOMPurify

Replace package with DOMPurify (
Popular and maintained XSS sanitizer.

✅ lodash.escape

Consider using Lodash escape ( if you were only using sanitize-html-react in escape mode.

No Comments

Posted in XSS


Advent Of Code 2015: Day 8

09 Dec 2015
CTF: Advent Of Code 2015
Link to challenge:
Date Completed: 09 December 2015



A fairly simple puzzle. My approach was to add up the strings together and use regular expressions to replace special characters with a * character so that the python len function would provide me with the correct result.



Posted in Advent Of Code 2015