CVE-2017-16082

CVE-2017-16082 is a critical-severity code injection vulnerability in pg (npm), affecting versions < 2.11.2. It is fixed in 2.11.2, 3.6.4, 4.5.7, 5.2.1, 6.0.5, 6.1.6, 6.2.5, 6.3.3, 6.4.2, 7.0.2, 7.1.2.

Does this CVE actually affect you?

Kodem shows which CVEs are reachable and running in your applications, so you fix what's exploitable, not just what's listed.

Thank you! Your submission has been received!
Oops! Something went wrong while submitting the form.

Runtime intelligence, not another scanner.

Summary

Remote Code Execution in pg

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()
})

Impact

Untrusted input is evaluated as executable code within the application's runtime environment. Typical impact: arbitrary code execution within the application's privilege context.

CVE-2017-16082 has a CVSS score of 9.8 (Critical). The vector is network-reachable, no privileges required, and no user interaction. A CVSS score reflects the worst-case severity of the vulnerability, not your specific exposure. Whether this affects your application depends on whether the vulnerable code is present and reachable in your environment. A fixed version is available (2.11.2, 3.6.4, 4.5.7, 5.2.1, 6.0.5, 6.1.6, 6.2.5, 6.3.3, 6.4.2, 7.0.2, 7.1.2); upgrading removes the vulnerable code path.

Affected versions

pg (< 2.11.2) pg (>= 3.0.0, < 3.6.4) pg (>= 4.0.0, < 4.5.7) pg (>= 5.0.0, < 5.2.1) pg (>= 6.0.0, < 6.0.5) pg (>= 6.1.0, < 6.1.6) pg (>= 6.2.0, < 6.2.5) pg (>= 6.3.0, < 6.3.3) pg (>= 6.4.0, < 6.4.2) pg (>= 7.0.0, < 7.0.2) pg (>= 7.1.0, < 7.1.2)

Security releases

pg → 2.11.2 (npm) pg → 3.6.4 (npm) pg → 4.5.7 (npm) pg → 5.2.1 (npm) pg → 6.0.5 (npm) pg → 6.1.6 (npm) pg → 6.2.5 (npm) pg → 6.3.3 (npm) pg → 6.4.2 (npm) pg → 7.0.2 (npm) pg → 7.1.2 (npm)

Kodem intelligence

Severity tells you how bad this could be in the worst case. It does not tell you whether you are exposed. Exploitability and impact are functions of runtime truth: whether the vulnerable code is present, reachable, and actually executes in your application. A vulnerable package can sit in your dependency tree and never run.

Kodem, an Intelligent Application Security platform, uses runtime intelligence to reveal which vulnerabilities actually execute in production, so teams prioritize the ones that genuinely matter. Kodem's runtime-powered SCA identifies whether this CVE is reachable in your applications.

Already deployed Kodem?

See it in your environmentNew to Kodem? Get a demo →

Remediation advice

  • 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. )

Frequently Asked Questions

  1. What is CVE-2017-16082? CVE-2017-16082 is a critical-severity code injection vulnerability in pg (npm), affecting versions < 2.11.2. It is fixed in 2.11.2, 3.6.4, 4.5.7, 5.2.1, 6.0.5, 6.1.6, 6.2.5, 6.3.3, 6.4.2, 7.0.2, 7.1.2. Untrusted input is evaluated as executable code within the application's runtime environment.
  2. How severe is CVE-2017-16082? CVE-2017-16082 has a CVSS score of 9.8 (Critical). This score reflects the worst-case severity of the vulnerability, not your specific exposure. Whether it represents real risk in your environment depends on whether the vulnerable code is present and reachable.
  3. Which versions of pg are affected by CVE-2017-16082? pg (npm) versions < 2.11.2 is affected.
  4. Is there a fix for CVE-2017-16082? Yes. CVE-2017-16082 is fixed in 2.11.2, 3.6.4, 4.5.7, 5.2.1, 6.0.5, 6.1.6, 6.2.5, 6.3.3, 6.4.2, 7.0.2, 7.1.2. Upgrade to this version or later.
  5. Is CVE-2017-16082 exploitable, and should I be worried? Whether CVE-2017-16082 is exploitable in your environment depends on whether the vulnerable code is present and reachable. A CVSS score is a worst-case rating; it does not account for your specific deployment, configuration, or usage patterns. Kodem, an Intelligent Application Security platform, uses runtime intelligence to show which vulnerabilities actually execute in production, so you can focus on the ones that represent real risk. Get a demo
  6. What actually determines whether CVE-2017-16082 is exploitable, and how bad it is? Exploitability and impact are not fixed properties of a CVE. They depend on runtime truth: whether the vulnerable code is present, reachable, and actually executes in your application. A high CVSS score on a dependency that never runs is not the same as real risk. Kodem, an Intelligent Application Security platform, uses runtime intelligence to reveal which vulnerabilities actually execute in production, so teams prioritize the ones that genuinely matter.
  7. How do I fix CVE-2017-16082?
    • Upgrade pg to 2.11.2 or later
    • Upgrade pg to 3.6.4 or later
    • Upgrade pg to 4.5.7 or later
    • Upgrade pg to 5.2.1 or later
    • Upgrade pg to 6.0.5 or later
    • Upgrade pg to 6.1.6 or later
    • Upgrade pg to 6.2.5 or later
    • Upgrade pg to 6.3.3 or later
    • Upgrade pg to 6.4.2 or later
    • Upgrade pg to 7.0.2 or later
    • Upgrade pg to 7.1.2 or later

Stop the waste.
Protect your environment with Kodem.