Cross-site Sripting (XSS) Affecting htmr package, versions <0.8.7


Severity

Recommended
0.0
medium
0
10

CVSS assessment made by Snyk's Security Team. Learn more

Threat Intelligence

Exploit Maturity
Proof of concept

Do your applications use this vulnerable package?

In a few clicks we can analyze your entire application and see what components are vulnerable in your application, and suggest you quick fixes.

Test your applications

Snyk Learn

Learn about Cross-site Sripting (XSS) vulnerabilities in an interactive lesson.

Start learning
  • Snyk IDSNYK-JS-HTMR-560840
  • published20 Mar 2020
  • disclosed15 Mar 2020
  • creditvisat

Introduced: 15 Mar 2020

CVE NOT AVAILABLE CWE-79  (opens in a new tab)

How to fix?

Upgrade htmr to version 0.8.7 or higher.

Overview

htmr is a simple and lightweight conversion library from HTML string to react element coversions.

Affected versions of this package are vulnerable to Cross-site Sripting (XSS). This module uses innerHTML ref to unescape HTML entities. This leads to DOM-based XSS by inserting HTML-encoded XSS payload (see PoC).

PoC

  1. Create a React app: create-react-app xss-htmr
  2. Install htmr module: cd xss-htmr; npm i htmr
  3. Edit src/App.js file to this:
import React from 'react';
import convert from 'htmr';

export default function App() { return convert(&lt;p&gt;Hash: ${window.location.hash}&lt;/p&gt;); }

  1. Run the server: npm run start
  2. Visit http://localhost:3000/#&lt;img/src/onerror=alert('xss')&gt;, an alert will popup.

Details

CVSS Scores

version 3.1