# Diesel use after free in SqliteConnection deserialize_readonly_database

Source: https://junglewise.ai/threats/diesel-use-after-free-in-sqliteconnection-deserialize-readonly-database-dadf7b98  
Publisher: Junglewise Threat Intelligence, https://junglewise.ai/threats  
Published: 2026-07-16. Updated: 2026-07-16  
License: CC BY 4.0 with a link back

Severity: medium · CVSS 6.9 · Published 2026-07-16

Diesel, a popular database toolkit for the Rust programming language, contains a memory safety flaw when loading SQLite databases from memory. An application using this specific feature could crash or behave unpredictably if the memory buffer containing the database is cleared while the connection is still active. This could lead to service instability or potential data corruption in affected applications.

Technologies: [diesel (crates.io)](https://junglewise.ai/threats/technologies/diesel). Vendors: [crates.io](https://junglewise.ai/threats/vendors/crates-io).

## Quick answers

**Is This vulnerability exploited in the wild?** No. Junglewise Threat Intelligence has no report of This vulnerability being exploited in the wild.

**How severe is This vulnerability?** Medium severity, with a CVSS score of 6.9, published 16 July 2026.

**Which products and versions are affected?** diesel (crates.io) < 2.3.10.

**Is there a fix for This vulnerability?** A patch was published on 2026-07-16: Version 2.3.10 released Junglewise finds every place you run it, drafts the upgrade and applies it once you approve.

**How is This vulnerability attacked?** It is attacked over the network, in a software library.

**Am I affected?** Check whether you run diesel (crates.io) at an affected version. Junglewise does that check for you around the clock: connect your code, cloud and domains, and it matches new vulnerabilities like this one against what you actually run and tells you when one reaches you.

## Technical details

A use-after-free vulnerability exists in Diesel's SQLite backend due to improper lifetime management of memory buffers. When using `SqliteConnection::deserialize_readonly_database`, Diesel passed a byte slice (`&[u8]`) directly to `libsqlite3` without ensuring the buffer's lifetime matched the connection's lifetime. If a caller drops the buffer while the connection remains open, `libsqlite3` may attempt to access freed memory. This is reachable if an attacker can influence the data or timing of database deserialization in an application. The issue is resolved in version 2.3.10 by having `SqliteConnection` take ownership of a copy of the buffer.

## Affected products

- diesel-rs diesel < 2.3.10

## Timeline

- 2026-06-05: disclosed: Reported via RustSec
- 2026-07-16: advisory: GitHub Advisory published
- 2026-07-16: patched: Version 2.3.10 released

## References

- [https://github.com/diesel-rs/diesel/commit/1bc2ea46d9840e8d9af844239d3c84f37fe7d84b](https://github.com/diesel-rs/diesel/commit/1bc2ea46d9840e8d9af844239d3c84f37fe7d84b)
- [https://rustsec.org/advisories/RUSTSEC-2026-0172.html](https://rustsec.org/advisories/RUSTSEC-2026-0172.html)

## Related threats

- [RUSTSEC-2026-0172 - Possible use after free when deserializing a SQLite database via…](https://junglewise.ai/threats/rustsec-2026-0172-possible-use-after-free-when-deserializing-a-sqlite-3bbb802d)
- [Diesel argument injection in PostgreSQL COPY FROM and COPY TO](https://junglewise.ai/threats/diesel-argument-injection-in-postgresql-copy-from-and-copy-to-1fd3966b)
- [Diesel unaligned data access in SqliteAggregate](https://junglewise.ai/threats/diesel-unaligned-data-access-in-sqliteaggregate-27fb382f)
- [Diesel SQLite backend UTF-8 corruption in deserialization](https://junglewise.ai/threats/diesel-sqlite-backend-utf-8-corruption-in-deserialization-42824b77)
- [RUSTSEC-2026-0136 - Command injection in Diesel's implementation of `COPY FROM`/`COPY TO`](https://junglewise.ai/threats/rustsec-2026-0136-command-injection-in-diesel-s-implementation-of-copy-1779c5a9)
