CVE-2022-21227: Sqlite3 Denial-of-Service When Binding Invalid Parameters Vulnerability

HIGH
Advisory Identifier: GHSA-9qrh-qjmc-5w2p
CVSS 7.5
CWE-248
Published
Advisory Summary

CVE-2022-21227 is a HIGH (CVSS 7.5) denial-of-service when binding invalid parameters vulnerability (CWE-248: Uncaught Exception) affecting Sqlite3 libraries in the npm ecosystem. The issue involves denial-of-service when binding invalid parameters in sqlite3. Remediation is available by upgrading affected packages to version 5.0.3.

CVE-2022-21227 at a Glance

CVE Identifier CVE-2022-21227
GHSA Identifier GHSA-9qrh-qjmc-5w2p
Severity HIGH
CVSS v3.1 Base Score 7.5
CWE Classification CWE-248: Uncaught Exception
Affected Product Sqlite3
Package Ecosystem npm
Published Date
Last Updated

Security Impact

CVSS: 7.5

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:N/A:H).

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 None (I:N)
Availability High (A:H)

How to Fix CVE-2022-21227

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

sqlite3 fixed: 5.0.3
npm install sqlite3@5.0.3
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 sqlite3

How to Check if You Are Affected

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

npm ls sqlite3

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

Note: The npm ls sqlite3 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-248: Uncaught Exception, where an exception is thrown from a function, but it is not caught. In Sqlite3, 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

Affected versions of sqlite3 will experience a fatal error when supplying a specific object in the parameter array. This error causes the application to crash and could not be caught. Users of `sqlite3` v5.0.0, v5.0.1 and v5.0.2 are affected by this. This issue is fixed in v5.0.3. All users are recommended to upgrade to v5.0.3 or later. Ensure there is sufficient sanitization in the parent application to protect against invalid values being supplied to binding parameters as a workaround.

CVE-2022-21227 Affected Sqlite3 Versions

1 component(s)
Fixed Versions:
5.0.3
Product / Package Ecosystem Affected Versions Fixed Version
sqlite3
npm
≥ 5.0.0
< 5.0.3
5.0.3

References

Frequently Asked Questions

What is CVE-2022-21227?
CVE-2022-21227 is a security vulnerability in Sqlite3 involving Denial-of-Service when binding invalid parameters in sqlite3 under CWE-248: Uncaught Exception.
Which Sqlite3 versions are affected?
Affected versions include releases prior to 5.0.3 across affected packages: sqlite3.
What version fixes CVE-2022-21227?
Upgrading to 5.0.3 (or the latest patched release for your respective branch) resolves the vulnerability.
Is sqlite3 affected?
Yes, sqlite3 is affected in releases prior to 5.0.3. Upgrade your dependency to 5.0.3 or later.
What is the CVSS score of CVE-2022-21227?
CVE-2022-21227 has a CVSS v3.1 base score of 7.5 (HIGH) with vector string CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H.
What CWE is associated with CVE-2022-21227?
CVE-2022-21227 is classified under CWE-248: Uncaught Exception (An exception is thrown from a function, but it is not caught.).
How can I check npm dependencies for CVE-2022-21227?
Run the dependency tree command: 'npm ls sqlite3'. 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-9qrh-qjmc-5w2p",
  "modified" : "2022-05-03T02:24:25Z",
  "published" : "2022-04-28T20:25:23Z",
  "aliases" : [ "CVE-2022-21227" ],
  "summary" : "Denial-of-Service when binding invalid parameters in sqlite3",
  "details" : "Affected versions of sqlite3 will experience a fatal error when supplying a specific object in the parameter array. This error causes the application to crash and could not be caught. Users of `sqlite3` v5.0.0, v5.0.1 and v5.0.2 are affected by this. This issue is fixed in v5.0.3. All users are recommended to upgrade to v5.0.3 or later. Ensure there is sufficient sanitization in the parent application to protect against invalid values being supplied to binding parameters as a workaround.\n",
  "severity" : [ {
    "type" : "CVSS_V3",
    "score" : "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H"
  } ],
  "affected" : [ {
    "package" : {
      "ecosystem" : "npm",
      "name" : "sqlite3"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "5.0.0"
      }, {
        "fixed" : "5.0.3"
      } ]
    } ]
  } ],
  "references" : [ {
    "type" : "WEB",
    "url" : "https://github.com/TryGhost/node-sqlite3/security/advisories/GHSA-9qrh-qjmc-5w2p"
  }, {
    "type" : "ADVISORY",
    "url" : "https://nvd.nist.gov/vuln/detail/CVE-2022-21227"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/TryGhost/node-sqlite3/issues/1440"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/TryGhost/node-sqlite3/issues/1449"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/TryGhost/node-sqlite3/commit/593c9d498be2510d286349134537e3bf89401c4a"
  }, {
    "type" : "PACKAGE",
    "url" : "https://github.com/TryGhost/node-sqlite3"
  }, {
    "type" : "WEB",
    "url" : "https://security.snyk.io/vuln/SNYK-JS-SQLITE3-2388645"
  }, {
    "type" : "WEB",
    "url" : "https://snyk.io/vuln/SNYK-JAVA-ORGWEBJARSNPM-2805470"
  }, {
    "type" : "WEB",
    "url" : "https://snyk.io/vuln/SNYK-JS-SQLITE3-2388645"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-248" ],
    "severity" : "HIGH",
    "github_reviewed" : true,
    "github_reviewed_at" : "2022-04-28T20:25:23Z",
    "nvd_published_at" : "2022-05-01T16:15:00Z"
  }
}