Security hardening#1364
Merged
Merged
Conversation
HstoreEntries::next read a server-supplied key/value length and called the panicking slice::split_at without checking it against the remaining buffer, so a malicious server could crash the client (DoS) with an hstore value whose declared length exceeds the bytes present. Use split_at_checked and return an error instead, matching the array and range decoders.
…olumns Row/SimpleQueryRow validated the requested index against the RowDescription column count but indexed the ranges vector built from the DataRow field count, which the server controls independently. A DataRow with fewer fields than advertised columns made get/try_get (and a plain 0..row.len() loop) panic with an out-of-bounds index. Validate the two counts match when the row is built so the mismatch surfaces as a recoverable error instead.
The time 0.2 FromSql impls for Date/PrimitiveDateTime/OffsetDateTime added the server-supplied value to the 2000-01-01 epoch with the plain + operator, which panics when the result falls outside time's representable year range (-100_000..=100_000). A server-sent (or merely far-future) DATE/TIMESTAMP could therefore crash the client. time 0.2 has no checked_add, so validate the resulting Julian day against the representable range first, mirroring the checked_add the time 0.3 impls already use.
The PBKDF2 iteration count in the SCRAM server-first message is server-controlled and was passed to hi() unbounded, so a malicious or impersonating server could send i=4294967295 and force the client to run billions of HMAC-SHA256 operations inline on the connect path before authentication completes. Reject any iteration count above 100_000 before computing the salted password — ~24x the PostgreSQL default of 4096, matching the cap pgjdbc adopted for CVE-2026-42198.
The generated FromSql for a composite struct assigned each field from an Option populated by matching server-reported field names, then unwrapped them. A server reporting a duplicate field name (accepted by accepts(), which only checks every reported name matches some field) leaves another field unset, so the unwrap panicked. Use ok_or(..)? so a malformed composite returns a decode error rather than crashing the caller.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The SCRAM issue was originally reported by the security team at the University of Sydney.
The rest was found with Fable.