Apr 15, 2026·7 min read·7 visits
A misconfiguration between Ubuntu kernel patches and upstream OverlayFS changes allows local attackers to bypass security checks and escalate to root privileges by copying files with malicious capabilities.
CVE-2023-2640 is a high-severity local privilege escalation vulnerability located in the OverlayFS implementation of specific Ubuntu Linux kernels. The flaw exists due to an unsafe interaction between an Ubuntu-specific kernel patch and an upstream kernel modification, which effectively bypasses Virtual File System (VFS) permission checks for extended attributes. An unprivileged local attacker can exploit this condition to assign root-level capabilities to arbitrary executables, achieving full system compromise.
CVE-2023-2640 represents a critical logic failure within the Ubuntu Linux kernel's implementation of OverlayFS. OverlayFS is a union filesystem designed to layer an "upper" filesystem over a "lower" filesystem, presenting a unified view to user space. This mechanism requires complex security boundary management, specifically during "copy-up" operations where modified files are transferred from the read-only lower directory to the writable upper directory.
The vulnerability originates from an integration error rather than a pure upstream bug. Ubuntu maintains custom, backported patches designated as "SAUCE" patches. In this instance, a specific SAUCE patch intended to facilitate unprivileged OverlayFS mounts collided with a subsequent upstream architectural change. This collision inadvertently disabled kernel-level permission validations for setting extended file attributes.
An attacker leveraging this vulnerability requires local shell access to the target host and the ability to instantiate user namespaces. By manipulating a localized OverlayFS mount, the attacker circumvents standard access controls and applies elevated execution capabilities to standard binaries. Execution of these modified binaries outside the namespace context immediately yields arbitrary root code execution.
The fundamental root cause lies in the improper handling of Virtual File System (VFS) capability checks during OverlayFS operations. In Linux environments, access control and execution privileges can be managed via extended attributes (xattrs), specifically the security.capability attribute. The kernel must rigorously validate that the user attempting to assign these attributes possesses the requisite administrative capabilities.
In 2018, Ubuntu introduced a custom SAUCE patch titled "UBUNTU: SAUCE: overlayfs: Skip permission checking for trusted.overlayfs.* xattrs". This modification allowed unprivileged users to manage OverlayFS structures by bypassing permission checks strictly for attributes prefixed with trusted.overlayfs.*. The intent was localized and limited to internal filesystem mechanics.
In 2020, the upstream Linux kernel integrated commit c914c0e27eb0, which refactored xattr handling to utilize centralized wrapper functions (vfs_setxattr, vfs_getxattr, etc.). This architectural shift effectively unified the code paths for all xattr modifications within OverlayFS. The Ubuntu SAUCE patch logic was subsumed into these broader wrappers. Consequently, the conditional bypass intended solely for trusted.overlayfs.* was misapplied to all extended attributes, entirely disabling the security validations during copy-up operations.
Analyzing the vulnerable kernel code reveals the exact intersection of the conflicting patches. During a typical VFS attribute modification, the kernel invokes cap_convert_nscap to verify the user namespace possesses the required authority. The Ubuntu SAUCE patch injected logic that circumvented this verification if the operation originated from an internal OverlayFS process.
When an attacker triggers a copy-up operation by modifying an executable file mapped via OverlayFS, the kernel delegates the task to a high-privileged kernel worker thread. Because the upstream wrappers consolidated the attribute modification pathway, the worker thread processes the malicious security.capability xattr. The kernel queries the SAUCE patch logic, observes the operation belongs to OverlayFS, and skips the cap_convert_nscap check. The host filesystem subsequently records the malicious capability.
The patch applied in Ubuntu Security Notice USN-6250-1 removes the flawed SAUCE patch integration. The remediation explicitly isolates the capability logic from general VFS wrappers. The kernel source was modified to reinstate rigorous capability checks across all attribute writes, demanding verifiable namespace authority regardless of the caller's origin.
/* Conceptual representation of the underlying capability bypass logic */
// VULNERABLE STATE:
int vfs_setxattr(struct user_namespace *mnt_userns, struct dentry *dentry,
const char *name, const void *value, size_t size, int flags)
{
// Ubuntu SAUCE patch collision caused capability checks to be skipped
// for all xattrs if called from an overlayfs context.
if (is_overlayfs_context() && !strcmp(name, "security.capability")) {
// Bypass cap_convert_nscap()
goto write_xattr;
}
// Normal capability check happens here otherwise
}
// PATCHED STATE:
// The explicit bypass mechanism logic is removed, ensuring capabilities
// are validated via standard VFS paths regardless of overlayfs state.Exploitation begins with establishing an isolated environment. The attacker executes the unshare command to generate a new user and mount namespace. This constructs a localized sandbox where the attacker is mapped to the root user identifier (UID 0), despite retaining zero administrative privileges on the underlying host filesystem.
Within this namespace, the attacker establishes the required directory hierarchy: a lower directory, an upper directory, and a work directory. The attacker places an arbitrary executable payload (e.g., a compiled C program designed to launch a shell) into the lower directory. Next, the attacker mounts an OverlayFS instance utilizing these directories. Crucially, the attacker employs the setcap utility to embed the cap_setuid+ep attribute into the payload residing in the lower directory.
The final phase requires translating this localized capability to the host filesystem. The attacker triggers a modification against the mapped payload within the OverlayFS mount point, typically using a touch command. This modification compels the kernel to execute a copy-up operation, transferring the payload and its malicious extended attributes into the upper directory. The attacker exits the unshare namespace and directly executes the binary located within the host's upper directory. The binary runs with full CAP_SETUID privileges, granting an interactive root shell.
# Core sequence from public Proof-of-Concept exploits
unshare -rm sh -c "mkdir -p l u w m && \
cp /tmp/exploit l/ && \
setcap cap_setuid+eip l/exploit && \
mount -t overlay overlay -o rw,lowerdir=l,upperdir=u,workdir=w m && \
touch m/exploit"
/tmp/u/exploit # Payload executes with setuid rootThe impact of CVE-2023-2640 is severe due to its reliability and the ubiquity of the vulnerable component. Successful exploitation yields immediate and complete control over the affected node. The attacker secures the capacity to access sensitive configuration files, modify kernel parameters, inject persistent persistence mechanisms, and laterally traverse the network leveraging the compromised host.
Ubuntu installations are heavily utilized as base images in containerized ecosystems and cloud infrastructure. While an attacker requires an initial execution foothold, this vulnerability transforms minor initial access vectors—such as a restricted application sandbox or a low-privilege service account compromise—into complete system ownership. The flaw enables horizontal expansion by undermining node-level boundaries in multi-tenant environments.
The vulnerability maps to a CVSS v3.1 score of 7.8, reflecting low complexity and the lack of user interaction requirements. The Exploit Prediction Scoring System (EPSS) rating exceeds 91% (0.99672 percentile), indicating an extreme probability of exploitation in operational environments. The widespread public availability of reliable weaponized exploit code mandates an accelerated response posture.
The definitive remediation strategy dictates applying the updated kernel packages provided by Canonical. Administrators must patch vulnerable kernels in alignment with Ubuntu Security Notice USN-6250-1. Upgrading requires a mandatory system reboot to ensure the newly patched kernel image is loaded into memory and the vulnerable execution paths are entirely eradicated from active use.
In scenarios where immediate host restarts are administratively restricted, engineers must deploy system-level configuration workarounds to sever the exploit chain. Disabling unprivileged user namespaces prevents an attacker from initializing the sandboxed environment required to mount an unprivileged OverlayFS instance. Administrators execute sysctl -w kernel.unprivileged_userns_clone=0 to implement this restriction dynamically.
Security operations centers must tune endpoint detection sensors to recognize the behavioral signatures of this exploit. Telemetry focusing on the execution of the unshare binary with user and mount namespace flags (-r, -m) followed closely by mount -t overlay operations indicates strong malicious intent. Furthermore, monitoring audit logs for unprivileged users assigning security.capability attributes to binaries in temporary file systems (/tmp, /dev/shm) provides high-fidelity detection mechanisms.
CVSS:3.1/AV:L/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:H| Product | Affected Versions | Fixed Version |
|---|---|---|
Ubuntu 23.04 (Lunar Lobster) Canonical | < 6.2.0-26.26 | 6.2.0-26.26 |
Ubuntu 22.04 LTS (Jammy Jellyfish) Canonical | < 5.19.0-50.50 | 5.19.0-50.50 |
Ubuntu 20.04 LTS (Focal Fossa) Canonical | < 5.4.0-155.172 | 5.4.0-155.172 |
| Attribute | Detail |
|---|---|
| CWE ID | CWE-863 |
| Attack Vector | Local |
| CVSS v3.1 | 7.8 |
| EPSS Score | 0.91524 |
| Impact | Privilege Escalation (Root) |
| Exploit Status | Weaponized |
| CISA KEV | No |
The kernel fails to properly validate the authority of a user attempting to set privileged extended attributes during OverlayFS operations.