CVE-2021-45712
RustEmbed generated `get` method allows for directory traversal when reading files from disk
An issue was discovered in the rust-embed crate before 6.3.0 for Rust. A ../ directory traversal can sometimes occur in debug mode.
Attack profile
How easy it is to exploit
- Attack vector
- Network
- Complexity
- Low
- Privileges needed
- None
- User interaction
- None
What an attacker can affect
- Confidentiality
- High
- Integrity
- None
- Availability
- None
Exploit likelihood
What each source reports
NVD Score used 7.5
An issue was discovered in the rust-embed crate before 6.3.0 for Rust. A ../ directory traversal can sometimes occur in debug mode.
- Record
CVE-2021-45712- CVSS 3.1
- 7.5 High
CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:N/A:N - CVSS 2.0
- 5.0 Medium
AV:N/AC:L/Au:N/C:P/I:N/A:N - Weakness
- CWE-22
- Updated
- 2026-11-02
CVE ListNo score
An issue was discovered in the rust-embed crate before 6.3.0 for Rust. A ../ directory traversal can sometimes occur in debug mode.
- Record
CVE-2021-45712- Updated
- 2026-11-02
EUVDEUVD-2022-0747No score
An issue was discovered in the rust-embed crate before 6.3.0 for Rust. A ../ directory traversal can sometimes occur in debug mode.
- Record
EUVD-2022-0747- Updated
- 2026-11-03
GitHub AdvisoriesGHSA-xrg3-hmf3-rvgw 7.5
Path Traversal in rust-embed
When running in debug mode and the debug-embed (off by default) feature is not enabled, the generated get method does not check that the input path is a child of the folder given.
This allows attackers to read arbitrary files in the file system if they have control over the filename given. The following code will print the contents of your /etc/passwd if adjusted with a correct number of ../s depending on where it is run from.
- Record
GHSA-xrg3-hmf3-rvgw- CVSS 3.1
- 7.5 High
CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:N/A:N - Weakness
- CWE-22
- Updated
- 2026-11-02
GitHub AdvisoriesGHSA-cgw6-f3mj-h742No score
RustEmbed generated `get` method allows for directory traversal when reading files from disk
When running in debug mode and the debug-embed (off by default) feature is
not enabled, the generated get method does not check that the input path is
a child of the folder given.
This allows attackers to read arbitrary files in the file system if they have
control over the filename given. The following code will print the contents of
your /etc/passwd if adjusted with a correct number of ../s depending on
where it is run from.
#[derive(rust_embed::RustEmbed)]
#[folder = "src/"]
pub struct Asset;
fn main() {
let d = Asset::get("../../../etc/passwd").unwrap().data;
println!("{}", String::from_utf8_lossy(&d));
}
The flaw was corrected by canonicalizing the input filename and ensuring that it starts with the canonicalized folder path.
- Record
GHSA-cgw6-f3mj-h742- Weakness
- CWE-22
- Updated
- 2026-11-02
OSVGHSA-xrg3-hmf3-rvgw 7.5
Path Traversal in rust-embed
When running in debug mode and the debug-embed (off by default) feature is not enabled, the generated get method does not check that the input path is a child of the folder given.
This allows attackers to read arbitrary files in the file system if they have control over the filename given. The following code will print the contents of your /etc/passwd if adjusted with a correct number of ../s depending on where it is run from.
- Record
GHSA-xrg3-hmf3-rvgw- CVSS 3.1
- 7.5 High
CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:N/A:N - Weakness
- CWE-22
- Updated
- 2026-11-02
OSVGHSA-cgw6-f3mj-h742No score
RustEmbed generated `get` method allows for directory traversal when reading files from disk
When running in debug mode and the debug-embed (off by default) feature is
not enabled, the generated get method does not check that the input path is
a child of the folder given.
This allows attackers to read arbitrary files in the file system if they have
control over the filename given. The following code will print the contents of
your /etc/passwd if adjusted with a correct number of ../s depending on
where it is run from.
#[derive(rust_embed::RustEmbed)]
#[folder = "src/"]
pub struct Asset;
fn main() {
let d = Asset::get("../../../etc/passwd").unwrap().data;
println!("{}", String::from_utf8_lossy(&d));
}
The flaw was corrected by canonicalizing the input filename and ensuring that it starts with the canonicalized folder path.
- Record
GHSA-cgw6-f3mj-h742- Weakness
- CWE-22
- Updated
- 2026-11-02
OSVRUSTSEC-2021-0126No score
RustEmbed generated `get` method allows for directory traversal when reading files from disk
When running in debug mode and the debug-embed (off by default) feature is
not enabled, the generated get method does not check that the input path is
a child of the folder given.
This allows attackers to read arbitrary files in the file system if they have
control over the filename given. The following code will print the contents of
your /etc/passwd if adjusted with a correct number of ../s depending on
where it is run from.
#[derive(rust_embed::RustEmbed)]
#[folder = "src/"]
pub struct Asset;
fn main() {
let d = Asset::get("../../../etc/passwd").unwrap().data;
println!("{}", String::from_utf8_lossy(&d));
}
The flaw was corrected by canonicalizing the input filename and ensuring that it starts with the canonicalized folder path.
- Record
RUSTSEC-2021-0126- Updated
- 2026-11-02
Affected products
Affected packages
| Package | Affected | Fixed |
|---|---|---|
rust-embedcrates.io | before 6.3.0 | 6.3.0 |
rust-embedcrates.io | 0.0.0-0 up to 6.3.0 | 6.3.0 |
History
| Recorded | Changed | Sources |
|---|---|---|
| aliases | EUVD | |
| first indexed | CVE List, GitHub Advisories, NVD, OSV |
Dates are when Every CVE recorded each change. Upstream dates may differ.
In short
CVE-2021-45712 is a high vulnerability (CVSS 7.5) in Rust-embed Project Rust-embed, published November 29, 2021. No source lists public exploit code. EPSS puts the chance of exploitation in the next 30 days at 1.65%, the 76th percentile. Fixed in rust-embed 6.3.0.
References
rustsec.org/advisories/RUSTSEC-2021-0126.html
raw.githubusercontent.com/rustsec/advisory-db/main/crates/rust-embed/RUSTSEC-2021-0126.md
github.com/pyros2097/rust-embed/issues/159
github.com/advisories/GHSA-cgw6-f3mj-h742
nvd.nist.gov/vuln/detail/CVE-2021-45712
github.com/advisories/GHSA-xrg3-hmf3-rvgw
github.com/pyros2097/rust-embed
crates.io/crates/rust-embed