Commit 17cb68e9 authored by Sören Tempel's avatar Sören Tempel
Browse files

abuild-rmtemp: Do not follow symbolic links

Symbolic links might point to files outside of the chroot and
thus might delete files outside the chroot. This allows deletion
of arbitrary directories on the host from a malicious APKBUILD.

Following hard links shouldn't be a problem since hard links (usually)
cannot refer to directories and since remove(3) removes the link, not
the file it points to it shouldn't cause a problem.

I noticed this because alpine-baselayout creates /var/run as a symlink
to /run. Therefore causing /run to be deleted on the host when using
abuild-rmtemp which in turn causes a bunch of software to no longer
function properly (including OpenRC).
parent 70f52b9b
......@@ -44,7 +44,7 @@ int main(int argc, char **argv) {
if (!p) errx(1, "Incorrect user");
if (s.st_uid != p->pw_uid) errx(1, "Permission denied");
if (nftw(argv[1], handler, 512, FTW_DEPTH)) fail();
if (nftw(argv[1], handler, 512, FTW_DEPTH|FTW_PHYS)) fail();
return 0;
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment