BigPizzaV3/CodexPlusPlus · error · anyhow::Error

zip entry escapes destination

Error message

zip entry escapes destination: {name}

What it means

safe_zip_path sanitizes each zip entry name before extraction, mapping only Normal path components into the destination. Any entry containing an absolute path, parent traversal (..), root, or prefix component would escape the extraction directory, so it is rejected with this error to block Zip Slip attacks.

Solutions

  1. Do not use the zip — obtain the openai/plugins marketplace archive only from the official GitHub source and re-download
  2. Inspect the archive (unzip -l) for entries with absolute paths or '..' segments and rebuild/republish it if you control it
  3. If you legitimately need such entries, repack the zip with relative, sanitized entry names

Example fix

# before (malicious entry)
zip: ../evil.sh
# after (repacked)
zip: scripts/evil.sh
Defensive patterns

Strategy: validation

Validate before calling

fn zip_entry_is_safe(name: &str) -> bool {
    !name.starts_with('/') && !name.contains("..") && Path::new(name).components().all(|c| matches!(c, Component::Normal(_) | Component::CurDir))
}

Try / catch

match safe_zip_path(entry.name) {
    Ok(rel) => extract_to(dest.join(rel), data),
    Err(e) => { tracing::error!("rejected zip entry {}: {e}", entry.name); abort_install(); }
}

Prevention

When it happens

Trigger: extract_zip_exact processes an archive whose entry name is not relative-normal — e.g. '/etc/passwd', '../evil.sh', 'C:\\evil', or a drive/root-qualified name — so the Component match falls into the catch-all arm and bails.

Common situations: A malicious or tampered marketplace zip uploaded to a mirror; an archive built on Windows with absolute paths; a hand-crafted zip in a supply-chain attack against the plugin installer.

Understand the failure class

Background: Path traversal blocked: "path escapes the workspace" and "outside site root" errors when a path will not stay inside its allowed directory — this error's family across 26 libraries.

Related errors


AI-assisted analysis of BigPizzaV3/CodexPlusPlus@b1ed92e5e4 (2026-09-19). Data as JSON: /api/errors/e75f76bc7f9d598c. Report an issue: GitHub.

Appendix: source

Thrown at crates/codex-plus-core/src/plugin_marketplace.rs:478

                .with_context(|| format!("failed to create {}", parent.display()))?;
        }
        let mut contents = Vec::new();
        file.read_to_end(&mut contents)
            .with_context(|| format!("failed to read zip entry {}", file.name()))?;
        std::fs::write(&output_path, contents)
            .with_context(|| format!("failed to write {}", output_path.display()))?;
    }
    Ok(())
}

fn safe_zip_path(name: &str) -> anyhow::Result<PathBuf> {
    let path = Path::new(name);
    let mut relative = PathBuf::new();
    for component in path.components() {
        match component {
            Component::Normal(value) => relative.push(value),
            Component::CurDir => {}
            _ => anyhow::bail!("zip entry escapes destination: {name}"),
        }
    }
    if relative.as_os_str().is_empty() {
        anyhow::bail!("zip entry has empty path");
    }
    Ok(relative)
}

pub(crate) fn zip_entry_relative_path(name: &str) -> Option<PathBuf> {
    let path = Path::new(name);
    let mut components = path.components();
    match components.next()? {
        Component::Normal(_) => {}
        _ => return None,
    }
    let mut relative = PathBuf::new();
    for component in components {
        match component {

View on GitHub (pinned to b1ed92e5e4)