RUSTSEC-2021-0037

Source
https://rustsec.org/advisories/RUSTSEC-2021-0037
Import Source
https://github.com/rustsec/advisory-db/blob/osv/crates/RUSTSEC-2021-0037.json
JSON Data
https://api.osv.dev/v1/vulns/RUSTSEC-2021-0037
Aliases
Published
2021-03-05T12:00:00Z
Modified
2023-11-08T04:05:29.499484Z
Severity
  • 9.8 (Critical) CVSS_V3 - CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H CVSS Calculator
Summary
Fix a use-after-free bug in diesels Sqlite backend
Details

We've misused sqlite3_column_name. The SQLite documentation states that the following:

The returned string pointer is valid until either the prepared statement is destroyed by sqlite3finalize() or until the statement is automatically reprepared by the first call to sqlite3step() for a particular run or until the next call to sqlite3columnname() or sqlite3columnname16() on the same column.

As part of our query_by_name infrastructure we've first received all field names for the prepared statement and stored them as string slices for later use. After that we called sqlite3_step() for the first time, which invalids the pointer and therefore the stored string slice.

Database specific
{
    "license": "CC0-1.0"
}
References

Affected packages

crates.io / diesel

Package

Affected ranges

Type
SEMVER
Events
Introduced
0.0.0-0
Fixed
1.4.6

Ecosystem specific

{
    "affected_functions": null,
    "affects": {
        "os": [],
        "functions": [
            "diesel::SqliteConnection::query_by_name"
        ],
        "arch": []
    }
}

Database specific

{
    "cvss": "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H",
    "informational": null,
    "categories": [
        "memory-corruption"
    ]
}