CVE-2022-1243: Urijs Incorrect Protocol Extraction Vulnerability

HIGH
Advisory Identifier: GHSA-3vjf-82ff-p4r3
CVSS 7.2
CWE-20
Published
Advisory Summary

CVE-2022-1243 is a HIGH (CVSS 7.2) incorrect protocol extraction vulnerability (CWE-20: Improper Input Validation) affecting Urijs libraries in the npm ecosystem. The issue involves incorrect protocol extraction via \r, \n and \t characters. Remediation is available by upgrading affected packages to version 1.19.11.

CVE-2022-1243 at a Glance

CVE Identifier CVE-2022-1243
GHSA Identifier GHSA-3vjf-82ff-p4r3
Severity HIGH
CVSS v3.1 Base Score 7.2
CWE Classification CWE-20: Improper Input Validation
Affected Product Urijs
Package Ecosystem npm
Published Date
Last Updated

Security Impact

CVSS: 7.2

The security impact metrics below are parsed directly from the CVSS v3.1 vector string (CVSS:3.0/AV:N/AC:L/PR:N/UI:N/S:C/C:L/I:L/A:N).

Attack Vector Network (AV:N)
Attack Complexity Low (AC:L)
Privileges Required None (PR:N)
User Interaction None (UI:N)
Scope Changed (S:C)
Confidentiality Low (C:L)
Integrity Low (I:L)
Availability None (A:N)

How to Fix CVE-2022-1243

To remediate this vulnerability, upgrade all affected Urijs dependencies to a patched release. Both direct and transitive dependencies should be checked, as frameworks or security libraries may pull in vulnerable versions transitively.

urijs fixed: 1.19.11
npm install urijs@1.19.11
Verify Direct and Transitive Dependencies

Run the following command in your project directory to verify that all resolved dependencies use the patched release:

npm ls urijs

How to Check if You Are Affected

To determine whether your Node.js application is affected by CVE-2022-1243, inspect your project dependencies using npm:

npm ls urijs

Analyze the terminal output to locate any version of Urijs in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than 1.19.11), your application is affected.

Note: The npm ls urijs command inspects dependencies declared in your package.json and lockfile; it does not perform automated runtime dynamic scanning.

Technical Details

Vulnerability Mechanism & Technical Analysis

This vulnerability is classified under CWE-20: Improper Input Validation, where the product receives input or data, but it does not validate or incorrectly validates that the input has the properties that are required to process the data safely and correctly. In Urijs, software state validation or input boundaries are circumvented during processing. Review the official source advisory statement below for specific affected components, classes, and reproduction details.

Source Advisory Statement

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

CVE-2022-1243 Affected Urijs Versions

1 component(s)
Fixed Versions:
1.19.11
Product / Package Ecosystem Affected Versions Fixed Version
urijs
npm
< 1.19.11
1.19.11

References

Frequently Asked Questions

What is CVE-2022-1243?
CVE-2022-1243 is a security vulnerability in Urijs involving Incorrect protocol extraction via \r, \n and \t characters under CWE-20: Improper Input Validation.
Which Urijs versions are affected?
Affected versions include releases prior to 1.19.11 across affected packages: urijs.
What version fixes CVE-2022-1243?
Upgrading to 1.19.11 (or the latest patched release for your respective branch) resolves the vulnerability.
Is urijs affected?
Yes, urijs is affected in releases prior to 1.19.11. Upgrade your dependency to 1.19.11 or later.
What is the CVSS score of CVE-2022-1243?
CVE-2022-1243 has a CVSS v3.1 base score of 7.2 (HIGH) with vector string CVSS:3.0/AV:N/AC:L/PR:N/UI:N/S:C/C:L/I:L/A:N.
What CWE is associated with CVE-2022-1243?
CVE-2022-1243 is classified under CWE-20: Improper Input Validation (The product receives input or data, but it does not validate or incorrectly validates that the input has the properties that are required to process the data safely and correctly.).
How can I check npm dependencies for CVE-2022-1243?
Run the dependency tree command: 'npm ls urijs'. This command lists direct and transitive dependencies in your build configuration so you can verify if a vulnerable version is resolved.
Machine-readable OSV JSON OSV v1.5 Schema
Normalized schema output
{
  "schema_version" : "1.4.0",
  "id" : "GHSA-3vjf-82ff-p4r3",
  "modified" : "2022-04-14T20:13:56Z",
  "published" : "2022-04-06T00:01:31Z",
  "aliases" : [ "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.\n\nThis can lead to XSS when the module is used to prevent passing in malicious javascript: links into HTML or Javascript (see following example):\n````\nconst parse = require('urijs')\nconst express = require('express')\nconst app = express()\nconst port = 3000\n\ninput = \"ja\\r\\nvascript:alert(1)\"\nurl = parse(input)\n\nconsole.log(url)\n\napp.get('/', (req, res) => {\n if (url.protocol !== \"javascript:\") {res.send(\"<iframe src=\\'\" + input + \"\\'>CLICK ME!</iframe>\")}\n})\n\napp.listen(port, () => {\n console.log(`Example app listening on port ${port}`)\n})\n````",
  "severity" : [ {
    "type" : "CVSS_V3",
    "score" : "CVSS:3.0/AV:N/AC:L/PR:N/UI:N/S:C/C:L/I:L/A:N"
  } ],
  "affected" : [ {
    "package" : {
      "ecosystem" : "npm",
      "name" : "urijs"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0"
      }, {
        "fixed" : "1.19.11"
      } ]
    } ]
  } ],
  "references" : [ {
    "type" : "ADVISORY",
    "url" : "https://nvd.nist.gov/vuln/detail/CVE-2022-1243"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/medialize/uri.js/commit/b0c9796aa1a95a85f40924fb18b1e5da3dc8ffae"
  }, {
    "type" : "PACKAGE",
    "url" : "https://github.com/medialize/uri.js"
  }, {
    "type" : "WEB",
    "url" : "https://huntr.dev/bounties/8c5afc47-1553-4eba-a98e-024e4cc3dfb7"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-20" ],
    "severity" : "HIGH",
    "github_reviewed" : true,
    "github_reviewed_at" : "2022-04-07T15:45:58Z",
    "nvd_published_at" : "2022-04-05T15:15:00Z"
  }
}