CVE-2015-1328: incorrect permission checks in overlayfs, Ubuntu local root
The overlayfs filesystem did not correctly check file permissions when copying files from a lower to an upper directory, allowing an unprivileged user to create a root-owned copy of a sensitive file and then place it in a privileged location. An attacker could exploit this to gain root privileges by creating a world-writable /etc/ld.so.preload file.
seclists.org
Published on seclists.org
The overlayfs filesystem does not correctly check file permissions when creating new files in the upper filesystem directory. This can be exploited by an unprivileged process in kernels with CONFIGUSERNS=y and where overlayfs has the FSUSERNSMOUNT flag, which allows the mounting of overlayfs inside unprivileged mount…
The full write-up lives on its author's site
It belongs to its author, so we link to it rather than copy it. The other two tabs are our own rewrites, checked against it.
Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.
How it worked
Root cause
Likely the ovl_copy_up_* functions only checked if the owner of the file being modified had write permission to the upperdir, and copied file metadata (including ownership) without verifying the user's permission to write to the upperdir.
Impact
A local unprivileged attacker could gain root privileges by creating a world-writable /etc/ld.so.preload file, and could also list directory contents regardless of permissions.
What the attacker needed
Local unprivileged user account; kernel with CONFIG_USER_NS=y; overlayfs mounted with FS_USERNS_MOUNT
The fix
The kernel should be updated to correctly check permissions when copying files in overlayfs; a workaround is to remove or blacklist the overlayfs kernel module.
How it was found
- Create a new user namespace and mount an overlayfs with lowerdir=/etc and a user-writable upperdir.
- Make the work directory world-writable and rename a root-owned file (e.g., shadow) to create a copy in the upperdir.
- Exit the namespace and verify the copied file is owned by root.
- Create another namespace and mount overlayfs with lowerdir set to the previous upperdir and upperdir=/etc.
- Change permissions on the copied file to world-writable and exit the namespace.
- The file is now world-writable in /etc, allowing creation of /etc/ld.so.preload for root code execution.
Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.
Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.
Overlayfs is a Linux filesystem that lets you combine directories, and when a file is changed it is copied to a writable 'upper' directory. The bug was that this copy did not check if the user had permission to write to the upper directory, so a normal user could make a copy of a root-owned file and then move it into a system directory. This let the user become the root administrator.
What is Access control?
A user can do something their role should not allow: reach an admin function, act on a feature they have not paid for, or skip a permission check. IDOR is the special case where the object belongs to someone else.