Nov 20, 2026·10 min read·1 visit
During recursive directory relabeling (chcon -R), uutils coreutils resolves targets via unanchored pathname lookups instead of directory file descriptors. Local attackers can win a race condition via symlink or directory swapping to alter SELinux security contexts on arbitrary files outside the target hierarchy.
A Time-of-Check to Time-of-Use (TOCTOU) race condition in the chcon utility of uutils coreutils prior to version 0.8.0 allows a local attacker with write access to a directory tree undergoing recursive SELinux context relabeling to redirect extended attribute modifications to arbitrary system files.
The uutils/coreutils project is a cross-platform reimplementation of the GNU coreutils suite written in Rust. Among the utilities provided for Linux systems is chcon (uu_chcon), which modifies the SELinux (Security-Enhanced Linux) security context of files and directories. SELinux contexts are stored as extended attributes (security.selinux) on filesystem inodes and are evaluated by the Linux kernel to enforce Mandatory Access Control (MAC) policies.
When chcon is invoked with the recursive flag (-R or --recursive), it traverses a target directory hierarchy to apply the specified security context to all nested files and subdirectories. Safe implementation of recursive directory traversal requires that operations performed on discovered entries remain strictly bound to the directory inodes verified during the walk, particularly when an elevated process (such as root) traverses directories writable by unprivileged users.
In uutils/coreutils versions prior to 0.8.0, the recursive implementation of chcon suffers from a Time-of-Check to Time-of-Use (TOCTOU) race condition (CWE-367). Rather than anchoring extended attribute retrieval and modification to verified directory file descriptors using descriptor-relative system calls (such as openat), the utility passes path strings derived from the traversal state directly to path-based SELinux context manipulation functions.
Because path resolution and attribute mutation occur as separate, non-atomic steps from the initial directory entry inspection, an unprivileged local user with write access to any subdirectory within the traversal path can manipulate the directory structure mid-operation. By swapping a directory or file with a symbolic link during the race window, the attacker can cause the privileged chcon process to apply arbitrary SELinux security contexts to sensitive files outside the intended directory tree.
The root cause of CVE-2026-35376 lies in how uu_chcon interacts with the fts (File Tree Stream) traversal API (fts-sys) and the selinux crate when processing individual filesystem entries. In affected versions, the process_file function retrieves the current traversal entry via fts.last_entry_ref() and extracts its access path (fts_accpath) using entry.access_path().
During an fts directory walk, fts normally changes the process working directory as it descends into subdirectories (unless FTS_NOCHDIR is specified), and fts_accpath represents a path string relative to the current working directory or the starting path. Once process_file obtains this Path, it passes it directly to change_file_context(options, context, fts_access_path).
Inside change_file_context, the utility performs two separate path-based operations when modifying or computing a security context. First, if operating in a custom partial-context mode, it queries the target's existing context using SecurityContext::of_path(path, options.affect_symlink_referent, false), which invokes getfilecon or lgetfilecon under the hood. Second, it applies the new context by calling SecurityContext::from_c_str(&context_string, false).set_for_path(path, options.affect_symlink_referent, false), which invokes setfilecon or lsetfilecon.
The vulnerability occurs because fts_read performs the initial stat or lstat check on the filesystem entry at Time-of-Check, while SecurityContext::of_path and SecurityContext::set_for_path perform fresh pathname resolution in the kernel at Time-of-Use. Neither operation is bound to an open file descriptor representing the verified target inode, nor is the lookup anchored to an explicit directory file descriptor with symlink traversal flags properly constrained across both steps.
Furthermore, even if lsetfilecon is selected (when options.affect_symlink_referent is false), lsetfilecon only prevents following a symlink at the final path component. If fts_accpath contains intermediate directory components (or if the parent directory hierarchy is renamed and replaced with a symlink before the current working directory is pinned via an open descriptor), the kernel will follow intermediate symlinks during path resolution. Even for single-component relative paths, if options.affect_symlink_referent is enabled (via the -L or -H flags, or default dereferencing behavior), setfilecon will directly follow a newly substituted terminal symlink.
Before the patch in commit 7cfc74e47ffab452663be6842d788a5164d9688b, src/uu/chcon/src/chcon.rs processed each entry returned by fts by extracting fts_access_path and passing the raw &Path reference directly to change_file_context. The pre-patch implementation lacked any file descriptor management during the context modification phase:
// Vulnerable code path in src/uu/chcon/src/chcon.rs (pre-0.8.0)
fn process_file(
options: &Options,
context: &SELinuxSecurityContext,
fts: &mut fts::FTS,
root_dev_ino: Option<DeviceAndINode>,
) -> Result<()> {
let mut entry = fts.last_entry_ref().unwrap();
// ... validation and cycle checks ...
let fts_access_path = entry.access_path().ok_or_else(|| ...)?;
// Directly passes the unanchored path string to change_file_context
result = change_file_context(options, context, fts_access_path);
// ...
}
fn change_file_context(
options: &Options,
context: &SELinuxSecurityContext,
path: &Path,
) -> Result<()> {
match &options.mode {
CommandLineMode::Custom { .. } => {
// TOCTOU: Resolves path string from scratch via getfilecon/lgetfilecon
let file_context = match SecurityContext::of_path(path, options.affect_symlink_referent, false) {
// ...
};
// TOCTOU: Resolves path string again via setfilecon/lsetfilecon
SecurityContext::from_c_str(&context_string, false)
.set_for_path(path, options.affect_symlink_referent, false)
}
// ...
}
}To remediate this flaw, the patch introduces explicit file descriptor anchoring using the rustix crate. First, a helper method current_dir_fd() was added to fts::FTS in src/uu/chcon/src/fts.rs to capture an OwnedFd pointing to the current traversal directory (.):
// Added to src/uu/chcon/src/fts.rs
pub(crate) fn current_dir_fd(&self) -> io::Result<OwnedFd> {
open(
Path::new("."),
OFlags::RDONLY | OFlags::DIRECTORY | OFlags::CLOEXEC,
Mode::empty(),
)
.map_err(io::Error::from)
}Next, src/uu/chcon/src/chcon.rs was updated to open the target entry relative to traversal_dir_fd using openat with the O_PATH and O_CLOEXEC flags. When affect_symlink_referent is false, O_NOFOLLOW is also applied so that openat binds directly to the symlink inode itself rather than dereferencing it:
// Patched code in src/uu/chcon/src/chcon.rs
fn open_target_fd(
traversal_dir_fd: BorrowedFd<'_>,
target_path: &Path,
affect_symlink_referent: bool,
display_path: &Path,
) -> Result<OwnedFd> {
// O_PATH allows opening a descriptor without requiring read/write permissions on the file
// and supports opening symlink inodes directly when combined with O_NOFOLLOW.
let mut flags = OFlags::PATH | OFlags::CLOEXEC;
if !affect_symlink_referent {
flags |= OFlags::NOFOLLOW;
}
openat(traversal_dir_fd, target_path, flags, Mode::empty())
.map_err(io::Error::from)
.map_err(|err| Error::from_io1(translate!("chcon-op-accessing"), display_path, err))
}Because the Linux kernel does not permit standard extended attribute file descriptor system calls (fgetxattr / fsetxattr, which back fgetfilecon / fsetfilecon) to operate directly on an O_PATH file descriptor (returning EBADF), the patch constructs a magic procfs path (/proc/self/fd/<fd>) referencing the pinned target_fd:
fn change_file_context(
options: &Options,
context: &SELinuxSecurityContext,
traversal_dir_fd: BorrowedFd<'_>,
target_path: &Path,
display_path: &Path,
) -> Result<()> {
let target_fd = open_target_fd(
traversal_dir_fd,
target_path,
options.affect_symlink_referent,
display_path,
)?;
// Bind context operations to the specific inode referenced by target_fd
let target = PathBuf::from(format!("/proc/self/fd/{}", target_fd.as_raw_fd()));
match &options.mode {
CommandLineMode::Custom { .. } => {
// Passing true for follow_symbolic_links resolves the /proc/self/fd/<N> magic link
// directly to the underlying inode pinned by target_fd (even if that inode is a symlink).
let file_context = match SecurityContext::of_path(&target, true, false) {
// ...
};
// ...
SecurityContext::from_c_str(&context_string, false)
.set_for_path(&target, true, false)
}
// ...
}
}> [!NOTE]
> This patch pattern—opening the target via openat with O_PATH | O_NOFOLLOW and subsequently calling getxattr/setxattr (following symlinks) on /proc/self/fd/<N>—is the standard Linux user-space idiom (also used by modern GNU coreutils) for safely manipulating extended attributes on arbitrary inodes, including symlinks and device nodes, without triggering file-open side effects or TOCTOU races.
In terms of fix completeness, binding both SecurityContext::of_path and SecurityContext::set_for_path to the same target_fd eliminates the race window between reading the existing context and writing the new context. Additionally, the upstream commit introduces a verification script (util/check-safe-traversal.sh) that runs chcon -R under strace to confirm that getxattr and setxattr are never invoked directly on target paths.
Exploiting CVE-2026-35376 requires local access to a Linux system where SELinux is enabled and uutils/coreutils (< 0.8.0) is deployed. Furthermore, an administrative user or automated privileged task (such as a cron job, container provisioning script, or package deployment hook) must execute chcon -R over a directory hierarchy where the unprivileged attacker holds write permissions.
To maximize the probability of winning the race condition, an attacker typically prepares a deep or wide directory structure within the writable directory tree. Populating the directory with thousands of dummy entries increases the execution duration of the fts traversal and can induce disk I/O latency or scheduler preemption between the fts_read step and the change_file_context execution.
/srv/shared/attacker_dir/sub/target) and populates sibling directories with numerous files to slow down chcon -R.inotify subsystem (watching for IN_OPEN or IN_ACCESS events on preceding sibling directories) or by polling directory metadata in a tight loop.fts_read inspects the target entry (or when FTS_NOCHDIR is active, as fts descends into sub), the attacker uses renameat2(..., RENAME_EXCHANGE) or rapid unlink/symlink calls to replace the target path component with a symbolic link pointing to a sensitive system file (such as /etc/shadow, /etc/passwd, or a privileged daemon socket).change_file_context invokes SecurityContext::set_for_path on the unanchored path string. The kernel resolves the newly placed symlink and modifies the security.selinux extended attribute on the arbitrary target file.At the time of writing, no public proof-of-concept (PoC) exploit code or weaponized exploit module has been published for CVE-2026-35376. The EPSS score is 0.0011 (1.31st percentile), reflecting the local prerequisite and high attack complexity (AC:H) inherent to winning filesystem race conditions.
The primary security impact of CVE-2026-35376 is the circumvention or corruption of SELinux Mandatory Access Control (MAC) policies. In an SELinux-enforced environment, process confinement and resource isolation depend on accurate file labels (e.g., shadow_t, sshd_key_t, httpd_sys_content_t). Standard Discretionary Access Control (DAC) permissions remain unaffected by chcon, meaning this vulnerability does not directly alter standard Unix mode bits or file ownership (uid/gid).
However, if an attacker forces a privileged chcon -R process (which typically applies a permissive or service-accessible label such as httpd_sys_rw_content_t, container_file_t, or user_home_t) to relabel a restricted system file, a confined process or compromised service that was previously blocked by SELinux policy may gain read or write access to that file (assuming DAC permissions or capability sets otherwise permit access).
Conversely, an attacker can leverage the vulnerability to cause a localized Denial of Service (DoS). By redirecting a user-space or service-specific security context onto critical system binaries, libraries, configuration files, or UNIX domain sockets (for example, relabeling /etc/ld.so.cache or /run/systemd/private), legitimate system daemons confined by strict SELinux domains will receive EACCES (AVC denial) errors when attempting to interact with those resources.
This aligns with the CVSS v3.1 assessment of 4.5 (Medium) (CVSS:3.1/AV:L/AC:H/PR:L/UI:N/S:U/C:L/I:L/A:L). Confidentiality, Integrity, and Availability each receive a Low (L) impact rating because successful exploitation only modifies SELinux labels without overriding underlying DAC enforcement, and requires winning a local race condition during an administrative action.
Administrators and distribution maintainers using uutils/coreutils should upgrade to version 0.8.0 or later, which includes commit 7cfc74e47ffab452663be6842d788a5164d9688b (PR #11402). Downstream distributions packaging uu_chcon separately should backport the changes to src/uu/chcon/src/chcon.rs, src/uu/chcon/src/fts.rs, and src/uu/chcon/Cargo.toml (ensuring rustix with the fs feature is available).
In environments where an immediate upgrade of uutils/coreutils is not feasible, administrators should apply the following operational mitigations:
chcon on Untrusted Paths: Do not execute uu_chcon -R as root on directories writable by unprivileged users or compromised service accounts (such as /tmp, /var/tmp, /dev/shm, user home directories, or shared web roots).restorecon -R (from policycoreutils) in combination with semanage fcontext rules, as restorecon utilizes safe descriptor-based traversal via libselinux (selinux_restorecon).chcon command under the target user's unprivileged UID/GID rather than as root.CVSS:3.1/AV:L/AC:H/PR:L/UI:N/S:U/C:L/I:L/A:L| Product | Affected Versions | Fixed Version |
|---|---|---|
coreutils (uu_chcon) uutils | < 0.8.0 | 0.8.0 |
| Attribute | Detail |
|---|---|
| Vulnerability Type | CWE-367: Time-of-Check Time-of-Use (TOCTOU) Race Condition |
| Affected Component | uutils/coreutils chcon utility (uu_chcon) < 0.8.0 |
| Attack Vector | Local (AV:L) / High Attack Complexity (AC:H) |
| CVSS v3.1 Score | 4.5 Medium (CVSS:3.1/AV:L/AC:H/PR:L/UI:N/S:U/C:L/I:L/A:L) |
| EPSS Score | 0.11% (1.31st Percentile) |
| Security Impact | Arbitrary SELinux context modification / Mandatory Access Control (MAC) policy bypass |
| Exploit Status | No known public exploits or active exploitation (Not in CISA KEV) |
| Fixed Version | uutils/coreutils 0.8.0 (Commit 7cfc74e47ffab452663be6842d788a5164d9688b) |
The product checks the state of a resource before using that resource, but the resource's state can change between the check and the use in a way that invalidates the results of the check.
A line delimiter injection vulnerability in Git Large File Storage (Git LFS) versions 0.6.0 through 3.8.0 allows remote attackers to execute arbitrary commands via crafted Git submodule URLs containing embedded line feed characters.
CVE-2026-105803 (GHSA-x72p-hmqp-46hw) is a high-severity arbitrary command execution vulnerability in Git Large File Storage (Git LFS) affecting versions from v1.3.0 prior to v3.8.1. The flaw stems from the combination of an unanchored regular expression in custom transfer adapter initialization (CWE-777) and insufficient syntactic validation during .lfsconfig key filtering (CWE-1286). An attacker can craft a repository containing a malicious .lfsconfig file that bypasses safe-key filtering restrictions and registers an arbitrary binary as a custom transfer adapter, leading to remote code execution when a victim clones or fetches from the repository.
An unauthenticated SQL injection vulnerability exists in Daptin prior to version 0.12.30. The generic entity listing handler fails to validate user-supplied sort parameters against the table schema before passing them to the goqu SQL query builder, enabling remote attackers to break out of SQL identifier quoting and execute arbitrary SQL subqueries.
CVE-2026-77369 is a broken access control and Insecure Direct Object Reference (IDOR) vulnerability in Daptin, an open-source headless CMS. Affected versions from 0.11.4 through 0.12.29 expose a generic YJS real-time collaboration WebSocket endpoint (`GET /yjs/:documentName`) that verifies user authentication but fails to enforce row-level authorization when supplied with a canonical database room identifier (`{typename}.{referenceId}.{columnName}`). This allows any low-privileged authenticated user to read or modify restricted database columns of type `file.*` across all entities.
CVE-2026-77376 is an open redirect vulnerability (CWE-601) in the core framework of Bolt CMS prior to version 6.1.4. The vulnerability resides within the LoginFormAuthenticator class, which processes post-authentication redirection for both successful and failed login attempts. Due to a lack of destination validation, the application accepts untrusted target paths from user sessions and directly reflects unvalidated HTTP Referer headers into HTTP Location response headers. Attackers can exploit this behavior to redirect users to arbitrary external domains after interacting with the Bolt login endpoint, facilitating credential harvesting and phishing attacks.
Bolt CMS (bolt/core) versions prior to 6.1.4 contain a Server-Side Request Forgery (SSRF) vulnerability in the authenticated URL-upload (/async/upload-url) and media embed (/async/embed) endpoints. Backend users with file upload or media embedding privileges can supply arbitrary URLs that the application fetches without destination IP validation. This allows authenticated attackers to force the server to initiate HTTP requests to loopback interfaces, RFC 1918 private networks, and cloud instance metadata services.