This project contains known security vulnerabilities. Find detailed information at the bottom.

Crate sqlx-core

Dependencies

(64 total, 24 outdated, 1 insecure, 4 possibly insecure)

CrateRequiredLatestStatus
 ahash^0.7.60.8.11out of date
 atoi^1.02.0.0out of date
 base64^0.13.00.22.1out of date
 bigdecimal^0.3.00.4.8out of date
 bit-vec^0.6.30.8.0out of date
 bitflags^1.3.22.9.0out of date
 bstr^0.2.171.12.0out of date
 byteorder^1.4.31.5.0up to date
 bytes^1.1.01.10.1up to date
 chrono ⚠️^0.4.190.4.40maybe insecure
 crc^33.2.1up to date
 crossbeam-queue^0.3.20.3.12up to date
 digest^0.10.00.10.7up to date
 dirs^4.0.06.0.0out of date
 dotenvy^0.150.15.7up to date
 either^1.6.11.15.0up to date
 encoding_rs^0.8.300.8.35up to date
 event-listener^2.5.25.4.0out of date
 flume^0.10.90.11.1out of date
 futures-channel^0.3.190.3.31up to date
 futures-core^0.3.190.3.31up to date
 futures-executor^0.3.190.3.31up to date
 futures-intrusive^0.4.00.5.0out of date
 futures-util^0.3.190.3.31up to date
 generic-array^0.14.41.2.0out of date
 git2^0.140.20.1out of date
 hashlink^0.8.00.10.0out of date
 hex^0.4.30.4.3up to date
 hkdf^0.12.00.12.4up to date
 hmac^0.12.00.12.1up to date
 indexmap^1.6.02.9.0out of date
 ipnetwork^0.19.00.21.1out of date
 itoa^1.0.11.0.15up to date
 libc^0.2.1120.2.171up to date
 libsqlite3-sys ⚠️^0.24.10.32.0out of date
 log^0.4.140.4.27up to date
 mac_address^1.1.21.1.8up to date
 md-5^0.10.00.10.6up to date
 memchr^2.4.12.7.4up to date
 num-bigint^0.4.00.4.6up to date
 once_cell^1.9.01.21.3up to date
 paste^1.0.61.0.15up to date
 percent-encoding^2.1.02.3.1up to date
 rand^0.8.40.9.0out of date
 regex^1.5.51.11.1up to date
 rsa ⚠️^0.6.00.9.8insecure
 rust_decimal^1.19.01.37.1up to date
 rustls ⚠️^0.20.10.23.26out of date
 rustls-pemfile^1.02.2.0out of date
 serde^1.0.1321.0.219up to date
 serde_json^1.0.731.0.140up to date
 sha1^0.10.10.10.6up to date
 sha2^0.10.00.10.8up to date
 smallvec^1.7.01.15.0up to date
 sqlformat^0.2.00.3.5out of date
 sqlx-rt^0.6.20.6.3up to date
 stringprep^0.1.20.1.5up to date
 thiserror^1.0.302.0.12out of date
 time^0.3.20.3.41up to date
 tokio-stream^0.1.80.1.17up to date
 url^2.2.22.5.4up to date
 uuid^1.01.16.0up to date
 webpki-roots^0.22.00.26.8out of date
 whoami ⚠️^1.2.11.6.0maybe insecure

Dev dependencies

(2 total, 1 outdated, 2 possibly insecure)

CrateRequiredLatestStatus
 sqlx ⚠️^0.6.20.8.3out of date
 tokio ⚠️^11.44.2maybe insecure

Security Vulnerabilities

chrono: Potential segfault in `localtime_r` invocations

RUSTSEC-2020-0159

Impact

Unix-like operating systems may segfault due to dereferencing a dangling pointer in specific circumstances. This requires an environment variable to be set in a different thread than the affected functions. This may occur without the user's knowledge, notably in a third-party library.

Workarounds

No workarounds are known.

References

libsqlite3-sys: `libsqlite3-sys` via C SQLite CVE-2022-35737

