GHSA-ggxf-9f6j-w742: Diesel :deserialize_readonly_database` Vulnerability

MODERATE
CWE-416
Published
Advisory Summary

GHSA-ggxf-9f6j-w742 is a MODERATE :deserialize_readonly_database` vulnerability (CWE-416: Use After Free) affecting Diesel libraries in the crates.io ecosystem. The issue involves :deserialize_readonly_database`. Remediation is available by upgrading affected packages to version 2.3.10.

GHSA-ggxf-9f6j-w742 at a Glance

CVE Identifier N/A
GHSA Identifier GHSA-ggxf-9f6j-w742
Severity MODERATE
CVSS v3.1 Base Score N/A
CWE Classification CWE-416: Use After Free
Affected Product Diesel
Package Ecosystem crates.io
Published Date
Last Updated

How to Fix GHSA-ggxf-9f6j-w742

To remediate this vulnerability, upgrade all affected Diesel dependencies to a patched release. Both direct and transitive dependencies should be checked, as frameworks or security libraries may pull in vulnerable versions transitively.

diesel fixed: 2.3.10
Upgrade diesel to 2.3.10
Verify Direct and Transitive Dependencies

Run the following command in your project directory to verify that all resolved dependencies use the patched release:

inspect dependencies for diesel

How to Check if You Are Affected

To determine whether your application is affected by GHSA-ggxf-9f6j-w742, inspect your project dependencies for Diesel:

inspect dependencies for diesel

Analyze the terminal output to locate any version of Diesel in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than 2.3.10), your application is affected.

Note: Verify declared build manifests and deployed runtime container environments.

Technical Details

Vulnerability Mechanism & Technical Analysis

This vulnerability is classified under CWE-416: Use After Free, where the product reuses or references memory after it has been freed. at some point afterward, the memory may be allocated again and saved in another pointer, while the original pointer references a location somewhere within the new allocation. any operations using the original pointer are no longer valid because the memory "belongs" to the code that operates on the new pointer. In Diesel, software state validation or input boundaries are circumvented during processing. Review the official source advisory statement below for specific affected components, classes, and reproduction details.

Source Advisory Statement

Diesel allows loading a SQLite database from a byte buffer, represented as `&[u8]`, at runtime via the `SqliteConnection::deserialize_readonly_database` function. In previous versions of Diesel, this buffer was passed directly to libsqlite3. Since libsqlite3 requires the buffer to remain alive for as long as the database connection is open and Diesel did not ensure this as part of its safe API, callers of `SqliteConnection::deserialize_readonly_database` could drop the buffer prematurely. This prematurely drop caused libsqlite3 to operate on freed memory. This vulnerability affects users of `SqliteConnection::deserialize_readonly_database` who drop the buffer passed to the function before they drop the database connection. ## Mitigation The preferred mitigation to the outlined problem is to update to Diesel version 2.3.10 or newer, which includes a fix for the problem. Alternatively users need to take to keep the buffer alive until the connection is dropped. ## Resolution Diesel now stores a copy of the buffer inside of the `SqliteConnection` object itself to keep it alive as long as the underlying libsqlite3 connection exists.

GHSA-ggxf-9f6j-w742 Affected Diesel Versions

1 component(s)
Fixed Versions:
2.3.10
Product / Package Ecosystem Affected Versions Fixed Version
diesel
crates.io
< 2.3.10
2.3.10

References

Frequently Asked Questions

What is GHSA-ggxf-9f6j-w742?
GHSA-ggxf-9f6j-w742 is a security vulnerability in Diesel involving :deserialize_readonly_database` under CWE-416: Use After Free.
Which Diesel versions are affected?
Affected versions include releases prior to 2.3.10 across affected packages: diesel.
What version fixes GHSA-ggxf-9f6j-w742?
Upgrading to 2.3.10 (or the latest patched release for your respective branch) resolves the vulnerability.
Is diesel affected?
Yes, diesel is affected in releases prior to 2.3.10. Upgrade your dependency to 2.3.10 or later.
What CWE is associated with GHSA-ggxf-9f6j-w742?
GHSA-ggxf-9f6j-w742 is classified under CWE-416: Use After Free (The product reuses or references memory after it has been freed. At some point afterward, the memory may be allocated again and saved in another pointer, while the original pointer references a location somewhere within the new allocation. Any operations using the original pointer are no longer valid because the memory "belongs" to the code that operates on the new pointer.).
How can I check crates.io dependencies for GHSA-ggxf-9f6j-w742?
Run the dependency tree command: 'inspect dependencies for diesel'. This command lists direct and transitive dependencies in your build configuration so you can verify if a vulnerable version is resolved.
Machine-readable OSV JSON OSV v1.5 Schema
Normalized schema output
{
  "schema_version" : "1.4.0",
  "id" : "GHSA-ggxf-9f6j-w742",
  "modified" : "2026-07-16T19:25:25Z",
  "published" : "2026-07-16T19:25:25Z",
  "aliases" : [ ],
  "summary" : "Diesel has possible use after free when deserializing a SQLite database via `SqliteConnection::deserialize_readonly_database`",
  "details" : "Diesel allows loading a SQLite database from a byte buffer, represented as `&[u8]`, at runtime via the `SqliteConnection::deserialize_readonly_database` function. In previous versions of Diesel, this buffer was passed directly to libsqlite3. Since libsqlite3 requires the buffer to remain alive for as long as the database connection is open and Diesel did not ensure this as part of its safe API, callers of `SqliteConnection::deserialize_readonly_database` could drop the buffer prematurely. This prematurely drop caused libsqlite3 to operate on freed memory.\n\nThis vulnerability affects users of `SqliteConnection::deserialize_readonly_database` who drop the buffer passed to the function before they drop the database connection.\n\n## Mitigation\n\nThe preferred mitigation to the outlined problem is to update to Diesel version 2.3.10 or newer, which includes a fix for the problem. Alternatively users need to take to keep the buffer alive until the connection is dropped.\n\n## Resolution\n\nDiesel now stores a copy of the buffer inside of the `SqliteConnection` object itself to keep it alive as long as the underlying libsqlite3 connection exists.",
  "severity" : [ {
    "type" : "CVSS_V4",
    "score" : "CVSS:4.0/AV:N/AC:L/AT:N/PR:N/UI:N/VC:N/VI:L/VA:L/SC:N/SI:N/SA:N"
  } ],
  "affected" : [ {
    "package" : {
      "ecosystem" : "crates.io",
      "name" : "diesel"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0"
      }, {
        "fixed" : "2.3.10"
      } ]
    } ]
  } ],
  "references" : [ {
    "type" : "WEB",
    "url" : "https://github.com/diesel-rs/diesel/commit/1bc2ea46d9840e8d9af844239d3c84f37fe7d84b"
  }, {
    "type" : "PACKAGE",
    "url" : "https://github.com/diesel-rs/diesel"
  }, {
    "type" : "WEB",
    "url" : "https://rustsec.org/advisories/RUSTSEC-2026-0172.html"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-416" ],
    "severity" : "MODERATE",
    "github_reviewed" : true,
    "github_reviewed_at" : "2026-07-16T19:25:25Z",
    "nvd_published_at" : null
  }
}