CVE-2021-38191: Tokio Race Condition Vulnerability
MODERATECVE-2021-38191 is a MODERATE (CVSS 5.9) race condition vulnerability (CWE-366: Race Condition within a Thread) affecting Tokio libraries in the crates.io ecosystem. The issue involves race condition in tokio. Remediation is available by upgrading affected packages to version 1.8.1, 1.7.2, 1.6.3, 1.5.1.
CVE-2021-38191 at a Glance
Security Impact
CVSS: 5.9
The security impact metrics below are parsed directly from the CVSS v3.1 vector string (CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:U/C:N/I:N/A:H).
How to Fix CVE-2021-38191
To remediate this vulnerability, upgrade all affected Tokio dependencies to a patched release. Both direct and transitive dependencies should be checked, as frameworks or security libraries may pull in vulnerable versions transitively.
Upgrade tokio to 1.8.1
Upgrade tokio to 1.7.2
Upgrade tokio to 1.6.3
Upgrade tokio to 1.5.1
Run the following command in your project directory to verify that all resolved dependencies use the patched release:
inspect dependencies for tokio
How to Check if You Are Affected
To determine whether your application is affected by CVE-2021-38191, inspect your project dependencies for Tokio:
inspect dependencies for tokio
Analyze the terminal output to locate any version of Tokio in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than 1.8.1), 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-366: Race Condition within a Thread, where if two threads of execution use a resource simultaneously, there exists the possibility that resources may be used while invalid, in turn making the state of execution undefined. In Tokio, 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
CVE-2021-38191 Affected Tokio Versions
4 component(s)| Product / Package | Ecosystem | Affected Versions | Fixed Version |
|---|---|---|---|
|
tokio
|
crates.io |
≥ 1.8.0
< 1.8.1
|
1.8.1
|
|
tokio
|
crates.io |
≥ 1.7.0
< 1.7.2
|
1.7.2
|
|
tokio
|
crates.io |
≥ 1.6.0
< 1.6.3
|
1.6.3
|
|
tokio
|
crates.io |
≥ 0.3.0
< 1.5.1
|
1.5.1
|
References
Frequently Asked Questions
What is CVE-2021-38191?
Which Tokio versions are affected?
What version fixes CVE-2021-38191?
Is tokio affected?
What is the CVSS score of CVE-2021-38191?
What CWE is associated with CVE-2021-38191?
How can I check crates.io dependencies for CVE-2021-38191?
Machine-readable OSV JSON
OSV v1.5 Schema
{
"schema_version" : "1.4.0",
"id" : "GHSA-2grh-hm3w-w7hv",
"modified" : "2023-06-13T22:08:56Z",
"published" : "2021-08-25T20:55:51Z",
"aliases" : [ "CVE-2021-38191" ],
"summary" : "Race condition in tokio",
"details" : "When aborting a task with JoinHandle::abort, the future is dropped in the thread calling abort if the task is not currently being executed. This is incorrect for tasks spawned on a LocalSet. This can easily result in race conditions as many projects use Rc or RefCell in their Tokio tasks for better performance.",
"severity" : [ {
"type" : "CVSS_V3",
"score" : "CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:U/C:N/I:N/A:H"
} ],
"affected" : [ {
"package" : {
"ecosystem" : "crates.io",
"name" : "tokio"
},
"ranges" : [ {
"type" : "ECOSYSTEM",
"events" : [ {
"introduced" : "1.8.0"
}, {
"fixed" : "1.8.1"
} ]
} ]
}, {
"package" : {
"ecosystem" : "crates.io",
"name" : "tokio"
},
"ranges" : [ {
"type" : "ECOSYSTEM",
"events" : [ {
"introduced" : "1.7.0"
}, {
"fixed" : "1.7.2"
} ]
} ]
}, {
"package" : {
"ecosystem" : "crates.io",
"name" : "tokio"
},
"ranges" : [ {
"type" : "ECOSYSTEM",
"events" : [ {
"introduced" : "1.6.0"
}, {
"fixed" : "1.6.3"
} ]
} ]
}, {
"package" : {
"ecosystem" : "crates.io",
"name" : "tokio"
},
"ranges" : [ {
"type" : "ECOSYSTEM",
"events" : [ {
"introduced" : "0.3.0"
}, {
"fixed" : "1.5.1"
} ]
} ]
} ],
"references" : [ {
"type" : "ADVISORY",
"url" : "https://nvd.nist.gov/vuln/detail/CVE-2021-38191"
}, {
"type" : "WEB",
"url" : "https://github.com/tokio-rs/tokio/issues/3929"
}, {
"type" : "PACKAGE",
"url" : "https://github.com/tokio-rs/tokio"
}, {
"type" : "WEB",
"url" : "https://raw.githubusercontent.com/rustsec/advisory-db/main/crates/tokio/RUSTSEC-2021-0072.md"
}, {
"type" : "WEB",
"url" : "https://rustsec.org/advisories/RUSTSEC-2021-0072.html"
} ],
"database_specific" : {
"cwe_ids" : [ "CWE-362", "CWE-366" ],
"severity" : "MODERATE",
"github_reviewed" : true,
"github_reviewed_at" : "2021-08-18T21:30:23Z",
"nvd_published_at" : "2021-08-08T06:15:00Z"
}
}