Bug 2211666 - Ignore TERMINFO and HOME environment variables under root
Summary: Ignore TERMINFO and HOME environment variables under root
Keywords:
Status: ON_QA
Alias: None
Product: Red Hat Enterprise Linux 9
Classification: Red Hat
Component: ncurses
Version: 9.1
Hardware: Unspecified
OS: Unspecified
unspecified
unspecified
Target Milestone: rc
: ---
Assignee: Miroslav Lichvar
QA Contact: Ondrej Mejzlik
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2023-06-01 11:46 UTC by Miroslav Lichvar
Modified: 2023-08-15 13:52 UTC (History)
1 user (show)

Fixed In Version: ncurses-6.2-9.20210508.el9
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed:
Type: Bug
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Red Hat Issue Tracker RHELPLAN-158800 0 None None None 2023-06-01 11:48:26 UTC

Description Miroslav Lichvar 2023-06-01 11:46:02 UTC
Description of problem:
ncurses uses the TERMINFO and HOME environment variables to search for terminfo entries. If there is a bug in parsing or handling (e.g. CVE-2023-29491), it can be exploited for setuid applications.

ncurses has configure option --disable-root-environ to not use there variables when running as root.

Consider building ncurses with this option to avoid this class of security issues.

How reproducible:
always

Steps to Reproduce:
1. TERMINFO="/tmp/terminfo" strace bash -i -c true |& grep terminfo

Actual results:
stat("/tmp/terminfo", 0x55b8e99c2900)   = -1 ENOENT (No such file or directory)
stat("/root/.terminfo", 0x55b8e99c2900) = -1 ENOENT (No such file or directory)
stat("/etc/terminfo", {st_mode=S_IFDIR|0755, st_size=6, ...}) = 0
stat("/usr/share/terminfo", {st_mode=S_IFDIR|0755, st_size=195, ...}) = 0
access("/etc/terminfo/s/screen", R_OK)  = -1 ENOENT (No such file or directory)
access("/usr/share/terminfo/s/screen", R_OK) = 0
openat(AT_FDCWD, "/usr/share/terminfo/s/screen", O_RDONLY) = 3


Expected results:
No access to /tmp/terminfo and /root/.terminfo is observed

Additional info:


Note You need to log in before you can comment on or make changes to this bug.