Update Rust crate sqlx to 0.8.1 [SECURITY] #17
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.6.3
->0.8.1
GitHub Vulnerability Alerts
GHSA-xmrp-424f-vfpx
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.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>
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_truncation
cast_possible_wrap
cast_sign_loss
and to manually audit the code that they flag.
A fix is expected to be included in the
0.8.1
release (still WIP as of writing).Release Notes
launchbadge/sqlx (sqlx)
v0.8.1
Compare Source
16 pull requests were merged this release cycle.
This release contains a fix for RUSTSEC-2024-0363.
Postgres users are advised to upgrade ASAP as a possible exploit has been demonstrated:
#3440 (comment)
MySQL and SQLite do not appear to be exploitable, but upgrading is recommended nonetheless.
Added
MySqlConnectOptions::no_engine_substitution()
[[@kolinfluence]]MySqlConnectOptions::no_engine_subsitution()
(oops) in favor of the correctly spelled version.Changed
spec_error
module [[@abonander]]Use at your own risk.
libsqlite3-sys=0.30.1
to support sqlite 3.46 [[@CommanderStorm]]ring
(the existing implementation),and
aws-lc-rs
which has optional FIPS certification.runtime-tokio-rustls
,runtime-async-std-rustls
,tls-rustls
)enable the
ring
provider of RusTLS to match the existing behavior so this should not be a breaking change.tls-rustls-aws-lc-rs
feature to use theaws-lc-rs
provider.runtime-tokio-rustls
orruntime-async-std-rustls
,this will necessitate switching to the appropriate non-legacy runtime feature:
runtime-tokio
orruntime-async-std
Fixed
sqlx::Type
[[@alu]]node12
inSQLx
action [[@hamirmahal]]v0.18.1
to avoid yankedv0.14.3
[[@CommanderStorm]]v0.8.0
Compare Source
70 pull requests were merged this release cycle.
#2697 was merged the same day as release 0.7.4 and so was missed by the automatic CHANGELOG generation.
Breaking
#[sqlx::test]
usages are applied in the correct order now.MigrateError
.-- no-transaction
to the beginning.Migration
i64
as intermediate when decoding [[@abonander]]#[derive(sqlx::Type)]
in Postgres [[@abonander]]#[sqlx(no_pg_array)]
where conflicts occur.PgTypeInfo::with_name()
infers types that start with_
to be arrays of the un-prefixed type. Wrap type names in quotes to bypass this behavior.FromRow
, returnError::ColumnDecode
forTryFrom
errors [[@abonander]]#[sqlx(try_from = "T")]
now returnError::ColumnDecode
instead ofError::ColumnNotFound
.#[sqlx(default)]
on an individual field or the struct itself would have previously suppressed the error.This doesn't seem like good behavior as it could result in some potentially very difficult bugs.
From
and apply the default explicitly.#[sqlx(rename)]
and#[sqlx(rename_all)]
to match the expected behavior (rename
wins).ConnectOptions::to_url_lossy()
to match what parsing expects.Added
MySqlTime
, auditmysql::types
for panics [[@abonander]]NonZero*
scalar types [[@AlphaKeks]]Changed
Send
trait bound from argument binding [[@bobozaur]]libsqlite3-sys
are not considered breaking changes as per our semver guarantees.MySqlConnection
to reduce sizes of futures [[@stepantubanov]]sqlx migrate add ...
[[@CommanderStorm]]Fixed
ConnectionHandleRaw
type [[@abonander]]docker compose
instead ofdocker-compose
[[@abonander]]path
ownership problems when usingsqlx_macros_unstable
[[@lily-mosquitoes]]sqlx_postgres::any
[[@Zarathustra2]]migrate
error message. (#3275) [[@nk9]]persistent
query setting when preparing queries with theAny
driver [[@etorreborre]]select_input_type!()
being unhygenic [[@CommanderStorm]]M
orC
Notice fields are not UTF-8 [[@YgorSouza]]json
-feature should activatesqlx-postgres?/json
as well [[@CommanderStorm]]clock
andstd
features ofworkspace.dependencies.chrono
.v0.7.4
Compare Source
38 pull requests were merged this release cycle.
This is officially the last release of the 0.7.x release cycle.
As of this release, development of 0.8.0 has begun on
main
and only high-priority bugfixes may be backported.Added
to_url_lossy
to connect options [[@lily-mosquitoes]]query!
for cargo-free systems [[@kshramt]]raw_sql
API [[@abonander]]prepared statement interfaces
query*()
andquery!()
.query*()
functions.execute_many()
andfetch_many()
on interfaces that use prepared statements.interface is the only way to execute SQL. All other database flavors forbid multiple statements in
one prepared statement string as an extra defense against SQL injection.
raw_sql
API retains this functionality because it explicitly does not use prepared statements.Raw or text-mode query interfaces generally allow multiple statements in one query string, and this is
supported by all current databases. Due to their nature, however, one cannot use bind parameters with them.
Changed
create_new
instead ofatomic-file-write
[[@mattfbacon]]PgConnectOptions
[[@Fyko]]#[sqlx::test]
[[@ciffelia]]Fixed
sqlx::migrate::Migrator
.migrate!()
.v0.7.3
38 pull requests were merged this release cycle.
Added
fixtures_path
in sqlx::test args [[@ripa1995]]fn PgConnectOptions::get_host(&self)
[[@boris-lok]]FromRow
for the unit type [[@nanoqsh]]MySqlConnectOptions::get_database()
[[@shiftrightonce]]Text
adapter [[@abonander]]Changed
BOOLEAN
and the query macros [[@abonander]]NUMERIC
support [[@abonander]]libsqlite3-sys
to 0.27.0libsqlite3-sys
is considered semver-exempt;see the release notes for 0.7.0 below for details.
Fixed
rust_decimal::Decimal
for high-precision values [[@abonander]]sqlx migrate add
help text [[@cryeprecision]]try_stream!()
[[@abonander]]cargo build
[[@nyurik]]AtomicUsize
for thread IDs [[@abonander]]v0.7.2
23 pull requests were merged this release cycle.
Added
FromRow
derive [[@95ulisse]]Type
,Decode
, andEncode
forBox<str>
andBox<[u8]>
[[@grant0417]]Changed
remove_dir_all
crate fromsqlx-cli
, fixes RUSTSEC-2023-0018 [[@aldur]]Fixed
min_connections
[[@hakoerber]]v0.7.1
Compare Source
This release mainly addresses issues reported with the 0.7.0 release.
16 pull requests were merged this release cycle.
Added
PgHasArrayType
with#[derive(sqlx::Type)]
[[@abonander]]#[derive(sqlx::Type)]
with#[sqlx(transparent)]
regarding
PgHasArrayType
not being implemented, add#[sqlx(no_pg_array)]
to fix.Changed
Fixed
Clone
forPoolOptions
manually (#2548) [[@alilleybrinker]]tls-native-tls
in the documentation. [[@denschub]]v0.7.0
Compare Source
At least 70 pull requests were merged this release cycle! (The exact count is muddied with pull requests for alpha
releases and such.) And we gained 43 new contributors! Thank you to everyone who helped make this release a reality.
Breaking
Many revisions were made to query analysis in the SQLite driver; these are all potentially breaking changes
as they can change the output of
sqlx::query!()
et al. We'd like to thank [[@tyrelr]] for their numerous PRs tothis area.
The MSSQL driver has been removed as it was not nearly at the same maturity level as the other drivers.
[As previously announced][sqlx-pro], we have plans to introduce a fully featured replacement as a premium offering,
alongside drivers for other proprietary databases, with the goal to support full-time development on SQLx.
If interested, please email your inquiry to [email protected].
The offline mode for the queries has been changed to use a separate file per
query!()
invocation,which is intended to reduce the number of conflicts when merging branches in a project that both modified queries.
This means that CLI flag
--merged
is no longer supported. See [[#2363]] for details and make sure that yoursqlx-cli
version is in sync with thesqlx
version in your project.The type ascription override syntax for the query macros has been deprecated,
as parse support for it has been removed in
syn 2.0
, which we'll be upgrading to in the next breaking release.This can be replaced with type overrides using casting syntax (
as
).See [[#2483]] for details.
mssql
feature and associated database driver has been deleted from the source tree. It will return as part of our planned SQLx Pro offering as a from-scratch rewrite with extra features (such as TLS) and type integrations that were previously missing.runtime-actix-*
features have been deleted. They were previously changed to be aliases of theirruntime-tokio-*
counterparts for backwards compatibility reasons, but their continued existence is misleading as SQLx has no special knowledge of Actix anymore.runtime-actix-*
feature with itsruntime-tokio-*
equivalent.git2
feature has been removed. This was a requested integration from a while ago that over time made less and less sense to be part of SQLx itself. We have to be careful with the crates we add to our public API as each one introduces yet another semver hazard. The expected replacement is to make#[derive(sqlx::Type)]
useful enough that users can write wrapper types for whatever they want to use without SQLx needing to be specifically aware of it.Executor
impls forTransaction
andPoolConnection
have been deleted because they cannot exist in the new crate architecture without rewriting theExecutor
trait entirely.impl Executor
is expected, as they both dereference to the inner connection type which will still implement it:&mut transaction
->&mut *transaction
&mut connection
->&mut *connection
the driver crates cannot provide their own impls due to the orphan rule.
This will mean another major release of SQLx but ideally most API usage will not need to change significantly, if at all.
Migrator
are now#[doc(hidden)]
and semver-exempt; they weren't meant to be public.offline
feature has been removed from thesqlx
facade crate and is enabled unconditionally as most users are expected to have enabled it anyway and disabling it doesn't seem to appreciably affect compile times.decimal
feature has been renamed torust_decimal
to match the crate it actually provides integrations for.AnyDriver
andAnyConnection
now require eithersqlx::any::install_drivers()
orsqlx::any::install_default_drivers()
to be called at some point during the process' lifetime before the first connection is made, as the set of possible drivers is now determined at runtime. This was determined to be the least painful way to provide knowledge of database drivers toAny
without them being hardcoded.AnyEncode
trait has been removed.libsqlite3-sys
to be semver-exempt,and we reserve the right to upgrade it as necessary. If you are using
libsqlite3-sys
directly or a crate thatlinks it such as
rusqlite
, you should pin the versions of both crates to avoid breakages fromcargo update
:time
: Assume UTC when decoding aConfiguration
📅 Schedule: Branch creation - "" (UTC), Automerge - At any time (no schedule defined).
🚦 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.