{"id":"CVE-2017-16082","aliases":["DEBIAN-CVE-2017-16082","EUVD-2018-0331","GHSA-wc9v-mj63-m9g5","UBUNTU-CVE-2017-16082"],"status":"published","title":"Remote Code Execution in pg","description":"A remote code execution vulnerability was found within the pg module when the remote database or query specifies a specially crafted column name. There are 2 likely scenarios in which one would likely be vulnerable. 1) Executing unsafe, user-supplied sql which contains a malicious column name. 2) Connecting to an untrusted database and executing a query which returns results where any of the column names are malicious.","severity":{"version":"3.0","score":9.8,"vector":"CVSS:3.0/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H","level":"critical","assessor":"primary","from":"nvd"},"epss":{"day":"2026-11-08","score":0.1045,"percentile":0.95778,"model":"v2026.06.15"},"facts":{"in_kev":false,"known_exploited":false,"public_exploit":true,"fix_available":true},"cwes":["CWE-94"],"published":"2018-06-07T02:00:00Z","modified":"2026-09-01T20:03:45Z","exploits":[{"source":"pocgithub","id":"nulldreams/CVE-2017-16082","title":"nulldreams/CVE-2017-16082","date":"2018-11-27","url":"https://github.com/nulldreams/CVE-2017-16082"}],"fixes":[{"ecosystem":"npm","package":"pg","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"],"sources":["ghsa","osv"]},{"ecosystem":"Debian:12","package":"node-postgres","fixed_in":["7.7.1-1"],"sources":["osv"]},{"ecosystem":"Debian:13","package":"node-postgres","fixed_in":["7.7.1-1"],"sources":["osv"]},{"ecosystem":"Debian:14","package":"node-postgres","fixed_in":["7.7.1-1"],"sources":["osv"]}],"affected":[{"source":"ghsa","ecosystem":"npm","package":"pg","ranges":[{"type":"ECOSYSTEM","events":[{"introduced":"0"},{"fixed":"2.11.2"}]}]},{"source":"ghsa","ecosystem":"npm","package":"pg","ranges":[{"type":"ECOSYSTEM","events":[{"introduced":"3.0.0"},{"fixed":"3.6.4"}]}]},{"source":"ghsa","ecosystem":"npm","package":"pg","ranges":[{"type":"ECOSYSTEM","events":[{"introduced":"4.0.0"},{"fixed":"4.5.7"}]}]},{"source":"ghsa","ecosystem":"npm","package":"pg","ranges":[{"type":"ECOSYSTEM","events":[{"introduced":"5.0.0"},{"fixed":"5.2.1"}]}]},{"source":"ghsa","ecosystem":"npm","package":"pg","ranges":[{"type":"ECOSYSTEM","events":[{"introduced":"6.0.0"},{"fixed":"6.0.5"}]}]},{"source":"ghsa","ecosystem":"npm","package":"pg","ranges":[{"type":"ECOSYSTEM","events":[{"introduced":"6.1.0"},{"fixed":"6.1.6"}]}]},{"source":"ghsa","ecosystem":"npm","package":"pg","ranges":[{"type":"ECOSYSTEM","events":[{"introduced":"6.2.0"},{"fixed":"6.2.5"}]}]},{"source":"ghsa","ecosystem":"npm","package":"pg","ranges":[{"type":"ECOSYSTEM","events":[{"introduced":"6.3.0"},{"fixed":"6.3.3"}]}]},{"source":"ghsa","ecosystem":"npm","package":"pg","ranges":[{"type":"ECOSYSTEM","events":[{"introduced":"6.4.0"},{"fixed":"6.4.2"}]}]},{"source":"ghsa","ecosystem":"npm","package":"pg","ranges":[{"type":"ECOSYSTEM","events":[{"introduced":"7.0.0"},{"fixed":"7.0.2"}]}]},{"source":"ghsa","ecosystem":"npm","package":"pg","ranges":[{"type":"ECOSYSTEM","events":[{"introduced":"7.1.0"},{"fixed":"7.1.2"}]}]},{"source":"osv","ecosystem":"Debian:12","package":"node-postgres","ranges":[{"type":"ECOSYSTEM","events":[{"introduced":"0"},{"fixed":"7.7.1-1"}]}]},{"source":"osv","ecosystem":"Debian:13","package":"node-postgres","ranges":[{"type":"ECOSYSTEM","events":[{"introduced":"0"},{"fixed":"7.7.1-1"}]}]},{"source":"osv","ecosystem":"Debian:14","package":"node-postgres","ranges":[{"type":"ECOSYSTEM","events":[{"introduced":"0"},{"fixed":"7.7.1-1"}]}]},{"source":"osv","ecosystem":"npm","package":"pg","ranges":[{"type":"SEMVER","events":[{"introduced":"0"},{"fixed":"2.11.2"}]}]},{"source":"osv","ecosystem":"npm","package":"pg","ranges":[{"type":"SEMVER","events":[{"introduced":"3.0.0"},{"fixed":"3.6.4"}]}]},{"source":"osv","ecosystem":"npm","package":"pg","ranges":[{"type":"SEMVER","events":[{"introduced":"4.0.0"},{"fixed":"4.5.7"}]}]},{"source":"osv","ecosystem":"npm","package":"pg","ranges":[{"type":"SEMVER","events":[{"introduced":"5.0.0"},{"fixed":"5.2.1"}]}]},{"source":"osv","ecosystem":"npm","package":"pg","ranges":[{"type":"SEMVER","events":[{"introduced":"6.0.0"},{"fixed":"6.0.5"}]}]},{"source":"osv","ecosystem":"npm","package":"pg","ranges":[{"type":"SEMVER","events":[{"introduced":"6.1.0"},{"fixed":"6.1.6"}]}]},{"source":"osv","ecosystem":"npm","package":"pg","ranges":[{"type":"SEMVER","events":[{"introduced":"6.2.0"},{"fixed":"6.2.5"}]}]},{"source":"osv","ecosystem":"npm","package":"pg","ranges":[{"type":"SEMVER","events":[{"introduced":"6.3.0"},{"fixed":"6.3.3"}]}]},{"source":"osv","ecosystem":"npm","package":"pg","ranges":[{"type":"SEMVER","events":[{"introduced":"6.4.0"},{"fixed":"6.4.2"}]}]},{"source":"osv","ecosystem":"npm","package":"pg","ranges":[{"type":"SEMVER","events":[{"introduced":"7.0.0"},{"fixed":"7.0.2"}]}]},{"source":"osv","ecosystem":"npm","package":"pg","ranges":[{"type":"SEMVER","events":[{"introduced":"7.1.0"},{"fixed":"7.1.2"}]}]},{"source":"osv","ecosystem":"Ubuntu:16.04:LTS","package":"node-postgres","ranges":[{"type":"ECOSYSTEM","events":[{"introduced":"0"}]}],"versions":["0.13.3-1"]}],"products":[{"vendor":"hackerone","product":"pg node module"},{"vendor":"node-postgres","product":"pg"}],"references":[{"url":"https://node-postgres.com/announcements#2017-08-12-code-execution-vulnerability","tags":["x_refsource_MISC","x_transferred","Exploit","Third Party Advisory","evidence","web"]},{"url":"https://nodesecurity.io/advisories/521","tags":["x_refsource_MISC","x_transferred","Exploit","Third Party Advisory","evidence","report"]},{"url":"https://nvd.nist.gov/vuln/detail/CVE-2017-16082","tags":["advisory"]},{"url":"https://github.com/advisories/GHSA-wc9v-mj63-m9g5","tags":["advisory"]},{"url":"https://www.npmjs.com/advisories/521","tags":["web"]},{"url":"https://security-tracker.debian.org/tracker/CVE-2017-16082","tags":["advisory"]},{"url":"https://ubuntu.com/security/CVE-2017-16082","tags":["report"]},{"url":"https://www.cve.org/CVERecord?id=CVE-2017-16082","tags":["report"]}],"sources":{"cve":[{"id":"CVE-2017-16082","description":"A remote code execution vulnerability was found within the pg module when the remote database or query specifies a specially crafted column name. There are 2 likely scenarios in which one would likely be vulnerable. 1) Executing unsafe, user-supplied sql which contains a malicious column name. 2) Connecting to an untrusted database and executing a query which returns results where any of the column names are malicious.","status":"published","published":"2018-06-07T02:00:00Z","modified":"2024-09-17T03:49:23.543Z","cwes":["CWE-94"],"updated_at":"2026-11-02T14:33:21.453505Z"}],"euvd":[{"id":"EUVD-2018-0331","description":"A remote code execution vulnerability was found within the pg module when the remote database or query specifies a specially crafted column name. There are 2 likely scenarios in which one would likely be vulnerable. 1) Executing unsafe, user-supplied sql which contains a malicious column name. 2) Connecting to an untrusted database and executing a query which returns results where any of the column names are malicious.","status":"published","published":"2018-06-07T02:00:00Z","modified":"2024-09-17T03:49:23Z","updated_at":"2026-11-03T00:28:28.016201Z"}],"ghsa":[{"id":"GHSA-wc9v-mj63-m9g5","title":"Remote Code Execution in pg","description":"Affected versions of `pg` contain a remote code execution vulnerability that occurs when the remote database or query specifies a crafted column name. \n\nThere are two specific scenarios in which it is likely for an application to be vulnerable:\n1. The application executes unsafe, user-supplied sql which contains malicious column names.\n2. The application connects to an untrusted database and executes a query returning results which contain a malicious column name.\n\n## Proof of Concept\n```\nconst { Client } = require('pg')\nconst client = new Client()\nclient.connect()\n\nconst sql = `SELECT 1 AS \"\\\\'/*\", 2 AS \"\\\\'*/\\n + console.log(process.env)] = null;\\n//\"`\n\nclient.query(sql, (err, res) =\u003e {\n  client.end()\n})\n```\n\n\n## Recommendation\n\n* Version 2.x.x: Update to version 2.11.2 or later.\n* Version 3.x.x: Update to version 3.6.4 or later.\n* Version 4.x.x: Update to version 4.5.7 or later.\n* Version 5.x.x: Update to version 5.2.1 or later.\n* 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. )\n* Version 7.x.x: Update to version 7.1.2 or later. ( Note that version 7.0.2 is also patched. )","status":"published","published":"2018-07-24T19:44:42Z","modified":"2023-09-11T18:31:11Z","cvss":[{"version":"3.0","score":9.8,"vector":"CVSS:3.0/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H","level":"critical"}],"cwes":["CWE-94"],"updated_at":"2026-11-02T14:37:03.916765Z"}],"nvd":[{"id":"CVE-2017-16082","description":"A remote code execution vulnerability was found within the pg module when the remote database or query specifies a specially crafted column name. There are 2 likely scenarios in which one would likely be vulnerable. 1) Executing unsafe, user-supplied sql which contains a malicious column name. 2) Connecting to an untrusted database and executing a query which returns results where any of the column names are malicious.","status":"published","published":"2018-06-07T02:29:01.393Z","modified":"2026-06-17T01:08:46.077Z","cvss":[{"version":"3.0","score":9.8,"vector":"CVSS:3.0/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H","level":"critical","assessor":"primary"},{"version":"2.0","score":7.5,"vector":"AV:N/AC:L/Au:N/C:P/I:P/A:P","level":"high","assessor":"primary"}],"cwes":["CWE-94"],"updated_at":"2026-11-02T14:04:17.638656Z"}],"osv":[{"id":"CVE-2017-16082","description":"A remote code execution vulnerability was found within the pg module when the remote database or query specifies a specially crafted column name. There are 2 likely scenarios in which one would likely be vulnerable. 1) Executing unsafe, user-supplied sql which contains a malicious column name. 2) Connecting to an untrusted database and executing a query which returns results where any of the column names are malicious.","status":"published","published":"2018-06-07T02:29:01.393Z","modified":"2026-03-14T09:22:24.942195Z","cvss":[{"version":"3.0","score":9.8,"vector":"CVSS:3.0/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H","level":"critical"}],"updated_at":"2026-11-02T15:44:04.853379Z"},{"id":"DEBIAN-CVE-2017-16082","description":"A remote code execution vulnerability was found within the pg module when the remote database or query specifies a specially crafted column name. There are 2 likely scenarios in which one would likely be vulnerable. 1) Executing unsafe, user-supplied sql which contains a malicious column name. 2) Connecting to an untrusted database and executing a query which returns results where any of the column names are malicious.","status":"published","published":"2018-06-07T02:29:01.393Z","modified":"2026-09-01T20:03:45.538352866Z","cvss":[{"version":"3.0","score":9.8,"vector":"CVSS:3.0/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H","level":"critical"}],"updated_at":"2026-11-02T15:45:28.801885Z"},{"id":"GHSA-wc9v-mj63-m9g5","title":"Remote Code Execution in pg","description":"Affected versions of `pg` contain a remote code execution vulnerability that occurs when the remote database or query specifies a crafted column name. \n\nThere are two specific scenarios in which it is likely for an application to be vulnerable:\n1. The application executes unsafe, user-supplied sql which contains malicious column names.\n2. The application connects to an untrusted database and executes a query returning results which contain a malicious column name.\n\n## Proof of Concept\n```\nconst { Client } = require('pg')\nconst client = new Client()\nclient.connect()\n\nconst sql = `SELECT 1 AS \"\\\\'/*\", 2 AS \"\\\\'*/\\n + console.log(process.env)] = null;\\n//\"`\n\nclient.query(sql, (err, res) =\u003e {\n  client.end()\n})\n```\n\n\n## Recommendation\n\n* Version 2.x.x: Update to version 2.11.2 or later.\n* Version 3.x.x: Update to version 3.6.4 or later.\n* Version 4.x.x: Update to version 4.5.7 or later.\n* Version 5.x.x: Update to version 5.2.1 or later.\n* 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. )\n* Version 7.x.x: Update to version 7.1.2 or later. ( Note that version 7.0.2 is also patched. )","status":"published","published":"2018-07-24T19:44:42Z","modified":"2023-11-08T03:59:03.759366Z","cvss":[{"version":"3.0","score":9.8,"vector":"CVSS:3.0/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H","level":"critical"}],"cwes":["CWE-94"],"updated_at":"2026-11-02T15:46:58.401149Z"},{"id":"UBUNTU-CVE-2017-16082","description":"A remote code execution vulnerability was found within the pg module when the remote database or query specifies a specially crafted column name. There are 2 likely scenarios in which one would likely be vulnerable. 1) Executing unsafe, user-supplied sql which contains a malicious column name. 2) Connecting to an untrusted database and executing a query which returns results where any of the column names are malicious.","status":"published","published":"2018-06-07T02:29:00Z","modified":"2025-10-24T04:46:34Z","cvss":[{"version":"3.0","score":9.8,"vector":"CVSS:3.0/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H","level":"critical"}],"updated_at":"2026-11-02T15:54:14.563448Z"}]}}