RUSTSEC-2022-0090

It was sometimes possible for SQLite versions >= 1.0.12, < 3.39.2 to allow an array-bounds overflow when large string were input into SQLite's printf function.

As libsqlite3-sys bundles SQLite, it is susceptible to the vulnerability. libsqlite3-sys was updated to bundle the patched version of SQLite here.

tokio: reject_remote_clients Configuration corruption

RUSTSEC-2023-0001

On Windows, configuring a named pipe server with pipe_mode will force ServerOptions::reject_remote_clients as false.

This drops any intended explicit configuration for the reject_remote_clients that may have been set as true previously.

The default setting of reject_remote_clients is normally true meaning the default is also overridden as false.

Workarounds

Ensure that pipe_mode is set first after initializing a ServerOptions. For example:

let mut opts = ServerOptions::new();
opts.pipe_mode(PipeMode::Message);
opts.reject_remote_clients(true);

rsa: Marvin Attack: potential key recovery through timing sidechannels

RUSTSEC-2023-0071

Impact

Due to a non-constant-time implementation, information about the private key is leaked through timing information which is observable over the network. An attacker may be able to use that information to recover the key.

Patches

No patch is yet available, however work is underway to migrate to a fully constant-time implementation.

Workarounds

The only currently available workaround is to avoid using the rsa crate in settings where attackers are able to observe timing information, e.g. local use on a non-compromised computer is fine.

References

This vulnerability was discovered as part of the "Marvin Attack", which revealed several implementations of RSA including OpenSSL had not properly mitigated timing sidechannel attacks.

whoami: Stack buffer overflow with whoami on several Unix platforms

RUSTSEC-2024-0020

With versions of the whoami crate >= 0.5.3 and < 1.5.0, calling any of these functions leads to an immediate stack buffer overflow on illumos and Solaris:

  • whoami::username
  • whoami::realname
  • whoami::username_os
  • whoami::realname_os

With versions of the whoami crate >= 0.5.3 and < 1.0.1, calling any of the above functions also leads to a stack buffer overflow on these platforms:

  • Bitrig
  • DragonFlyBSD
  • FreeBSD
  • NetBSD
  • OpenBSD

This occurs because of an incorrect definition of the passwd struct on those platforms.

As a result of this issue, denial of service and data corruption have both been observed in the wild. The issue is possibly exploitable as well.

This vulnerability also affects other Unix platforms that aren't Linux or macOS.

This issue has been addressed in whoami 1.5.0.

For more information, see this GitHub issue.

rustls: `rustls::ConnectionCommon::complete_io` could fall into an infinite loop based on network input

RUSTSEC-2024-0336

If a close_notify alert is received during a handshake, complete_io does not terminate.

Callers which do not call complete_io are not affected.

rustls-tokio and rustls-ffi do not call complete_io and are not affected.

rustls::Stream and rustls::StreamOwned types use complete_io and are affected.

sqlx: Binary Protocol Misinterpretation caused by Truncating or Overflowing Casts

RUSTSEC-2024-0363

The following presentation at this year's DEF CON was brought to our attention on the SQLx Discord:

SQL Injection isn't Dead: Smuggling Queries at the Protocol Level
http://web.archive.org/web/20240812130923/https://media.defcon.org/DEF%20CON%2032/DEF%20CON%2032%20presentations/DEF%20CON%2032%20-%20Paul%20Gerste%20-%20SQL%20Injection%20Isn't%20Dead%20Smuggling%20Queries%20at%20the%20Protocol%20Level.pdf
(Archive link for posterity.)

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.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

sqlx 0.8.1 has been released with the fix: https://github.com/launchbadge/sqlx/blob/main/CHANGELOG.md#081---2024-08-23

Postgres users are advised to upgrade ASAP as a possible exploit has been demonstrated: https://github.com/launchbadge/sqlx/issues/3440#issuecomment-2307956901

MySQL and SQLite do not appear to be exploitable, but upgrading is recommended nonetheless.