You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Essentially, encoding a value larger than 4GiB can cause the length prefix in the protocol to overflow,
causing the server to interpret the rest of the string as binary protocol commands or other data.
This code has existed essentially since the beginning,
so it is reasonable to assume that all published versions <= 0.8.0 are affected.
Mitigation
As always, you should make sure your application is validating untrustworthy user input.
Reject any input over 4 GiB, or any input that could encode to a string longer than 4 GiB.
Dynamically built queries are also potentially problematic if it pushes the message size over this 4 GiB bound.
Encode::size_hint()
can be used for sanity checks, but do not assume that the size returned is accurate.
For example, the Json<T> and Text<T> adapters have no reasonable way to predict or estimate the final encoded size,
so they just return size_of::<T>() instead.
For web application backends, consider adding some middleware that limits the size of request bodies by default.
Resolution
Work has started on a branch to add #[deny] directives for the following Clippy lints:
renovateBot
changed the title
chore(deps): update rust crate sqlx to 0.8.1 [security]
chore(deps): update rust crate sqlx to 0.8 [security]
Oct 9, 2024
renovateBot
changed the title
chore(deps): update rust crate sqlx to 0.8 [security]
chore(deps): update rust crate sqlx to 0.8.1 [security]
Oct 9, 2024
renovateBot
changed the title
chore(deps): update rust crate sqlx to 0.8.1 [security]
chore(deps): update rust crate sqlx to 0.8 [security]
Oct 28, 2024
renovateBot
changed the title
chore(deps): update rust crate sqlx to 0.8 [security]
chore(deps): update rust crate sqlx to 0.8.1 [security]
Oct 28, 2024
renovateBot
changed the title
chore(deps): update rust crate sqlx to 0.8.1 [security]
chore(deps): update rust crate sqlx to 0.8 [security]
Oct 30, 2024
renovateBot
changed the title
chore(deps): update rust crate sqlx to 0.8 [security]
chore(deps): update rust crate sqlx to 0.8.1 [security]
Oct 30, 2024
renovateBot
changed the title
chore(deps): update rust crate sqlx to 0.8.1 [security]
chore(deps): update rust crate sqlx to 0.8 [security]
Nov 17, 2024
renovateBot
changed the title
chore(deps): update rust crate sqlx to 0.8 [security]
chore(deps): update rust crate sqlx to 0.8.1 [security]
Nov 17, 2024
renovateBot
changed the title
chore(deps): update rust crate sqlx to 0.8.1 [security]
chore(deps): update rust crate sqlx to 0.8 [security]
Nov 20, 2024
renovateBot
changed the title
chore(deps): update rust crate sqlx to 0.8 [security]
chore(deps): update rust crate sqlx to 0.8.1 [security]
Nov 20, 2024
renovateBot
changed the title
chore(deps): update rust crate sqlx to 0.8.1 [security]
chore(deps): update rust crate sqlx to 0.8 [security]
Dec 2, 2024
renovateBot
changed the title
chore(deps): update rust crate sqlx to 0.8 [security]
chore(deps): update rust crate sqlx to 0.8.1 [security]
Dec 2, 2024
renovateBot
changed the title
chore(deps): update rust crate sqlx to 0.8.1 [security]
chore(deps): update rust crate sqlx to 0.8 [security]
Dec 17, 2024
renovateBot
changed the title
chore(deps): update rust crate sqlx to 0.8 [security]
chore(deps): update rust crate sqlx to 0.8.1 [security]
Dec 17, 2024
renovateBot
changed the title
chore(deps): update rust crate sqlx to 0.8.1 [security]
chore(deps): update rust crate sqlx to 0.8 [security]
Dec 22, 2024
renovateBot
changed the title
chore(deps): update rust crate sqlx to 0.8.1 [security]
chore(deps): update rust crate sqlx to 0.8 [security]
Feb 9, 2025
renovateBot
changed the title
chore(deps): update rust crate sqlx to 0.8 [security]
chore(deps): update rust crate sqlx to 0.8.1 [security]
Feb 9, 2025
renovateBot
changed the title
chore(deps): update rust crate sqlx to 0.8.1 [security]
chore(deps): update rust crate sqlx to 0.8 [security]
Mar 3, 2025
renovateBot
changed the title
chore(deps): update rust crate sqlx to 0.8 [security]
chore(deps): update rust crate sqlx to 0.8.1 [security]
Mar 3, 2025
renovateBot
changed the title
chore(deps): update rust crate sqlx to 0.8.1 [security]
chore(deps): update rust crate sqlx to 0.8 [security]
Mar 11, 2025
renovateBot
changed the title
chore(deps): update rust crate sqlx to 0.8 [security]
chore(deps): update rust crate sqlx to 0.8.1 [security]
Mar 11, 2025
renovateBot
changed the title
chore(deps): update rust crate sqlx to 0.8.1 [security]
chore(deps): update rust crate sqlx to 0.8 [security]
Mar 17, 2025
renovateBot
changed the title
chore(deps): update rust crate sqlx to 0.8 [security]
chore(deps): update rust crate sqlx to 0.8.1 [security]
Mar 17, 2025
renovateBot
changed the title
chore(deps): update rust crate sqlx to 0.8.1 [security]
chore(deps): update rust crate sqlx to 0.8 [security]
Apr 1, 2025
renovateBot
changed the title
chore(deps): update rust crate sqlx to 0.8.1 [security]
chore(deps): update rust crate sqlx to 0.8 [security]
May 7, 2025
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
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.
This PR contains the following updates:
0.7→0.8.1SQLx Binary Protocol Misinterpretation caused by Truncating or Overflowing Casts
GHSA-xmrp-424f-vfpx
More information
Details
The following presentation at this year's DEF CON was brought to our attention on the SQLx Discord:
Essentially, encoding a value larger than 4GiB can cause the length prefix in the protocol to overflow,
causing the server to interpret the rest of the string as binary protocol commands or other data.
It appears SQLx does perform truncating casts in a way that could be problematic,
for example: https://github.com/launchbadge/sqlx/blob/6f2905695b9606b5f51b40ce10af63ac9e696bb8/sqlx-postgres/src/arguments.rs#L163
This code has existed essentially since the beginning,
so it is reasonable to assume that all published versions
<= 0.8.0are affected.Mitigation
As always, you should make sure your application is validating untrustworthy user input.
Reject any input over 4 GiB, or any input that could encode to a string longer than 4 GiB.
Dynamically built queries are also potentially problematic if it pushes the message size over this 4 GiB bound.
Encode::size_hint()can be used for sanity checks, but do not assume that the size returned is accurate.
For example, the
Json<T>andText<T>adapters have no reasonable way to predict or estimate the final encoded size,so they just return
size_of::<T>()instead.For web application backends, consider adding some middleware that limits the size of request bodies by default.
Resolution
Work has started on a branch to add
#[deny]directives for the following Clippy lints:cast_possible_truncationcast_possible_wrapcast_sign_lossand to manually audit the code that they flag.
A fix is expected to be included in the
0.8.1release (still WIP as of writing).Severity
Medium
References
This data is provided by the GitHub Advisory Database (CC-BY 4.0).
Configuration
📅 Schedule: (UTC)
🚦 Automerge: Disabled by config. Please merge this manually once you are satisfied.
♻ Rebasing: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.
🔕 Ignore: Close this PR and you won't be reminded about this update again.
This PR was generated by Mend Renovate. View the repository job log.