CVE-2023-29491

7.8 HIGH

📋 TL;DR

This vulnerability in ncurses allows local users to trigger memory corruption by providing malformed terminfo database files. It affects setuid applications using vulnerable ncurses versions, potentially allowing privilege escalation. The issue stems from improper validation of terminfo data.

💻 Affected Systems

Products:
  • ncurses
Versions: All versions before 6.4 20230408
Operating Systems: Linux, Unix-like systems
Default Config Vulnerable: ⚠️ Yes
Notes: Only exploitable when used by setuid applications. Requires local user access and ability to write to terminfo directories.

📦 What is this software?

⚠️ Risk & Real-World Impact

🔴

Worst Case

Local privilege escalation to root via exploitation of setuid applications, leading to complete system compromise.

🟠

Likely Case

Local privilege escalation to the user running the setuid application, potentially gaining elevated privileges.

🟢

If Mitigated

No impact if proper file permissions prevent users from writing to terminfo directories or if setuid applications don't use vulnerable ncurses functions.

🌐 Internet-Facing: LOW - This is a local privilege escalation vulnerability requiring local access.
🏢 Internal Only: HIGH - Internal users with local shell access can potentially exploit this to gain elevated privileges.

🎯 Exploit Status

Public PoC: ⚠️ Yes
Weaponized: LIKELY
Unauthenticated Exploit: ✅ No
Complexity: MEDIUM

Exploitation requires local access and knowledge of vulnerable setuid applications. Proof-of-concept code has been published in security advisories.

🛠️ Fix & Mitigation

✅ Official Fix

Patch Version: ncurses 6.4 20230408 and later

Vendor Advisory: http://ncurses.scripts.mit.edu/?p=ncurses.git%3Ba=commit%3Bh=eb51b1ea1f75a0ec17c9c5937cb28df1e8eeec56

Restart Required: No

Instructions:

1. Update ncurses package to version 6.4 20230408 or later. 2. For Debian/Ubuntu: apt update && apt upgrade ncurses. 3. For RHEL/CentOS: yum update ncurses. 4. For Fedora: dnf update ncurses. 5. Recompile any applications statically linked to vulnerable ncurses versions.

🔧 Temporary Workarounds

Restrict terminfo directory permissions

linux

Prevent users from writing to terminfo directories that setuid applications might access.

chmod 755 /usr/share/terminfo
chmod 755 $HOME/.terminfo
chmod 755 /etc/terminfo

Remove setuid bit from vulnerable applications

linux

Remove setuid permissions from applications using ncurses until patched.

chmod u-s /path/to/vulnerable/application

🧯 If You Can't Patch

  • Remove or disable setuid applications that use ncurses
  • Implement strict file permissions on terminfo directories and user home directories

🔍 How to Verify

Check if Vulnerable:

Check ncurses version: ncursesw6-config --version or dpkg -l libncurses* | grep ^ii

Check Version:

ncursesw6-config --version || dpkg -l libncurses* | grep ^ii || rpm -q ncurses

Verify Fix Applied:

Verify installed ncurses version is 6.4 20230408 or later: ncursesw6-config --version | grep -q '6.4' && echo 'Patched'

📡 Detection & Monitoring

Log Indicators:

  • Failed setuid executions
  • Abnormal terminfo file access patterns
  • Memory corruption errors in application logs

Network Indicators:

  • None - this is a local exploit

SIEM Query:

process.name:setuid AND file.path:/usr/share/terminfo/* OR file.path:$HOME/.terminfo/*

🔗 References

📤 Share & Export