Every CVESearch/Get API key

CVE-2021-45712

RustEmbed generated `get` method allows for directory traversal when reading files from disk

7.5 HighFix available

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

1.65%Up 1.0 points since Dec 27, 2021
90%50%10%1%

What each source reports

NVD Score used7.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 HighCVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:N/A:N
CVSS 2.0
5.0 MediumAV: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-rvgw7.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 HighCVSS: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-rvgw7.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 HighCVSS: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

Affected packages
PackageAffectedFixed
rust-embed
crates.io
before 6.3.0
6.3.0
rust-embed
crates.io
0.0.0-0 up to 6.3.0
6.3.0

History

History
RecordedChangedSources
aliasesEUVD
first indexedCVE 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

MoveEnter Open