security improvements#951
Conversation
a6b9da7 to
b589702
Compare
b589702 to
25eb2cf
Compare
tommady
left a comment
There was a problem hiding this comment.
Hi, thanks for the contribution!
I left a comment.
One small thing I noticed: it looks like LimitedReader went on vacation and didn’t make it into:
- tar
- rar
Might be worth inviting it back for consistency (and so things don’t get… too unlimited). 😄
| if target.is_absolute() { | ||
| return Ok(()); | ||
| } |
There was a problem hiding this comment.
Our zip.rs extraction is a bit too naive.
In zip.rs, we use output_folder.join(&relpath) + fs::File::create(), which will blindly follow symlinks on disk. That means a malicious archive like:
- link -> /etc (allowed by the absolute check)
- link/passwd -> (malicious content, allowed by the absolute check)
would end up overwriting /etc/passwd on the host.
The tar crate avoids this by checking path metadata during extraction to ensure writes stay inside the output dir.
https://docs.rs/tar/0.4.42/src/tar/entry.rs.html#937-947
I’d suggest we follow the same approach in zip.rs.
WDYT?
tommady
left a comment
There was a problem hiding this comment.
I'd love your validate_dest_inside_root check!
it is a very clever and highly performant way than canonicalization.
@marcospb19 please help check this
thank you
Multiple problems affecting security
../paths escape the output directory, becausePathBuf::joinreplaces the base when the second arg is absolute.path.display(), so an archive can inject ESC sequences, BiDi overrides (CVE-2021-42574), zero-width chars, etc.decompressandlist.u32::MAX(4 GiB) in bothdecompress.rsandlist.rs.--passwordon the command line leaks viapsand shell history; no env var alternative exists.