Prevent zip path exploits

This commit is contained in:
Caelan Sayler
2024-03-17 21:39:21 +00:00
parent 35e8852ad0
commit 4c3fcc74db

View File

@@ -294,8 +294,9 @@ impl BundleInfo<'_> {
let mut archive = self.zip.borrow_mut();
for i in 0..archive.len() {
let file = archive.by_index(i)?;
let key = file.name();
files.push(key.to_string());
let key = file.enclosed_name().ok_or_else(
|| anyhow!("Could not extract file safely ({}). Ensure no paths in archive are absolute or point to a path outside the archive.", file.name()))?;
files.push(key.to_string_lossy().to_string());
}
Ok(files)
}