SeleniumHQ/selenium · error · anyhow::Error
Unsafe entry (path traversal): {:?}
Error message
Unsafe entry (path traversal): {:?} What it means
Returned by check_path_traversal() in rust/src/files.rs when an archive entry's path is empty or contains a ParentDir (..), RootDir (/ or \), or Windows Prefix component. This is the zip-slip / tar-slip defense: it prevents a malicious or malformed archive from writing outside the target directory during decompression. It is called for every entry before extraction.
Source
Thrown at rust/src/files.rs:120
pub fn create_path_if_not_exists(path: &Path) -> Result<(), Error> {
if !path.exists() {
fs::create_dir_all(path)?;
}
Ok(())
}
pub fn check_path_traversal(entry_path: &Path) -> Result<(), Error> {
if entry_path.as_os_str().is_empty()
|| entry_path.components().any(|c| {
matches!(
c,
std::path::Component::ParentDir
| std::path::Component::RootDir
| std::path::Component::Prefix(_)
)
})
{
return Err(anyhow!("Unsafe entry (path traversal): {:?}", entry_path));
}
Ok(())
}
pub fn uncompress(
compressed_file: &str,
target: &Path,
log: &Logger,
os: &str,
single_file: Option<String>,
volume: Option<&str>,
) -> Result<(), Error> {
let mut extension = match infer::get_from_path(compressed_file)? {
Some(kind) => kind.extension(),
_ => {
if compressed_file.ends_with(PKG) || compressed_file.ends_with(DMG) {
if MACOS.is(os) {
PKGView on GitHub (pinned to aa36b38e69)
Solutions
- Do not bypass this check; instead verify the archive's source and integrity (sha256) before trusting it.
- Re-download the driver from the official endpoint to replace a possibly tampered archive.
- If the archive is legitimately structured with absolute paths, extract it manually in a sandbox and copy the needed binary.
- Report the upstream package if a legitimate driver ships a traversal entry.
Defensive patterns
Strategy: validation
Validate before calling
// Rust: verify entry path is safe before extraction (mirrors the library check)
fn is_safe_entry(p: &Path) -> bool {
!p.as_os_str().is_empty() && !p.components().any(|c| matches!(c,
std::path::Component::ParentDir | std::path::Component::RootDir
| std::path::Component::Prefix(_)))
} Try / catch
// Callers typically cannot catch inside Selenium Manager; validate archives pre-download: // 1. Verify sha256 of the downloaded archive against the published checksum. // 2. Scan the archive's entry list with `unzip -l` / `tar -tf` before trusting. // (Internal Rust callers can use check_path_traversal directly.)
Prevention
- Always verify the archive's sha256 against the published checksum before extraction.
- Download drivers only from official endpoints to avoid tampered archives.
- Keep the path-traversal check enabled; never bypass it.
When it happens
Trigger: uncompress/unzip iterates archive entries and calls check_path_traversal(entry_path) on each. Any entry whose components include .. or an absolute root triggers the error before the file is written. Also fires on an empty path string.
Common situations: A downloaded driver archive (zip/tar) contains an entry like ../../etc/cron.d/x; a macOS .pkg Payload cpio entry has an absolute path; a corrupted archive produces a garbage entry path; a mirror serves a tampered archive.
Related errors
- {} files are only supported in macOS
- Format for file {} cannot be inferred
- Wrong browser/driver version
- Downloaded file cannot be uncompressed ({} extension)
- Payload is not a pbzx stream
AI-assisted analysis of SeleniumHQ/selenium@aa36b38e69 (2026-08-14).
Data as JSON: /api/errors/f86c5e2ecadf3633.
Report an issue: GitHub.