Remote Code Execution Vulnerability in node-postgres

node-postgres Updated 02 Oct 2025

Summary

07/06/2018
N/A
Yes i
Critical
9.8

CVE-2017-16082: A remote code execution vulnerability was found within the pg module when the remote database or query specifies a specially crafted column name. Affects node-postgres versions < 7.7.1-1. Fixed in 7.7.1-1. How to fix ↓

Free scan

Check if this vulnerability affects your application

Upload a manifest or SBOM and we'll show whether you're affected, plus every other risky package in the same scan.

Check my app free

No signup required · Results in about 60 seconds

Upload your dependency manifest or SBOM

Drag & drop your file here or

Java Javascript PHP Python Go Rust Ruby Dart C/C++ Elixir CycloneDX SPDX

Upload a supported dependency manifest or SBOM. No installation or source-code access required.

See supported files and SBOM formats
SBOM sbom.json · bom.json · bom.xml · *.spdx.json · *.cdx.json · *.cdx.xml
Java pom.xml · gradle.lockfile · buildscript-gradle.lockfile
Javascript package-lock.json · yarn.lock · pnpm-lock.yaml
PHP composer.lock
Python poetry.lock · requirements.txt · Pipfile.lock
Go go.mod
Rust Cargo.lock
Ruby Gemfile.lock
Dart pubspec.lock
C/C++ conan.lock
Elixir mix.lock
Enter your work email to receive your report link.

Verify your email to view the full report and start 30 days of continuous monitoring. No credit card required.

Sponsored Lume, the Habilume companion Habilume Habit tracker with a companion that grows with you Complete habits, earn Lume Points, and watch your Lume grow as you stay consistent. App Store Google Play

Background

node-postgres is a package used for connecting to PostgreSQL databases from Node.js applications. It provides a simple and efficient way to interact with the database, allowing developers to execute queries and retrieve results. However, a vulnerability has been discovered in the package that can lead to remote code execution.

Vulnerability Detail

The vulnerability, identified as CVE-2017-16082, allows an attacker to execute arbitrary code on the server hosting the PostgreSQL database. This can occur when the remote database or query specifies a specially crafted column name. There are two likely scenarios in which one would be vulnerable: 1) Executing unsafe, user-supplied SQL that contains a malicious column name, and 2) Connecting to an untrusted database and executing a query that returns results with any malicious column names. The impact of this vulnerability can be severe, as it enables an attacker to execute arbitrary code with the privileges of the database user.

How To Fix

Minimum fixed version

7.7.1-1

This is the first release that contains the fix.

sudo apt-get install --only-upgrade node-postgres

Tip — Not sure which version your app runs? Vulert can match this fix to it. Scan free →

Workaround

If updating the package is not immediately feasible, a possible workaround is to sanitize user-supplied SQL queries and ensure that only trusted column names are used. This can help mitigate the risk of executing malicious code. Here is an example of how to sanitize a query using the pg module:

const { Client } = require('pg');

const client = new Client();

const query = `SELECT * FROM table WHERE ${sanitize(columnName)} = $1`;

client.query(query, [value]);

Conclusion

The remote code execution vulnerability in node-postgres can have severe consequences, allowing an attacker to execute arbitrary code on the server. It is crucial to update the package to the latest version and sanitize user-supplied SQL queries to mitigate the risk. For further support on vulnerability remediation, contact DevNack.com.

See every vulnerability recorded for node-postgres →

Share this vulnerability

FAQ

node-postgres is a package that allows Node.js applications to connect to PostgreSQL databases and interact with them.

The vulnerability occurs when a remote database or query specifies a specially crafted column name, allowing an attacker to execute arbitrary code.

The vulnerability can lead to remote code execution, enabling an attacker to execute arbitrary code on the server hosting the PostgreSQL database.

To fix the vulnerability, update the node-postgres package to version 7.7.1-1 or later.

If updating the package is not immediately feasible, you can sanitize user-supplied SQL queries to mitigate the risk of executing malicious code.

Related vulnerabilities

Recent vulnerabilities recorded for node-postgres.

Sponsored Lume, the Habilume companion Habilume Habit tracker with a companion that grows with you Complete habits, earn Lume Points, and watch your Lume grow as you stay consistent. App Store Google Play

How To Fix

Minimum fixed version

7.7.1-1

This is the first release that contains the fix.

sudo apt-get install --only-upgrade node-postgres

Tip — Not sure which version your app runs? Vulert can match this fix to it. Scan free →

Subscribe to Vulert on Telegram
Daily digest of new CVEs, critical and high severity, affected packages and fixes — plus a weekly roundup.
Join the channel →
Help improve this record
Report an issue or send feedback