CVE-2022-31150: Undici Undici Before V5.8.0 Vulnerable To Vulnerability

MODERATE
Advisory Identifier: GHSA-3cvr-822r-rqcc
CVSS 5.3
CWE-93
Published
Advisory Summary

CVE-2022-31150 is a MODERATE (CVSS 5.3) undici before v5.8.0 vulnerable to vulnerability (CWE-93: Improper Neutralization of CRLF Sequences ('CRLF Injection')) affecting Undici libraries in the npm ecosystem. The issue involves undici before v5.8.0 vulnerable to crlf injection in request headers. Remediation is available by upgrading affected packages to version 5.8.0.

CVE-2022-31150 at a Glance

CVE Identifier CVE-2022-31150
GHSA Identifier GHSA-3cvr-822r-rqcc
Severity MODERATE
CVSS v3.1 Base Score 5.3
CWE Classification CWE-93: Improper Neutralization of CRLF Sequences ('CRLF Injection')
Affected Product Undici
Package Ecosystem npm
Published Date
Last Updated

Security Impact

CVSS: 5.3

The security impact metrics below are parsed directly from the CVSS v3.1 vector string (CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/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 Unchanged (S:U)
Confidentiality None (C:N)
Integrity Low (I:L)
Availability None (A:N)

How to Fix CVE-2022-31150

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

undici fixed: 5.8.0
npm install undici@5.8.0
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 undici

How to Check if You Are Affected

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

npm ls undici

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

Note: The npm ls undici 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-93: Improper Neutralization of CRLF Sequences ('CRLF Injection'), where the product uses crlf (carriage return line feeds) as a special element, e.g. to separate lines or records, but it does not neutralize or incorrectly neutralizes crlf sequences from inputs. In Undici, 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

### Impact It is possible to inject CRLF sequences into request headers in Undici. ```js const undici = require('undici') const response = undici.request("http://127.0.0.1:1000", { headers: {'a': "\r\nb"} }) ``` The same applies to `path` and `method` ### Patches Update to v5.8.0 ### Workarounds Sanitize all HTTP headers from untrusted sources to eliminate `\r\n`. ### References https://hackerone.com/reports/409943 https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2018-12116 ### For more information If you have any questions or comments about this advisory: * Open an issue in [undici repository](https://github.com/nodejs/undici/issues) * To make a report, follow the [SECURITY](https://github.com/nodejs/node/blob/HEAD/SECURITY.md) document

CVE-2022-31150 Affected Undici Versions

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

References

Frequently Asked Questions

What is CVE-2022-31150?
CVE-2022-31150 is a security vulnerability in Undici involving undici before v5.8.0 vulnerable to CRLF injection in request headers under CWE-93: Improper Neutralization of CRLF Sequences ('CRLF Injection').
Which Undici versions are affected?
Affected versions include releases prior to 5.8.0 across affected packages: undici.
What version fixes CVE-2022-31150?
Upgrading to 5.8.0 (or the latest patched release for your respective branch) resolves the vulnerability.
Is undici affected?
Yes, undici is affected in releases prior to 5.8.0. Upgrade your dependency to 5.8.0 or later.
What is the CVSS score of CVE-2022-31150?
CVE-2022-31150 has a CVSS v3.1 base score of 5.3 (MODERATE) with vector string CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:L/A:N.
What CWE is associated with CVE-2022-31150?
CVE-2022-31150 is classified under CWE-93: Improper Neutralization of CRLF Sequences ('CRLF Injection') (The product uses CRLF (carriage return line feeds) as a special element, e.g. to separate lines or records, but it does not neutralize or incorrectly neutralizes CRLF sequences from inputs.).
How can I check npm dependencies for CVE-2022-31150?
Run the dependency tree command: 'npm ls undici'. 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-3cvr-822r-rqcc",
  "modified" : "2022-07-21T20:30:10Z",
  "published" : "2022-07-21T20:30:10Z",
  "aliases" : [ "CVE-2022-31150" ],
  "summary" : "undici before v5.8.0 vulnerable to CRLF injection in request headers",
  "details" : "### Impact\n\nIt is possible to inject CRLF sequences into request headers in Undici.\n\n```js\nconst undici = require('undici')\n\nconst response = undici.request(\"http://127.0.0.1:1000\", {\n  headers: {'a': \"\\r\\nb\"}\n})\n```\n\nThe same applies to `path` and `method`\n\n### Patches\n\nUpdate to v5.8.0\n\n### Workarounds\n\nSanitize all HTTP headers from untrusted sources to eliminate `\\r\\n`.\n\n### References\n\nhttps://hackerone.com/reports/409943\nhttps://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2018-12116\n\n### For more information\n\nIf you have any questions or comments about this advisory:\n\n* Open an issue in [undici repository](https://github.com/nodejs/undici/issues)\n* To make a report, follow the [SECURITY](https://github.com/nodejs/node/blob/HEAD/SECURITY.md) document\n",
  "severity" : [ {
    "type" : "CVSS_V3",
    "score" : "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:L/A:N"
  } ],
  "affected" : [ {
    "package" : {
      "ecosystem" : "npm",
      "name" : "undici"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0"
      }, {
        "fixed" : "5.8.0"
      } ]
    } ]
  } ],
  "references" : [ {
    "type" : "WEB",
    "url" : "https://github.com/nodejs/undici/security/advisories/GHSA-3cvr-822r-rqcc"
  }, {
    "type" : "ADVISORY",
    "url" : "https://nvd.nist.gov/vuln/detail/CVE-2022-31150"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/nodejs/undici/commit/a29a151d0140d095742d21a004023d024fe93259"
  }, {
    "type" : "WEB",
    "url" : "https://hackerone.com/reports/409943"
  }, {
    "type" : "PACKAGE",
    "url" : "https://github.com/nodejs/undici"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/nodejs/undici/releases/tag/v5.8.0"
  }, {
    "type" : "WEB",
    "url" : "https://security.netapp.com/advisory/ntap-20220915-0002"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-93" ],
    "severity" : "MODERATE",
    "github_reviewed" : true,
    "github_reviewed_at" : "2022-07-21T20:30:10Z",
    "nvd_published_at" : "2022-07-19T21:15:00Z"
  }
}