Bug 2465392 (CVE-2026-140038)

Summary: CVE-2026-140038 binutils: gprofng uses predictable /tmp directory with unchecked mkdir() enabling symlink-based file clobber
Product: [Other] Security Response Reporter: OSIDB Bzimport <bzimport>
Component: vulnerabilityAssignee: Product Security <prodsec-ir-bot>
Status: NEW --- QA Contact:
Severity: medium Docs Contact:
Priority: medium    
Version: unspecifiedCC: akhatavk, aos-team-art-private, asdas, crizzo, dpaolell, gtanzill, jbuscemi, jdelft, jupierce, lgarciaa, mbiarnes, ppalepu, ppostler, prdhamdh, rhel-process-autobot, security-response-team, sghai, sidsharm, suppawar, vlaad, watson-tool-maintainers
Target Milestone: ---Keywords: Security
Target Release: ---   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: ---
Doc Text:
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.
Story Points: ---
Clone Of: Environment:
Last Closed: Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On: 2587563, 2587564, 2587565, 2587566, 2587567, 2587568, 2587569, 2587570    
Bug Blocks:    

Description OSIDB Bzimport 2026-05-04 15:15:45 UTC
AI_ONLY_REPORT
package: binutils-2.45.1-5.hum1
------
Summary: Predictable `/tmp` directory + unchecked `mkdir()` enables  
symlink-based file clobber in gprofng: a local attacker who can pre-create  
the expected temporary directory for a victim process can place symlinks so  
that `gprofng` truncates or overwrites victim-writable files through  
predictable file names such as `print`.
Requirements to exploit: A local attacker account on the same system, the  
ability to predict or cover the victim PID range, and a victim execution  
path in the `gprofng` component that reaches an affected temp-file sink.  
The issue is relevant only when the `gprofng` code in this SRPM is built  
and used.
Component affected: `binutils-2.45.1-5.hum1` (`gprofng`);  
`gprofng/src/DbeSession.cc` `DbeSession::get_tmp_file_name()`, with  
reachable write sinks including `gprofng/src/Print.cc`  
`er_print_common_display::open()` and `gprofng/src/Module.cc`.
Version affected: `binutils-2.45.1-5.hum1`
Patch available: no released package fix established; proposed patch  
included below
Version fixed: unknown
Upstream coordination: Not notified.
CVSS: CVSS:3.1/AV:L/AC:H/PR:L/UI:R/S:U/C:N/I:H/A:H - 6.0 (MEDIUM)
AV:L - Exploitation requires a local attacker on the same host.
AC:H - The attacker must pre-create a matching  
`/tmp/analyzer.<uid>.<pid>` directory and rely on PID matching plus the  
victim reaching an affected write path.
PR:L - A local unprivileged account is required to stage the directory  
and symlink.
UI:R - The victim must run `gprofng` in a workflow that reaches the  
vulnerable open, such as printer output.
S:U - The impact stays within the victim process security scope.
C:N - The available evidence supports file clobber or truncation, not  
data disclosure.
I:H - A successful attack can modify victim-writable files through  
symlink redirection.
A:H - Overwriting or truncating important user files can cause  
significant availability loss.
Impact: Moderate. Based on Red Hat's severity guidance, this issue can  
compromise integrity and availability of victim-writable files, but it is a  
local, workflow-dependent attack that requires a local account, PID  
prediction or broad pre-creation, and victim execution of an affected  
`gprofng` path. The current evidence does not show remote compromise or  
privilege escalation, so Moderate fits better than Important.
Embargo: no
Reason: The flaw is local, requires multiple preconditions, and appears  
suitable for normal coordinated public remediation without extended embargo  
handling.
Acknowledgement: Aisle Research
Vulnerability Details: `gprofng` constructs a temporary directory name in  
`/tmp` from the current UID and PID, then ignores failure from `mkdir()`.  
If that directory already exists, the code still returns file paths beneath  
it. Later code opens predictable names inside that directory without  
anti-symlink protections.
```cpp
if (tmp_dir_name == NULL)
{
tmp_dir_name = dbe_sprintf ("/tmp/analyzer.%llu.%lld",
(unsigned long long) getuid (), (long long)  
getpid ());
mkdir (tmp_dir_name, S_IRWXU);
}
```
One demonstrated sink is the printer-output path:
```cpp
tmp_file = dbeSession->get_tmp_file_name ("print", false);
out_file = fopen (tmp_file, "w");
```
Another write path also uses a temp-derived pathname with `O_CREAT |  
O_WRONLY`:
```cpp
stabsTmp = dbeSession->get_tmp_file_name (base, false);
obj = open64 (stabsTmp, O_CREAT | O_WRONLY | O_LARGEFILE, 0600);
```
In practical terms, if an attacker creates  
`/tmp/analyzer.<victim_uid>.<future_pid>` first and places a symlink such  
as `print` inside it, a later victim `gprofng` process with the matching  
PID may follow that symlink and clobber a victim-writable target file. The  
strongest directly supported path is the `Print.cc` flow above; the  
additional sink in `Module.cc` suggests the pattern is not isolated to one  
caller.
Steps to reproduce:
1. On a shared Linux system, prepare two accounts: `attacker` and `victim`.
2. As `attacker`, determine the victim UID and pre-create a range of  
candidate directories named `/tmp/analyzer.<victim_uid>.<pid>`.
3. Inside each candidate directory, place a symlink named `print` to a  
victim-writable target file. The directory permissions must still allow the  
victim process to traverse the path.
4. As `victim`, run a `gprofng` workflow that reaches  
`er_print_common_display::open()` with printer output so that `print` is  
opened using `fopen(..., "w")`.
5. When the victim PID matches a pre-created directory, the target file is  
truncated or overwritten via the symlink.
Mitigation: Until a code fix is available, avoid running affected `gprofng`  
workflows on shared systems with untrusted local users. Where possible,  
execute the tool in an environment with a private `/tmp` view or equivalent  
filesystem isolation so that another local user cannot pre-create the  
predictable directory path.
Proposed Fix: Replace the predictable UID+PID directory with a randomized  
directory created by `mkdtemp()`, and fail safely if directory creation  
does not succeed. As follow-up hardening, the file-opening sites should  
also use anti-symlink patterns such as `O_NOFOLLOW | O_EXCL`, `mkstemp()`,  
or `openat()` on a trusted directory descriptor.
```diff
diff --git a/gprofng/src/DbeSession.cc b/gprofng/src/DbeSession.cc
— a/gprofng/src/DbeSession.cc
+++ b/gprofng/src/DbeSession.cc
@@ -489,12 +489,23 @@ char *
DbeSession::get_tmp_file_name (const char *nm, bool for_java)
{
if (tmp_dir_name == NULL)
{
     tmp_dir_name = dbe_sprintf ("/tmp/analyzer.%llu.%lld",

                                 (unsigned long long) getuid (), (long  
long) getpid ());

     mkdir (tmp_dir_name, S_IRWXU);
+      char *tmpl = dbe_sprintf ("/tmp/analyzer.%llu.XXXXXX",
+                                (unsigned long long) getuid ());
+      if (mkdtemp (tmpl) == NULL)
+        {
+          free (tmpl);
+          return NULL;
+        }
+      tmp_dir_name = tmpl;
      }
    char *fnm = dbe_sprintf ("%s/%s", tmp_dir_name, nm);
    if (for_java)
      for (char *s = fnm + strlen (tmp_dir_name) + 1; *s; s++)
        if (*s == '/')
          *s = '.';
    return fnm;
  }
```


------
This report was generated using AI technology. Always review AI-generated  
content prior to use