From 4f08666b8aafe66d4786158c8f26dec1c540893b Mon Sep 17 00:00:00 2001 From: David Oberhollenzer Date: Sun, 3 May 2020 01:43:11 +0200 Subject: Fix: use 0644 as default permissions when creating files Until now, when packing or unpacking a SquashFS image, files where created with paranoid permissions (i.e. 0600). The rational behind this was that otherwise, the tools may inadvertently expose secrets, e.g. if a root user packs files that that aren't world readable, such as the /etc/shadows file, but the packed SquashFS image is, we have accidentally leaked this file to other users that can access the newly created SquashFS image. The same line of reasoning also applies when unpacking files. Unfortunately, this breaks a list of other, more common standard use cases (e.g. a build server where the an image is built by a deamon running as user X but then has to be accessed by another deamon running as Y). This commit changes to a more standard approach of using permissive file permissions by default and asking paranoid users to simply use a paranoid umask. For tar2sqfs & gensquashfs this simply means chaning the default permissions in the libsquashfs file implementation. For rdsquashfs on the other hand there is still the use case where the unpacked files get the permissions from the [secret] image, so setting a strict umask is not applicable and changing to permissive file mode leaks something. For this case a second code path needs to be added that derives the permissions from the ones in the image. Signed-off-by: David Oberhollenzer --- lib/sqfs/unix/io_file.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib/sqfs/unix') diff --git a/lib/sqfs/unix/io_file.c b/lib/sqfs/unix/io_file.c index 52fc94b..d4c1232 100644 --- a/lib/sqfs/unix/io_file.c +++ b/lib/sqfs/unix/io_file.c @@ -168,7 +168,7 @@ sqfs_file_t *sqfs_open_file(const char *filename, sqfs_u32 flags) } } - file->fd = open(filename, open_mode, 0600); + file->fd = open(filename, open_mode, 0644); if (file->fd < 0) { temp = errno; free(file); -- cgit v1.2.3