Vulnerabilities in pkg:npm/knex
PACKAGECVE-2016-20018 is a HIGH (CVSS 7.5) sql injection vulnerability (CWE-89: Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')) affecting Knex libraries in the npm ecosystem. The issue involves knex.js has a limited sql injection vulnerability. Remediation is available by upgrading affected packages to version 2.4.0.
pkg:npm/knex
Vulnerability advisories affecting package pkg:npm/knex. Select an advisory below to view technical details or fixes.
| Advisory ID | CVE / NVD | Severity | Summary |
|---|---|---|---|
| GHSA-4jv9-3563-23j3 | CVE-2016-20018 | HIGH | Knex.js has a limited SQL injection vulnerability |
| GHSA-58v4-qwx5-7f59 | CVE-2019-10757 | CRITICAL | SQL Injection in knex |
CVE-2016-20018 at a Glance
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:H/I:N/A:N).
How to Fix CVE-2016-20018
To remediate this vulnerability, upgrade all affected Knex dependencies to a patched release. Both direct and transitive dependencies should be checked, as frameworks or security libraries may pull in vulnerable versions transitively.
npm install knex@2.4.0
Run the following command in your project directory to verify that all resolved dependencies use the patched release:
npm ls knex
How to Check if You Are Affected
To determine whether your Node.js application is affected by CVE-2016-20018, inspect your project dependencies using npm:
npm ls knex
Analyze the terminal output to locate any version of Knex in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than 2.4.0), your application is affected.
Note: The npm ls knex 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-89: Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection'), where the product constructs all or part of an sql command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended sql command when it is sent to a downstream component. without sufficient removal or quoting of sql syntax in user-controllable inputs, the generated sql query can cause those inputs to be interpreted as sql instead of ordinary user data. In Knex, 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
CVE-2016-20018 Affected Knex Versions
1 component(s)| Product / Package | Ecosystem | Affected Versions | Fixed Version |
|---|---|---|---|
|
knex
|
npm |
< 2.4.0
|
2.4.0
|
References
Frequently Asked Questions
What is CVE-2016-20018?
Which Knex versions are affected?
What version fixes CVE-2016-20018?
Is knex affected?
What is the CVSS score of CVE-2016-20018?
What CWE is associated with CVE-2016-20018?
How can I check npm dependencies for CVE-2016-20018?
Machine-readable OSV JSON
OSV v1.5 Schema
{
"schema_version" : "1.4.0",
"id" : "GHSA-4jv9-3563-23j3",
"modified" : "2023-01-08T15:23:32Z",
"published" : "2022-12-19T09:30:23Z",
"aliases" : [ "CVE-2016-20018" ],
"summary" : "Knex.js has a limited SQL injection vulnerability",
"details" : "Knex Knex.js through 2.3.0 has a limited SQL injection vulnerability that can be exploited to ignore the WHERE clause of a SQL query. This vulnerability has been fixed in version 2.4.0.",
"severity" : [ {
"type" : "CVSS_V3",
"score" : "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:N/A:N"
} ],
"affected" : [ {
"package" : {
"ecosystem" : "npm",
"name" : "knex"
},
"ranges" : [ {
"type" : "ECOSYSTEM",
"events" : [ {
"introduced" : "0"
}, {
"fixed" : "2.4.0"
} ]
} ]
} ],
"references" : [ {
"type" : "ADVISORY",
"url" : "https://nvd.nist.gov/vuln/detail/CVE-2016-20018"
}, {
"type" : "WEB",
"url" : "https://github.com/knex/knex/issues/1227"
}, {
"type" : "WEB",
"url" : "https://github.com/knex/knex/pull/5417"
}, {
"type" : "WEB",
"url" : "https://github.com/knex/knex/commit/e145322da92749be7749f9ade5b5f5a66d6586a4"
}, {
"type" : "PACKAGE",
"url" : "https://github.com/knex/knex"
}, {
"type" : "WEB",
"url" : "https://github.com/knex/knex/releases/tag/2.4.0"
}, {
"type" : "WEB",
"url" : "https://www.ghostccamm.com/blog/knex_sqli"
} ],
"database_specific" : {
"cwe_ids" : [ "CWE-89" ],
"severity" : "HIGH",
"github_reviewed" : true,
"github_reviewed_at" : "2022-12-20T17:19:47Z",
"nvd_published_at" : "2022-12-19T09:15:00Z"
}
}