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) {
                    PKG

View on GitHub (pinned to aa36b38e69)

Solutions

  1. Do not bypass this check; instead verify the archive's source and integrity (sha256) before trusting it.
  2. Re-download the driver from the official endpoint to replace a possibly tampered archive.
  3. If the archive is legitimately structured with absolute paths, extract it manually in a sandbox and copy the needed binary.
  4. 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

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


AI-assisted analysis of SeleniumHQ/selenium@aa36b38e69 (2026-08-14). Data as JSON: /api/errors/f86c5e2ecadf3633. Report an issue: GitHub.