Skip to content

← Public intelligence

crates.io package

diesel

Open actionable advisories and recorded vendor fixes. This public package view has no inventory attached and cannot establish whether your deployment is affected. A vendor fix never resolves your finding; verify your installed version and the source guidance.

Open advisories

6 actionable advisories, newest first. Withdrawn advisories and news are excluded. Coverage is partial.

  1. Medium, CVSS 6.9crates.ioPublished

    Diesel has possible use after free when deserializing a SQLite database via SqliteConnection::deserialize_readonly_database

    GHSA-ggxf-9f6j-w742

    Affected
    • crates.io diesel < 2.3.10
    Fixed in
    2.3.10· Vendor fix available
    Issue
    Diesel allows loading a SQLite database from a byte buffer, represented as &[u8], at runtime via the SqliteConnection::deserializereadonlydatabase 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::deserializereadonlydatabase could drop the buffer prematurely. This prematurely drop caused libsqlite3 to operate on freed memory. This vulnerability affects users of SqliteConnection::deserializereadonlydatabase 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…

    Recommended action: Upgrade to 2.3.10 or later, then redeploy and verify.A vendor fix does not resolve your finding until you verify it in your own systems.

    Sources:github.comSource checked Evidence →
  2. Medium, CVSS 6.9crates.ioPublished

    Diesel: Command injection in Diesel's implementation of COPY FROM/COPY TO

    GHSA-m9p2-fxp5-v3fp

    Affected
    • crates.io diesel < 2.3.8
    Fixed in
    2.3.8· Vendor fix available
    Issue
    Diesel allows users to configure various options for PostgreSQL's COPY FROM and COPY TO statements. These configurations are partially provided as strings or characters. Diesel did not check if any these user-provided options contain a quote character ', which can lead to the injection of additional options in the current COPY FROM/COPY TO statement. This vulnerability affects any user of COPY FROM/COPY TO that passes user-provided input to any of the affected functions. It can result in modifications of options in the current statement, but it is not possible inject additional statements. 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 correctly escapes any quotes contained in the provided arguments.

    Recommended action: Upgrade to 2.3.8 or later, then redeploy and verify.A vendor fix does not resolve your finding until you verify it in your own systems.

    Sources:github.comSource checked Evidence →
  3. Medium, CVSS 6.3crates.ioPublished

    Diesel: Possible unaligned data access for implementations of SqliteAggregate

    GHSA-q8x8-jrhj-fh9p

    Affected
    • crates.io diesel < 2.3.8
    Fixed in
    2.3.8· Vendor fix available
    Issue
    Diesel allows to register custom aggregate SQL functions for SQLite via the SqliteAggregate interface. To store an instance of the custom aggregate processor Diesel relied on the sqlite3aggregatecontext function provided by sqlite. This function doesn't provide any guarantees about alignment of the returned allocation, which in turn can lead to problems if the type implementing requires a special alignment, e.g. via a custom #[align(x)] attribute on the type implementing this trait. This affects any user of SqliteAggregate that registers the custom aggregate function with an SQLite connection, while using a non-standard alignment on the type implementing this trait. Mitigation The preferred mitigation to the outlined problem is to update to a Diesel version 2.3.8 or newer, which includes fixes for the problem. Resolution Diesel now allocates the corresponding memory on Rust side to get a correctly aligned allocation.

    Recommended action: Upgrade to 2.3.8 or later, then redeploy and verify.A vendor fix does not resolve your finding until you verify it in your own systems.

    Sources:github.comSource checked Evidence →
  4. High, CVSS 8.7crates.ioPublished

    Diesel's SQLite backend has possible UTF-8 corruption

    GHSA-h5x4-m2qf-r4f2

    Affected
    • crates.io diesel < 2.3.8
    Fixed in
    2.3.8· Vendor fix available
    Issue
    Diesel uses the sqlite3valuetext function to receive strings from SQLite while deserializing query results. We misinterpreted the corresponding SQLite documentation that this function always returns a UTF-8 encoded string values as const cchar. Based on that we used str::fromutf8unchecked to construct a Rust string slice without any additional UTF-8 checks in place. It turned out that this function doesn't always return correct UTF-8 strings. For field of the SQLite side storage type BLOB this pointer can contain arbitrary bytes, which makes the usage of str::fromutf8unchecked unsound as this violates the safety contract of str to only contain valid UTF-8 encoded Strings. Mitigation The preferred mitigation to the outlined problem is to update to a Diesel version 2.3.8 or newer, which includes fixes for the problem. Resolution Diesel now correctly checks whether the provides byte buffer is actually valid UTF-8, instead of relying on SQLite's documentation. This fix is included in the…

    Recommended action: Upgrade to 2.3.8 or later, then redeploy and verify.A vendor fix does not resolve your finding until you verify it in your own systems.

    Sources:github.comSource checked Evidence →
  5. High, CVSS 8.9crates.ioPublished

    Diesel vulnerable to Binary Protocol Misinterpretation caused by Truncating or Overflowing Casts

    GHSA-wq9x-qwcq-mmgf

    Affected
    • crates.io diesel < 2.2.3
    Fixed in
    2.2.3· Vendor fix available
    Issue
    The following presentation at this year's DEF CON was brought to our attention on the Diesel Gitter Channel: 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 Diesel does perform truncating casts in a way that could be problematic, for example: <https://github.com/diesel-rs/diesel/blob/ae82c4a5a133db65612b7436356f549bfecda1c7/diesel/src/pg/connection/stmt/mod.rs#L36 This code has existed essentially since the beginning, so it is reasonable to assume that all published versions <= 2.2.2 are…

    Recommended action: Upgrade to 2.2.3 or later, then redeploy and verify.A vendor fix does not resolve your finding until you verify it in your own systems.

    Sources:github.comSource checked Evidence →
  6. Critical, CVSS 9.8crates.ioPublished

    Fix a use-after-free bug in diesels Sqlite backend

    CVE-2021-28305 · GHSA-j8q9-5rp9-4mv9

    Affected
    • crates.io diesel < 1.4.6
    Fixed in
    1.4.6· Vendor fix available
    Issue
    An issue was discovered in the diesel crate before 1.4.6 for Rust. There is a use-after-free in the SQLite backend because the semantics of sqlite3columnname are not followed.

    Recommended action: Upgrade to 1.4.6 or later, then redeploy and verify.A vendor fix does not resolve your finding until you verify it in your own systems.

    Sources:github.comSource checked Evidence →