{"id":"CVE-2021-45712","aliases":["EUVD-2022-0747","GHSA-cgw6-f3mj-h742","GHSA-xrg3-hmf3-rvgw","RUSTSEC-2021-0126"],"status":"published","title":"RustEmbed generated `get` method allows for directory traversal when reading files from disk","description":"An issue was discovered in the rust-embed crate before 6.3.0 for Rust. A ../ directory traversal can sometimes occur in debug mode.","severity":{"version":"3.1","score":7.5,"vector":"CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:N/A:N","level":"high","assessor":"primary","from":"nvd"},"epss":{"day":"2026-11-11","score":0.01645,"percentile":0.76768,"model":"v2026.06.15"},"facts":{"in_kev":false,"known_exploited":false,"public_exploit":false,"fix_available":true},"cwes":["CWE-22"],"published":"2021-11-29T12:00:00Z","modified":"2026-06-17T04:13:59Z","fixes":[{"ecosystem":"crates.io","package":"rust-embed","fixed_in":["6.3.0"],"sources":["ghsa","osv"]}],"affected":[{"source":"ghsa","ecosystem":"crates.io","package":"rust-embed","ranges":[{"type":"ECOSYSTEM","events":[{"introduced":"0"},{"fixed":"6.3.0"}]}]},{"source":"ghsa","ecosystem":"crates.io","package":"rust-embed","ranges":[{"type":"ECOSYSTEM","events":[{"introduced":"0"},{"fixed":"6.3.0"}]}]},{"source":"osv","ecosystem":"crates.io","package":"rust-embed","ranges":[{"type":"SEMVER","events":[{"introduced":"0"},{"fixed":"6.3.0"}]}]},{"source":"osv","ecosystem":"crates.io","package":"rust-embed","ranges":[{"type":"SEMVER","events":[{"introduced":"0"},{"fixed":"6.3.0"}]}]},{"source":"osv","ecosystem":"crates.io","package":"rust-embed","ranges":[{"type":"SEMVER","events":[{"introduced":"0.0.0-0"},{"fixed":"6.3.0"}]}]}],"products":[{"vendor":"rust-embed_project","product":"rust-embed"}],"references":[{"url":"https://rustsec.org/advisories/RUSTSEC-2021-0126.html","tags":["x_refsource_MISC","x_transferred","Exploit","Issue Tracking","Third Party Advisory","web","advisory"]},{"url":"https://raw.githubusercontent.com/rustsec/advisory-db/main/crates/rust-embed/RUSTSEC-2021-0126.md","tags":["x_refsource_MISC","x_transferred","Exploit","Third Party Advisory","web"]},{"url":"https://github.com/pyros2097/rust-embed/issues/159","tags":["web","report"]},{"url":"https://github.com/advisories/GHSA-cgw6-f3mj-h742"},{"url":"https://nvd.nist.gov/vuln/detail/CVE-2021-45712","tags":["advisory"]},{"url":"https://github.com/advisories/GHSA-xrg3-hmf3-rvgw"},{"url":"https://github.com/pyros2097/rust-embed","tags":["package"]},{"url":"https://crates.io/crates/rust-embed","tags":["package"]}],"sources":{"cve":[{"id":"CVE-2021-45712","description":"An issue was discovered in the rust-embed crate before 6.3.0 for Rust. A ../ directory traversal can sometimes occur in debug mode.","status":"published","published":"2021-12-26T21:46:50Z","modified":"2024-08-04T04:47:02.168Z","updated_at":"2026-11-02T14:33:02.930115Z"}],"euvd":[{"id":"EUVD-2022-0747","description":"An issue was discovered in the rust-embed crate before 6.3.0 for Rust. A ../ directory traversal can sometimes occur in debug mode.","status":"published","published":"2021-12-26T21:46:50Z","modified":"2024-08-04T04:47:02Z","updated_at":"2026-11-03T03:08:25.77408Z"}],"ghsa":[{"id":"GHSA-xrg3-hmf3-rvgw","title":"Path Traversal in rust-embed","description":"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.\n\nThis 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.","status":"published","published":"2022-01-06T22:03:56Z","modified":"2023-06-13T20:41:58Z","cvss":[{"version":"3.1","score":7.5,"vector":"CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:N/A:N","level":"high"}],"cwes":["CWE-22"],"updated_at":"2026-11-02T14:36:54.225318Z"},{"id":"GHSA-cgw6-f3mj-h742","title":"RustEmbed generated `get` method allows for directory traversal when reading files from disk","description":"When running in debug mode and the `debug-embed` (off by default) feature is\nnot enabled, the generated `get` method does not check that the input path is\na child of the folder given. \n\nThis allows attackers to read arbitrary files in the file system if they have\ncontrol over the filename given. The following code will print the contents of\nyour `/etc/passwd` if adjusted with a correct number of `../`s depending on\nwhere it is run from.\n\n```rust\n#[derive(rust_embed::RustEmbed)]\n#[folder = \"src/\"]\npub struct Asset;\n\nfn main() {\n    let d = Asset::get(\"../../../etc/passwd\").unwrap().data;\n    println!(\"{}\", String::from_utf8_lossy(\u0026d));\n}\n```\n\nThe flaw was corrected by canonicalizing the input filename and ensuring that\nit starts with the canonicalized folder path.\n","status":"published","published":"2022-06-17T00:18:08Z","modified":"2023-01-12T05:01:09Z","cwes":["CWE-22"],"updated_at":"2026-11-02T14:36:13.23016Z"}],"nvd":[{"id":"CVE-2021-45712","description":"An issue was discovered in the rust-embed crate before 6.3.0 for Rust. A ../ directory traversal can sometimes occur in debug mode.","status":"published","published":"2021-12-26T22:15:09.047Z","modified":"2026-06-17T04:13:59.977Z","cvss":[{"version":"3.1","score":7.5,"vector":"CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:N/A:N","level":"high","assessor":"primary"},{"version":"2.0","score":5,"vector":"AV:N/AC:L/Au:N/C:P/I:N/A:N","level":"medium","assessor":"primary"}],"cwes":["CWE-22"],"updated_at":"2026-11-02T14:07:02.977492Z"}],"osv":[{"id":"GHSA-xrg3-hmf3-rvgw","title":"Path Traversal in rust-embed","description":"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.\n\nThis 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.","status":"published","published":"2022-01-06T22:03:56Z","modified":"2023-11-08T04:07:23.363783Z","cvss":[{"version":"3.1","score":7.5,"vector":"CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:N/A:N","level":"high"}],"cwes":["CWE-22"],"updated_at":"2026-11-02T15:47:00.198893Z"},{"id":"GHSA-cgw6-f3mj-h742","title":"RustEmbed generated `get` method allows for directory traversal when reading files from disk","description":"When running in debug mode and the `debug-embed` (off by default) feature is\nnot enabled, the generated `get` method does not check that the input path is\na child of the folder given. \n\nThis allows attackers to read arbitrary files in the file system if they have\ncontrol over the filename given. The following code will print the contents of\nyour `/etc/passwd` if adjusted with a correct number of `../`s depending on\nwhere it is run from.\n\n```rust\n#[derive(rust_embed::RustEmbed)]\n#[folder = \"src/\"]\npub struct Asset;\n\nfn main() {\n    let d = Asset::get(\"../../../etc/passwd\").unwrap().data;\n    println!(\"{}\", String::from_utf8_lossy(\u0026d));\n}\n```\n\nThe flaw was corrected by canonicalizing the input filename and ensuring that\nit starts with the canonicalized folder path.\n","status":"published","published":"2022-06-17T00:18:08Z","modified":"2023-11-08T04:07:23.363783Z","cwes":["CWE-22"],"updated_at":"2026-11-02T15:46:44.927642Z"},{"id":"RUSTSEC-2021-0126","title":"RustEmbed generated `get` method allows for directory traversal when reading files from disk","description":"When running in debug mode and the `debug-embed` (off by default) feature is\nnot enabled, the generated `get` method does not check that the input path is\na child of the folder given. \n\nThis allows attackers to read arbitrary files in the file system if they have\ncontrol over the filename given. The following code will print the contents of\nyour `/etc/passwd` if adjusted with a correct number of `../`s depending on\nwhere it is run from.\n\n```rust\n#[derive(rust_embed::RustEmbed)]\n#[folder = \"src/\"]\npub struct Asset;\n\nfn main() {\n    let d = Asset::get(\"../../../etc/passwd\").unwrap().data;\n    println!(\"{}\", String::from_utf8_lossy(\u0026d));\n}\n```\n\nThe flaw was corrected by canonicalizing the input filename and ensuring that\nit starts with the canonicalized folder path.","status":"published","published":"2021-11-29T12:00:00Z","modified":"2023-11-08T04:07:23.363783Z","updated_at":"2026-11-02T15:53:39.492624Z"}]}}
