GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — [Security] Prototype pollution via server-supplied column names in result rows · Issue #3654 · brianc/node-postgres

[Security] Prototype pollution via server-supplied column names in result rows #3654

New issue
Copy link
New issue
Copy link
Closed
Closed
[Security] Prototype pollution via server-supplied column names in result rows#3654
Copy link
Assignees
hjr3
Labels
bug

Description

@eddieran
eddieran
opened on Apr 13, 2026
Issue body actions

Split from #3651 as suggested by @charmander.

Summary

When a PostgreSQL server returns column names like __proto__, constructor, or toString, these are used as object keys in result rows without any sanitization. A rogue or compromised PostgreSQL server can exploit this to pollute Object.prototype on the client.

Affected code

packages/pg/lib/result.js — both addFields() and parseRow():

// addFields() builds the pre-built empty result object:
const row = {}
for (let i = 0; i < fieldDescriptions.length; i++) {
  const desc = fieldDescriptions[i]
  row[desc.name] = null  // desc.name comes from server
}
this._prebuiltEmptyResultObject = { ...row }

// parseRow() assigns parsed values using server-supplied field names:
parseRow(rowData) {
  const row = { ...this._prebuiltEmptyResultObject }
  for (let i = 0, len = rowData.length; i < len; i++) {
    const field = this.fields[i].name  // server-controlled
    row[field] = this._parsers[i](v)   // value also server-controlled
  }
  return row
}

Threat model

This is a rogue server scenario, not a trusted-config issue. If a client connects to a malicious PostgreSQL server (e.g. via DNS hijack, MITM without TLS verification, or a compromised host), the server controls the column names in RowDescription messages. A column named __proto__ with a crafted value can pollute the prototype chain of all objects in the Node.js process.

Steps to reproduce

  1. Set up a mock PostgreSQL server that returns a RowDescription with a field named __proto__ and a DataRow with the value {"polluted": true} (as a JSON/text column)
  2. Connect a pg client to this server and execute any query
  3. After the result is parsed, check ({}).polluted — it will be true

Impact

  • Denial of service (crash or undefined behavior in downstream code)
  • Potential RCE depending on how the application uses objects after pollution

Suggested fix

Use Object.create(null) instead of {} for result rows, or reject/rename column names that collide with Object.prototype properties:

const row = Object.create(null)

Activity

  1. hjr3
    added a commit that references this issue on Apr 13, 2026

    fix(pg): prototype pollution via server-supplied column names

    This issue will close once commit 035fd44 is merged into the 'master' branch.
    035fd44
  2. hjr3
    self-assigned this
    on Apr 13, 2026
  3. hjr3
    added 4 commits that reference this issue on Apr 13, 2026

    fix(pg): prototype pollution via server-supplied column names

    This issue will close once commit 213795a is merged into the 'master' branch.
    213795a

    fix(pg): prototype pollution via server-supplied column names

    This issue will close once commit 3055476 is merged into the 'master' branch.
    3055476

    fix(pg): prototype pollution via server-supplied column names

    This issue will close once commit 3c11cd8 is merged into the 'master' branch.
    3c11cd8

    fix(pg): prototype pollution via server-supplied column names

    This issue will close once commit f71b55c is merged into the 'master' branch.
    f71b55c
  4. charmander
    added
    bug
    on Apr 14, 2026
  5. hjr3
    added a commit that references this issue on Apr 17, 2026

    fix(pg): prototype pollution via server-supplied column names

    This issue will close once commit 81a97db is merged into the 'master' branch.
    81a97db
  6. brianc
    closed this as completedin 7674d8con May 11, 2026
  7. brianc
    added a commit that references this issue on May 11, 2026

    Fix pg prototype pollution via server supplied column names (brianc#3656

    This issue will close once commit 7674d8c is merged into the 'master' branch.
    7674d8c
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

  • @hjr3
    hjr3

Labels

bug

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

    You are visitor 01402775 — GeezerVison does not store the pages you look up.
    Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.