Skip to content

RUSTSEC-2026-0135

Unsound transmute while debug/display printing batch Insert statements in Diesel's SQLite backend

Not rated yet crates.io
Severity
Not rated yet
No source has published a CVSS score yet
Exploit chance (EPSS)
—
No score published
Known exploited
No
Not in CISA's catalog
Weakness
—
Not classified
Fix
2.3.8
Upgrade diesel to this version or later

Description

Diesel allows users to output the generated SQL for any query DSL construct via th diesel::debug_query function as Display and Debug output.

For the particular implementation used by batch Insert statements in the SQLite backend Diesel relied on an unspecified transmute between types with a #[repr(rust)] layout. This is formally undefined behaviour as the compiler is free to change the layout of these types at any time.

This vulnerability affects users that print out batch insert statements constructed using an array/vector of values without default values using diesel::debug_query on the SQLite backend.

Mitigation

The preferred mitigation to the outlined problem is to update to Diesel version 2.3.8 or newer, which includes fixes for the problem.

Resolution

Diesel now uses a sound cast instead.

Affected versions

crates.io

PackageVulnerableFixed in
diesel
>= 0.0.0-0, < 2.3.8
2.3.8

How to fix

Move to the fixed version or later with your package manager, update the lockfile, and run your tests. If the package only arrives through another dependency, upgrade that dependency first. If none of its releases pulls a fixed version yet, force the version with your package manager's override.

diesel crates.io → 2.3.8

cargo
cargo update -p diesel --precise 2.3.8

References

Timeline

  1. Published
  2. Last updated by the source
AdvisorySeverityWhy it's related
GHSA-ggxf-9f6j-w742
Diesel has possible use after free when deserializing a SQLite database via `SqliteConnection::deserialize_readonly_database`
Medium Also affects diesel
RUSTSEC-2026-0134
Unsound access to padding bytes while serializing date/time values using the Mysql backend
Not rated yet Also affects diesel
GHSA-m9p2-fxp5-v3fp
Diesel: Command injection in Diesel's implementation of `COPY FROM`/`COPY TO`
Medium Also affects diesel
GHSA-q8x8-jrhj-fh9p
Diesel: Possible unaligned data access for implementations of `SqliteAggregate`
Medium Also affects diesel
GHSA-h5x4-m2qf-r4f2
Diesel's SQLite backend has possible UTF-8 corruption
High Also affects diesel
GHSA-wq9x-qwcq-mmgf
Diesel vulnerable to Binary Protocol Misinterpretation caused by Truncating or Overflowing Casts
High Also affects diesel
RUSTSEC-2021-0037
Fix a use-after-free bug in diesels Sqlite backend
Critical Also affects diesel
Is this in your code?

MergeHarbor checks every repository's dependencies against this database, ranks what matters by exploitability and reachability, routes it to the owning team and opens the fix pull request.

Check your repos with MergeHarbor