CVE-2021-28305
JSON

9.8critical

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

Severity
9.8critical CVSS:3.1 by NVD
Exploit likelihood
1.32% (higher than 71% of CVEs; EPSS, by FIRST)
Published
Last changed
Assigned by
mitre
Also known as
GHSA-j8q9-5rp9-4mv9RUSTSEC-2021-0037

Description

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 sqlite3_column_name are not followed.

Affected

Product or packageVersionsReported by
Unspecified productn/aCVE List
diesel (crates.io)before 1.4.6, from 0.0.0-0 before 1.4.6GitHub Advisory Database, RustSec Advisory Database
diesel dieselbefore 1.4.6NVD

All scores

GitHub9.8critical CVSS:3.1CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H
RustSec Advisory Database9.8critical CVSS:3.1CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H
NVD9.8critical CVSS:3.1CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H
NVD7.5high CVSS:2.0AV:N/AC:L/Au:N/C:P/I:P/A:P

Classification

What each source says

CVE List

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 sqlite3_column_name are not followed.

RustSec Advisory Database

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 sqlite3_finalize() or until the statement is automatically reprepared by the first call to sqlite3_step() for a particular run or until the next call to sqlite3_column_name() or sqlite3_column_name16() 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.

NVD (es)

Se detectó un problema en la crate diesel versiones anteriores a 1.4.6 para Rust. Se presenta un uso de la memoria previamente liberada en el backend de SQLite porque no se sigue la semántica de la función sqlite3_column_name

References

Sources

SourceRecordLicence
CVE ListCVE-2021-28305 changed 2024-08-03CVE Terms of Use
GitHub Advisory DatabaseGHSA-j8q9-5rp9-4mv9 changed 2023-11-08CC-BY-4.0
RustSec Advisory DatabaseRUSTSEC-2021-0037 changed 2023-11-08CC0-1.0
NVDCVE-2021-28305 changed 2026-06-17Public domain