CVE-2017-16082: Code Injection

Published Jun 7, 2018
·
Updated

A remote code execution vulnerability was found within the pg module when the remote database or query specifies a specially crafted column name. There are 2 likely scenarios in which one would likely be vulnerable. 1) Executing unsafe, user-supplied sql which contains a malicious column name. 2) Connecting to an untrusted database and executing a query which returns results where any of the column names are malicious.

Other sources

Affected versions of pg contain a remote code execution vulnerability that occurs when the remote database or query specifies a crafted column name.

There are two specific scenarios in which it is likely for an application to be vulnerable: 1. The application executes unsafe, user-supplied sql which contains malicious column names. 2. The application connects to an untrusted database and executes a query returning results which contain a malicious column name.

Proof of Concept const { Client } = require('pg') const client = new Client() client.connect()

const sql = SELECT 1 AS "\\'/", 2 AS "\\'/\n + console.log(process.env)] = null;\n//"

client.query(sql, (err, res) => { client.end() })

Recommendation

Version 2.x.x: Update to version 2.11.2 or later. Version 3.x.x: Update to version 3.6.4 or later. Version 4.x.x: Update to version 4.5.7 or later. Version 5.x.x: Update to version 5.2.1 or later. Version 6.x.x: Update to version 6.4.2 or later. ( Note that versions 6.1.6, 6.2.5, and 6.3.3 are also patched. ) Version 7.x.x: Update to version 7.1.2 or later. ( Note that version 7.0.2 is also patched. )

Affected Software

17 affected componentsFixes available
npm/pg>=7.1.0<7.1.2
7.1.2
npm/pg>=7.0.0<7.0.2
7.0.2
npm/pg>=6.4.0<6.4.2
6.4.2
npm/pg>=6.3.0<6.3.3
6.3.3
npm/pg>=6.2.0<6.2.5
6.2.5
npm/pg>=6.1.0<6.1.6
6.1.6
npm/pg>=6.0.0<6.0.5
6.0.5
npm/pg>=5.0.0<5.2.1
5.2.1
npm/pg>=4.0.0<4.5.7
4.5.7
npm/pg>=3.0.0<3.6.4
3.6.4
npm/pg<2.11.2
2.11.2
Node-postgres Pg Node.js>=2.0.0<2.11.2
Node-postgres Pg Node.js>=3.0.0<3.6.4
Node-postgres Pg Node.js>=4.0.0<4.5.7
Node-postgres Pg Node.js>5.0.0<5.2.1
Node-postgres Pg Node.js>=6.0.0<6.4.2
Node-postgres Pg Node.js>=7.0.0<7.1.2

Event History

Jun 7, 2018
CVE Published
via MITRE·02:00 AM
Data Sourced
via MITRE·02:00 AM
DescriptionWeakness
Jul 24, 2018
Advisory Published
07:44 PM

Frequently Asked Questions

1

What is the severity of CVE-2017-16082?

CVE-2017-16082 is classified as a high severity vulnerability due to its remote code execution capabilities.

2

How do I fix CVE-2017-16082?

To fix CVE-2017-16082, upgrade to pg versions 7.1.2, 7.0.2, 6.4.2, or 6.3.3 or later.

3

What causes CVE-2017-16082?

CVE-2017-16082 is caused by the processing of specially crafted column names in user-supplied SQL queries.

4

Which systems are affected by CVE-2017-16082?

CVE-2017-16082 affects versions of the pg module in Node.js from 2.0.0 to 7.1.1.

5

How can I test for CVE-2017-16082 in my application?

You can test for CVE-2017-16082 by running SQL queries that utilize unsafe, user-supplied column names to check for unexpected behavior.

Contact

SecAlerts Pty Ltd.
132 Wickham Terrace
Fortitude Valley,
QLD 4006, Australia
info@secalerts.co
By using SecAlerts services, you agree to our services end-user license agreement. This website is safeguarded by reCAPTCHA and governed by the Google Privacy Policy and Terms of Service. All names, logos, and brands of products are owned by their respective owners, and any usage of these names, logos, and brands for identification purposes only does not imply endorsement. If you possess any content that requires removal, please get in touch with us.
© 2026 SecAlerts Pty Ltd.
ABN: 70 645 966 203, ACN: 645 966 203