{"record":{"id":"e75f76bc7f9d598c","repo":"BigPizzaV3/CodexPlusPlus","slug":"zip-entry-escapes-destination-name","errorCode":null,"errorMessage":"zip entry escapes destination: {name}","messagePattern":"zip entry escapes destination: (.+?)","errorType":"exception","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"crates/codex-plus-core/src/plugin_marketplace.rs","lineNumber":478,"sourceCode":"                .with_context(|| format!(\"failed to create {}\", parent.display()))?;\n        }\n        let mut contents = Vec::new();\n        file.read_to_end(&mut contents)\n            .with_context(|| format!(\"failed to read zip entry {}\", file.name()))?;\n        std::fs::write(&output_path, contents)\n            .with_context(|| format!(\"failed to write {}\", output_path.display()))?;\n    }\n    Ok(())\n}\n\nfn safe_zip_path(name: &str) -> anyhow::Result<PathBuf> {\n    let path = Path::new(name);\n    let mut relative = PathBuf::new();\n    for component in path.components() {\n        match component {\n            Component::Normal(value) => relative.push(value),\n            Component::CurDir => {}\n            _ => anyhow::bail!(\"zip entry escapes destination: {name}\"),\n        }\n    }\n    if relative.as_os_str().is_empty() {\n        anyhow::bail!(\"zip entry has empty path\");\n    }\n    Ok(relative)\n}\n\npub(crate) fn zip_entry_relative_path(name: &str) -> Option<PathBuf> {\n    let path = Path::new(name);\n    let mut components = path.components();\n    match components.next()? {\n        Component::Normal(_) => {}\n        _ => return None,\n    }\n    let mut relative = PathBuf::new();\n    for component in components {\n        match component {","sourceCodeStart":460,"sourceCodeEnd":496,"githubUrl":"https://github.com/BigPizzaV3/CodexPlusPlus/blob/b1ed92e5e4a2d74095d4b8db5af43cef7acba9c6/crates/codex-plus-core/src/plugin_marketplace.rs#L460-L496","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Do not use the zip — obtain the openai/plugins marketplace archive only from the official GitHub source and re-download","Inspect the archive (unzip -l) for entries with absolute paths or '..' segments and rebuild/republish it if you control it","If you legitimately need such entries, repack the zip with relative, sanitized entry names"],"exampleFix":"# before (malicious entry)\nzip: ../evil.sh\n# after (repacked)\nzip: scripts/evil.sh","handlingStrategy":"validation","validationCode":"fn zip_entry_is_safe(name: &str) -> bool {\n    !name.starts_with('/') && !name.contains(\"..\") && Path::new(name).components().all(|c| matches!(c, Component::Normal(_) | Component::CurDir))\n}","typeGuard":null,"tryCatchPattern":"match safe_zip_path(entry.name) {\n    Ok(rel) => extract_to(dest.join(rel), data),\n    Err(e) => { tracing::error!(\"rejected zip entry {}: {e}\", entry.name); abort_install(); }\n}","preventionTips":["Only download marketplace zips from the official source over HTTPS","Verify archive checksums/signatures when available","Never disable Zip Slip sanitization for convenience"],"tags":["security","zip","path-traversal"],"backgroundTag":"path-traversal-blocked","analyzedSha":"b1ed92e5e4a2d74095d4b8db5af43cef7acba9c6","analyzedAt":"2026-09-19T23:35:21.129Z","contentChangedAt":"2026-09-19T23:35:21.129Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}