Skip to content
Memory corruption Write-up Advanced

Uncursing the ncurses: Memory corruption vulnerabilities found in library

Microsoft found several memory corruption flaws in the ncurses library, including a stack information leak, a type confusion, an off-by-one, a heap overflow and a null-pointer dereference. By poisoning the TERMINFO environment variable, an attacker could chain these to leak memory and corrupt the heap, potentially elevating privileges in set-UID programs such as macOS top.

MsftSecIntel Follow

Published on microsoft.com

Microsoft has discovered a set of memory corruption vulnerabilities in a library called ncurses, which provides APIs that support text-based user interfaces (TUI). Released in 1993, the ncurses library is commonly used by various programs on Portable Operating System Interface (POSIX) operating systems, including…

Microsoft Threat Intelligence, on microsoft.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

Impact

The vulnerabilities could have been exploited to elevate privileges and run code within a targeted program’s context, though the text notes this requires a multi-stage attack chaining several flaws.

What the attacker needed

Ability to set TERMINFO or HOME; a set-UID program using ncurses; crafted terminfo database file

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.

ncurses is a library that many text-based programs use to draw on a terminal. It reads a description of the terminal from a file, and the path to that file can be changed with an environment variable, which is a setting passed to a program when it starts. The researchers showed that a crafted terminal description file can make ncurses read or write memory it should not, and because some programs run with extra privileges, this could let an attacker take over.

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.

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.