Skip to content
Memory corruption Write-up Advanced

What's Up, Doc? An OSec Approach to the Looney Tunables Bug (CVE-2023-4911)

A buffer overflow in glibc's dynamic linker, triggered by a malformed GLIBC_TUNABLES environment variable, allows an attacker to write out of bounds and manipulate the library search path. This can lead to privileged code execution when a SUID root binary is launched.

Rory Guidry Follow

Published on osec.com

CVE-2023-4911 is a serious one. The vulnerability sits deep in the GNU C Library (glibc), in the dynamic linker/loader ld.so, the component responsible for launching every dynamically linked executable on the system, including common SUID root programs such as su.

Rory Guidry, on osec.com

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

The parse_tunables function in ld.so incorrectly handles non-colon-separated SXID_IGNORE tunables, causing an out-of-bounds write when the same string is appended twice.

Impact

An attacker could achieve privileged code execution as root, but ASLR makes exploitation probabilistic and requires many attempts.

What the attacker needed

Local access to run a program; vulnerable glibc version; SUID root binary present

The fix

The vulnerability was fixed by patching or upgrading from the vulnerable glibc version.

How it was found

  1. Craft a GLIBC_TUNABLES environment variable containing two non-colon-separated SXID_IGNORE tunables.
  2. Pass this environment to an SUID root binary via execve, causing an out-of-bounds write in ld.so.
  3. Use the overflow to overwrite the l_info[DT_RPATH] pointer in struct link_map.
  4. Set the d_val offset to point to a directory under attacker control.
  5. Launch the SUID binary again so ld.so loads a malicious library from that directory.
  6. Gain privileged code execution 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.

A common system program that runs with high privileges can be tricked by a specially crafted environment variable into loading a malicious library. This lets an attacker run their own code as the root user, taking full control of the machine.

What is Memory corruption?

Native code reads or writes memory it should not: overflows, use-after-free, type confusion. The core of browser, kernel and parser bugs.

More by Rory Guidry

View all

2 more disclosed reports, best first.

Similar reports

View all

Same bug class and techniques, clearest first.

Memory corruption

The lesson behind this report.

Native code reads or writes memory it should not: overflows, use-after-free, type confusion. The core of browser, kernel and parser bugs.