SQL Injection

Affecting knex package, versions <0.6.23 || >=0.7.0 <0.7.6

Do your applications use this vulnerable package? Test your applications

Overview

knex is a batteries-included SQL query & schema builder for Postgres, MySQL and SQLite3 and the Browser.

Column names are not properly escaped in the postgreSQL dialect. This may allow attackers to craft a query to the host DB and access private information. Writing the following code:

var query = knex.select('id","name').from('test')
console.log(query.toSQL())

Has the following result:

{ method: 'select',
  options: undefined,
  bindings: [],
  sql: 'select "id","name" from "test"' }

Remediation

Upgrade knex to versions 0.6.23, 0.7.6 or higher.

References

CVSS Score

6.5
medium severity
  • Attack Vector
    Network
  • Attack Complexity
    Low
  • Privileges Required
    None
  • User Interaction
    None
  • Scope
    Unchanged
  • Confidentiality
    None
  • Integrity
    Low
  • Availability
    Low
CVSS:3.0/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:L/A:L
Credit
Jorge Godoy
CWE
CWE-89
Snyk ID
npm:knex:20150413
Disclosed
12 Apr, 2015
Published
20 Dec, 2016