5.3medium
Segmentation fault in Rust time crate
- Severity
- 5.3medium CVSS:3.1 by GitHub_M
- Exploit likelihood
- 2.00% (higher than 81% of CVEs; EPSS, by FIRST)
- Published
- Last changed
- Assigned by
- GitHub_M
- Also known as
- GHSA-wcg3-cvx6-7396RUSTSEC-2020-0071
Description
In Rust time crate from version 0.2.7 and before version 0.2.23, unix-like operating systems may segfault due to dereferencing a dangling pointer in specific circumstances. This requires the user to set any environment variable in a different thread than the affected functions. The affected functions are time::UtcOffset::local_offset_at, time::UtcOffset::try_local_offset_at, time::UtcOffset::current_local_offset, time::UtcOffset::try_current_local_offset, time::OffsetDateTime::now_local and time::OffsetDateTime::try_now_local. Non-Unix targets are unaffected. This includes Windows and wasm. The issue was introduced in version 0.2.7 and fixed in version 0.2.23.
Affected
| Product or package | Versions | Reported by |
|---|---|---|
| time-rs time | >= 0.2.7, <0.2.23 | CVE List |
| time (crates.io) | from 0.1.0 before 0.2.23, from 0.2.7 before 0.2.23, from 0.0.0-0 before 0.2.0, from 0.2.1-0 before 0.2.1, from 0.2.2-0 before 0.2.2, from 0.2.3-0 before 0.2.3, from 0.2.4-0 before 0.2.4, from 0.2.5-0 before 0.2.5 and 2 more | GitHub Advisory Database, RustSec Advisory Database |
| time_project time | from 0.2.7 before 0.2.23 | NVD |
All scores
| GitHub_M | 5.3medium CVSS:3.1 | CVSS:3.1/AV:N/AC:H/PR:L/UI:N/S:U/C:N/I:N/A:H |
| GitHub | 6.2medium CVSS:3.1 | CVSS:3.1/AV:L/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H |
| RustSec Advisory Database | 6.2medium CVSS:3.1 | CVSS:3.1/AV:L/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H |
| NVD | 5.3medium CVSS:3.1 | CVSS:3.1/AV:N/AC:H/PR:L/UI:N/S:U/C:N/I:N/A:H |
| NVD | 3.5low CVSS:2.0 | AV:N/AC:M/Au:S/C:N/I:N/A:P |
Classification
What each source says
CVE List
In Rust time crate from version 0.2.7 and before version 0.2.23, unix-like operating systems may segfault due to dereferencing a dangling pointer in specific circumstances. This requires the user to set any environment variable in a different thread than the affected functions. The affected functions are time::UtcOffset::local_offset_at, time::UtcOffset::try_local_offset_at, time::UtcOffset::current_local_offset, time::UtcOffset::try_current_local_offset, time::OffsetDateTime::now_local and time::OffsetDateTime::try_now_local. Non-Unix targets are unaffected. This includes Windows and wasm. The issue was introduced in version 0.2.7 and fixed in version 0.2.23.
GitHub Advisory Database
Impact
Unix-like operating systems may segfault due to dereferencing a dangling pointer in specific circumstances. This requires an environment variable to be set in a different thread than the affected functions. This may occur without the user's knowledge, notably in a third-party library.
The affected functions from time 0.2.7 through 0.2.22 are:
time::UtcOffset::local_offset_attime::UtcOffset::try_local_offset_attime::UtcOffset::current_local_offsettime::UtcOffset::try_current_local_offsettime::OffsetDateTime::now_localtime::OffsetDateTime::try_now_local
The affected functions in time 0.1 (all versions) are:
atat_utcnow
Non-Unix targets (including Windows and wasm) are unaffected.
Patches
In some versions of time, the internal method that determines the local offset has been modified to always return None on the affected operating systems. This has the effect of returning an Err on the try_* methods and UTC on the non-try_* methods. In later versions, time will attempt to determine the number of threads running in the process. If the process is single-threaded, the call will proceed as its safety invariant is upheld.
Users and library authors with time in their dependency tree must perform cargo update, which will pull in the updated, unaffected code.
Users of time 0.1 do not have a patch and must upgrade to an unaffected version: time 0.2.23 or greater or the 0.3 series.
Workarounds
Library authors must ensure that the program only has one running thread at the time of calling any affected method. Binary authors may do the same and/or ensure that no other thread is actively mutating the environment.
References
RustSec Advisory Database
Impact
The affected functions set environment variables without synchronization. On Unix-like operating systems, this can crash in multithreaded programs. Programs may segfault due to dereferencing a dangling pointer if an environment variable is read in a different thread than the affected functions. This may occur without the user's knowledge, notably in the Rust standard library or third-party libraries.
The affected functions from time 0.2.7 through 0.2.22 are:
time::UtcOffset::local_offset_attime::UtcOffset::try_local_offset_attime::UtcOffset::current_local_offsettime::UtcOffset::try_current_local_offsettime::OffsetDateTime::now_localtime::OffsetDateTime::try_now_local
The affected functions in time 0.1 (all versions) are:
time::at_utctime::attime::nowtime::tzset
Non-Unix targets (including Windows and wasm) are unaffected.
Patches
Pending a proper fix, the internal method that determines the local offset has been modified to always return None on the affected operating systems. This has the effect of returning an Err on the try_* methods and UTC on the non-try_* methods.
Users and library authors with time in their dependency tree should perform cargo update, which will pull in the updated, unaffected code.
Users of time 0.1 do not have a patch and should upgrade to an unaffected version: time 0.2.23 or greater or the 0.3 series.
Workarounds
A possible workaround for crates affected through the transitive dependency in chrono, is to avoid using the default oldtime feature dependency of the chrono crate by disabling its default-features and manually specifying the required features instead.
Examples:
Cargo.toml:
chrono = { version = "0.4", default-features = false, features = ["serde"] }
chrono = { version = "0.4.22", default-features = false, features = ["clock"] }
Commandline:
cargo add chrono --no-default-features -F clock
Sources:
NVD (es)
En el crate time de Rust desde la versión 0.2.7 y anterior a versión 0.2.23, los sistemas operativos tipo Unix pueden segregarse debido a la desreferenciación de un puntero colgante en circunstancias específicas. Esto requiere que el usuario configure cualquier variable de entorno en un hilo diferente al de las funciones afectadas. Las funciones afectadas son time::UtcOffset::local_offset_at, time::UtcOffset::try_local_offset_at, time::UtcOffset::current_local_offset, time::UtcOffset::try_current_local_offset, time::OffsetDateTime::now_local y time::OffsetDateTime::try_now_local. Los objetivos que no son Unix no están afectados. Esto incluye Windows y wasm. El problema se introdujo en la versión 0.2.7 y se corrigió en la versión 0.2.23
References
| https://github.com/time-rs/time/security/advisories/GHSA-wcg3-cvx6-7396 | patch, third-party-advisory, web | |
| https://github.com/time-rs/time/issues/293 | issue-tracking, report, third-party-advisory, web | |
| https://crates.io/crates/time/0.2.23 | release-notes, vendor-advisory, web | |
| https://nvd.nist.gov/vuln/detail/CVE-2020-26235 | advisory | |
| https://github.com/time-rs/time | package | |
| https://rustsec.org/advisories/RUSTSEC-2020-0071.html | advisory, web | |
| https://crates.io/crates/time | package | |
Related
Sources
| Source | Record | Licence |
|---|---|---|
| CVE List | CVE-2020-26235 changed 2024-08-04 | CVE Terms of Use |
| GitHub Advisory Database | GHSA-wcg3-cvx6-7396 changed 2026-09-10 | CC-BY-4.0 |
| RustSec Advisory Database | RUSTSEC-2020-0071 changed 2026-02-04 | CC0-1.0 |
| NVD | CVE-2020-26235 changed 2026-06-17 | Public domain |