Skip to content
Memory corruption Write-up Advanced

Exploit & Debug Looney Tunables CVE-2023-4911 Local Privilege Escalation in the glibc's ld.so

A buffer overflow in the glibc dynamic loader's handling of the GLIBC_TUNABLES environment variable allows an attacker to overwrite the link_map structure and set DT_RPATH to a trusted directory, causing the loader to load a malicious libc from that directory. This can lead to local privilege escalation to root when a SUID binary is executed.

Mohamed Sayed Follow

Published on flex0geek.blogspot.com

on November 24, 2023

Mohamed Sayed (Flex), on flex0geek.blogspot.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

Likely a buffer overflow in the parsing of the GLIBC_TUNABLES environment variable within glibc's dynamic loader, allowing corruption of the link_map structure.

Impact

An attacker could escalate privileges to root by executing a SUID binary after setting up the malicious library and environment, though the exploit requires brute-forcing a stack address and may take several minutes.

What the attacker needed

Local access to the system; ability to set environment variables; a SUID binary that uses the dynamic loader; ASLR enabled (brute-force needed)

How it was found

  1. Disable ASLR to make debugging easier.
  2. Find the offset of the .dynstr section in the SUID binary using objdump.
  3. Determine the offset of a string (a double quote) before .dynstr by subtracting 20 from the section start.
  4. Copy libc.so.6, inject shellcode at offset 171456, and place it in a directory named with that string.
  5. Send a normal GLIBC_TUNABLES value, then a malformed one to trigger the overflow and overwrite link_map.
  6. Set l_info[DT_RPATH] to point to a stack address containing the offset of the trusted directory string, then run the SUID binary to load the malicious libc and gain 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.

The glibc loader is a program that prepares other programs to run, including finding and loading shared libraries. A bug in how it reads an environment variable called GLIBC_TUNABLES lets an attacker write past a buffer and change a setting that tells the loader where to look for libraries. By pointing that setting to a folder they control, the attacker can make a privileged program load a malicious library and run their code as root.

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 Mohamed Sayed

View all

9 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.