Binary Protocol Misinterpretation caused by Truncating or Overflowing Casts Affecting sqlx package, versions <0.8.1
Do your applications use this vulnerable package?
In a few clicks we can analyze your entire application and see what components are vulnerable in your application, and suggest you quick fixes.
Test your applications- Snyk ID SNYK-RUST-SQLX-7707749
- published 18 Aug 2024
- disclosed 15 Aug 2024
- credit Unknown
How to fix?
Upgrade sqlx
to version 0.8.1 or higher.
Overview
Affected versions of this package are vulnerable to Binary Protocol Misinterpretation caused by Truncating or Overflowing Casts due to the improper handling of encoding values larger than 4GiB, which can cause the length prefix in the protocol to overflow. An attacker can manipulate the server into interpreting the rest of the string as binary protocol commands or other data by sending specially crafted input that exceeds this size limit.
Mititgation
This vulnerability can be mitigated by rejecting any input over 4 GiB, or any input that could encode to a string longer than 4 GiB. Also, Encode::size_hint()
can be used for sanity checks, but implementing middleware to limit the size of request bodies is recommended.