Title: [Security] SCRAM-SHA-256 accepts dangerously low iteration count from server · Issue #3655 · brianc/node-postgres · GitHub
Open Graph Title: [Security] SCRAM-SHA-256 accepts dangerously low iteration count from server · Issue #3655 · brianc/node-postgres
X Title: [Security] SCRAM-SHA-256 accepts dangerously low iteration count from server · Issue #3655 · brianc/node-postgres
Description: Split from #3651 as suggested by @charmander. Summary The SCRAM-SHA-256 implementation accepts any iteration count >= 1 from the server. A rogue PostgreSQL server can send a SCRAM challenge with i=1, making the derived key trivially chea...
Open Graph Description: Split from #3651 as suggested by @charmander. Summary The SCRAM-SHA-256 implementation accepts any iteration count >= 1 from the server. A rogue PostgreSQL server can send a SCRAM challenge with i=...
X Description: Split from #3651 as suggested by @charmander. Summary The SCRAM-SHA-256 implementation accepts any iteration count >= 1 from the server. A rogue PostgreSQL server can send a SCRAM challenge with...
Opengraph URL: https://github.com/brianc/node-postgres/issues/3655
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"[Security] SCRAM-SHA-256 accepts dangerously low iteration count from server","articleBody":"Split from #3651 as suggested by @charmander.\n\n## Summary\n\nThe SCRAM-SHA-256 implementation accepts any iteration count \u003e= 1 from the server. A rogue PostgreSQL server can send a SCRAM challenge with `i=1`, making the derived key trivially cheap to brute-force offline.\n\n## Affected code\n\n`packages/pg/lib/crypto/sasl.js` — `parseServerFirstMessage()`:\n\n```js\nconst iterationText = attrPairs.get('i')\nif (!iterationText) {\n throw new Error('SASL: SCRAM-SERVER-FIRST-MESSAGE: iteration missing')\n} else if (!/^[1-9][0-9]*$/.test(iterationText)) {\n throw new Error('SASL: SCRAM-SERVER-FIRST-MESSAGE: invalid iteration count')\n}\nconst iteration = parseInt(iterationText, 10)\n```\n\nThe regex only validates that the iteration count is a positive integer. There is no minimum bound check.\n\n## Threat model\n\nThis is a **rogue server** scenario. If a client connects to a malicious PostgreSQL server, the server controls the SCRAM `ServerFirstMessage` including the iteration count. By setting `i=1`, the server receives the client's SCRAM proof computed with only 1 PBKDF2 iteration. An attacker who captures this exchange can brute-force the password offline at effectively plaintext speed.\n\nRFC 7677 (SCRAM-SHA-256) Section 4 states:\n\u003e the minimum iteration count SHOULD be at least 4096\n\n## Steps to reproduce\n\n1. Set up a mock PostgreSQL server that responds to SCRAM-SHA-256 with `r=\u003cnonce\u003e,s=\u003csalt\u003e,i=1`\n2. Connect a `pg` client with a password\n3. The client completes the SCRAM exchange using only 1 PBKDF2 iteration\n4. The attacker now has a proof derived with 1 iteration — offline brute-force is trivial\n\n## Impact\n\nPassword compromise via offline brute-force after a single observed authentication exchange with a rogue server.\n\n## Suggested fix\n\nEnforce a minimum iteration count in `parseServerFirstMessage()`:\n\n```js\nconst iteration = parseInt(iterationText, 10)\nif (iteration \u003c 4096) {\n throw new Error('SASL: SCRAM-SERVER-FIRST-MESSAGE: iteration count ' + iteration + ' is below minimum 4096')\n}\n```","author":{"url":"https://github.com/eddieran","@type":"Person","name":"eddieran"},"datePublished":"2026-04-13T09:19:15.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":8},"url":"https://github.com/3655/node-postgres/issues/3655"}
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:76b73813-33fa-15d2-a3dd-e0300ae884e9 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | A16C:25435F:80F58F:B5B7CD:6A4BD3FA |
| html-safe-nonce | cb3e635fab697f76f19acdc23e19326535a6278fa54d4fad901f61c9adb6b6d7 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJBMTZDOjI1NDM1Rjo4MEY1OEY6QjVCN0NEOjZBNEJEM0ZBIiwidmlzaXRvcl9pZCI6Ijc3OTQ5NjYyMjQ5NDk3MjgyNTEiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | fca656647ce5fa7d8bbb5fcdfa0731d49ce1d76773dba3538756b21ab02ee71a |
| hovercard-subject-tag | issue:4253074399 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/brianc/node-postgres/3655/issue_layout |
| twitter:image | https://opengraph.githubassets.com/79af174c36011ad8166fba23a5f3ee16c06bb3787cc4c602edfe302948a3f419/brianc/node-postgres/issues/3655 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/79af174c36011ad8166fba23a5f3ee16c06bb3787cc4c602edfe302948a3f419/brianc/node-postgres/issues/3655 |
| og:image:alt | Split from #3651 as suggested by @charmander. Summary The SCRAM-SHA-256 implementation accepts any iteration count >= 1 from the server. A rogue PostgreSQL server can send a SCRAM challenge with i=... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | eddieran |
| hostname | github.com |
| expected-hostname | github.com |
| None | 9df996be9551ac02247d09a2f7f64ece66c35ca28885d346e98fdfda9cdaa37b |
| turbo-cache-control | no-preview |
| go-import | github.com/brianc/node-postgres git https://github.com/brianc/node-postgres.git |
| octolytics-dimension-user_id | 50081 |
| octolytics-dimension-user_login | brianc |
| octolytics-dimension-repository_id | 991475 |
| octolytics-dimension-repository_nwo | brianc/node-postgres |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 991475 |
| octolytics-dimension-repository_network_root_nwo | brianc/node-postgres |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | b71208a1c9ec7ccf364087569d0551f665dda674 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width