CVE 2019–19726: OpenBSD Local Privilege Escalation via RLIMIT_D
A flaw in OpenBSD's dynamic loader meant that when memory allocation failed, the dangerous LD_LIBRARY_PATH environment variable was not removed before running set-uid programs. A local unprivileged user could exploit this to load a malicious library and execute code as root.
Published on dhimasln.medium.com
Local Privilege Escalation (LPE) pada dynamic loader OpenBSD (ld.so) CVE-2019-19726 yang memungkinkan pengguna lokal tanpa hak istimewa menjadi root pada instalasi default melalui program set-uid seperti chpass atau passwd. Intinya: kondisi memori rendah + variabel lingkungan LDLIBRARYPATH yang tidak dibersihkan…
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 loader's error handling when memory allocation fails leaves LD_LIBRARY_PATH in the environment, and a subsequent exec of a non-set-uid child allows it to be used again.
Impact
A local unprivileged user could escalate to root on a default OpenBSD installation, as demonstrated by reading a root-owned file.
What the attacker needed
Local user account; ability to compile C code; writable directory (e.g., /tmp)
The fix
The vulnerability was patched by the OpenBSD team.
How it was found
- Create a malicious shared library with a constructor that sets uid/gid to 0 and spawns a shell.
- Compile the library with the same name as a library used by a set-uid program such as pwd_mkdb (e.g., libutil.so.13.1).
- Write a program that sets RLIMIT_DATA to a large value and sets LD_LIBRARY_PATH to the current directory, then execs chpass.
- Run the exploit program with /usr/bin/chpass as argument.
- The loader fails to clear LD_LIBRARY_PATH, and when chpass execs pwd_mkdb, the malicious library is loaded and its constructor runs as root.
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.
When a program runs with special root privileges, the system loader normally strips out certain environment variables that could be abused to load attacker-controlled code. This bug meant that under low-memory conditions, that stripping failed, so an attacker could trick the program into loading a malicious library and gain root access.
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.