Skip to content

Fix pg prototype pollution via server supplied column names#3656

Open
hjr3 wants to merge 2 commits intomasterfrom
fix-pg-prototype-pollution-via-server-supplied-column-names
Open

Fix pg prototype pollution via server supplied column names#3656
hjr3 wants to merge 2 commits intomasterfrom
fix-pg-prototype-pollution-via-server-supplied-column-names

Conversation

@hjr3
Copy link
Copy Markdown
Collaborator

@hjr3 hjr3 commented Apr 13, 2026

No description provided.

@cloudflare-workers-and-pages
Copy link
Copy Markdown

cloudflare-workers-and-pages bot commented Apr 13, 2026

Deploying node-postgres with  Cloudflare Pages  Cloudflare Pages

Latest commit: 81a97db
Status: ✅  Deploy successful!
Preview URL: https://4fd9a90c.node-postgres.pages.dev
Branch Preview URL: https://fix-pg-prototype-pollution-v.node-postgres.pages.dev

View logs

@hjr3 hjr3 self-assigned this Apr 13, 2026
@hjr3 hjr3 force-pushed the fix-pg-prototype-pollution-via-server-supplied-column-names branch 4 times, most recently from 3c11cd8 to f71b55c Compare April 13, 2026 14:01
Comment thread packages/pg/lib/result.js Outdated

parseRow(rowData) {
const row = { ...this._prebuiltEmptyResultObject }
const row = Object.assign(Object.create(null), this._prebuiltEmptyResultObject)
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Backward compat break, and I don’t think it’s necessary as long as _prebuiltEmptyResultObject is built correctly.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, great point. reverted.

Comment thread packages/pg/lib/result.js Outdated
}

this._prebuiltEmptyResultObject = { ...row }
this._prebuiltEmptyResultObject = Object.assign(Object.create(null), row)
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can be reverted, similar to previous comment. Only the initial const row = Object.create(null) is necessary.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

reverted

query.once('row', function (row) {
test('returned right columns', function () {
assert.deepStrictEqual(row, { name: row.name })
assert.deepStrictEqual(Object.keys(row), ['name'])
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

& revert test loosening accordingly

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

for sure. i was fighting with test failures that were not matching my local. i never intended to keep this as-is. reverted

@hjr3 hjr3 force-pushed the fix-pg-prototype-pollution-via-server-supplied-column-names branch from f71b55c to 81a97db Compare April 17, 2026 15:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants