Skip to content
XSS Disclosed report Intermediate CVE-2022-1243

Incorrect protocol extraction via \r, \n and \t characters

The urijs library incorrectly extracts the protocol from URLs containing carriage return, line feed, or tab characters, so a URL like 'ja\r\nvascript:alert(1)' is not recognised as a javascript: URL. An attacker could bypass a check that blocks javascript: links and inject a malicious link into HTML, leading to cross-site scripting.

medialize/URI.js

Originally disclosed on huntr

\r, \n and \t characters in user-input URLs can potentially lead to incorrect protocol extraction when using npm package urijs prior to version 1.19.11.

This can lead to XSS when the module is used to prevent passing in malicious javascript: links into HTML or Javascript (see following example):

const parse = require('urijs')
const express = require('express')
const app = express()
const port = 3000

input = "ja\r\nvascript:alert(1)"
url = parse(input)

console.log(url)

app.get('/', (req, res) => {
 if (url.protocol !== "javascript:") {res.send("<iframe src=\'" + input + "\'>CLICK ME!</iframe>")}
})

app.listen(port, () => {
 console.log(`Example app listening on port ${port}`)
})

From the GitHub Advisory Database (GHSA-3vjf-82ff-p4r3, CC BY 4.0).

The original report as published on the GitHub Advisory Database. Images and videos are our own copies; raw HTML is shown as text. View it on GitHub Advisory Database.

Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.

How it worked

Root cause

Likely the URL parser did not strip or reject carriage return, line feed, and tab characters before extracting the protocol, so the protocol check saw a different value than the browser did.

What the attacker needed

Application uses urijs < 1.19.11; input is placed into HTML; victim visits the page

The fix

The library was fixed in version 1.19.11 to handle these control characters correctly.

Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.

Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.

A library called urijs is used to split a web address into parts like the protocol (the 'javascript:' part). It failed to handle hidden control characters such as carriage return, line feed, and tab, so it did not see 'javascript:' when those characters were inserted. A website that relied on this check could then put a dangerous link into a page, and clicking it would run attacker code in the victim's browser.

What is XSS?

Script an attacker supplies runs in another user's browser, on the target's origin, with that user's session.

More from medialize/URI.js

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Cross-site scripting (XSS)

The lesson behind this report.

Script an attacker supplies runs in another user's browser, on the target's origin, with that user's session.