CVE-2023-4911

Description

A buffer overflow was discovered in the GNU C Library's dynamic loader ld.so while processing the GLIBC_TUNABLES environment variable. This issue could allow a local attacker to use maliciously crafted GLIBC_TUNABLES environment variables when launching binaries with SUID permission to execute code with elevated privileges.

Statement

This vulnerability was introduced in glibc version 2.34. RHEL-8 ships glibc 2.28, which is not originally affected by this vulnerability. However, the commit that introduced this vulnerability was backported to RHEL-8.5, making this version and onward vulnerable. RHEL-8.4 and older are not affected by this vulnerability.

Mitigation

For customers who cannot update immediately and do not have Secure Boot feature enabled, the issue can be mitigated using the provided SystemTap script with the following steps. When enabled, any setuid program invoked with GLIBC_TUNABLES in the environment will be terminated immediately. To invoke the setuid program, users will then have to unset or clear the GLIBC_TUNABLES envvar, e.g. `GLIBC_TUNABLES= sudo` .

Note that these mitigation steps will need to be repeated if the system is rebooted.

1) Install required systemtap packages and dependencies as per - https://access.redhat.com/solutions/5441

2) Create the following systemtap script, and name it stap_block_suid_tunables.stp:

function has_tunable_string:long()
{
name = "GLIBC_TUNABLES"

mm = @task(task_current())->mm;
if (mm)
{
env_start = @mm(mm)->env_start;
env_end = @mm(mm)->env_end;

if (env_start != 0 && env_end != 0)
while (env_end > env_start)
{
cur = user_string(env_start, "");
env_name = tokenize(cur, "=");

if (env_name == name && tokenize("", "") != "")
return 1;
env_start += strlen (cur) + 1
}
}

return 0;
}

probe process("/lib*/ld*.so*").function("__tunables_init")
{
atsecure = 0;
/* Skip processing if we can't read __libc_enable_secure, e.g. core dump
handler (systemd-cgroups-agent and systemd-coredump). */
try { atsecure = @var("__libc_enable_secure"); }
catch { printk (4, sprintf ("CVE-2023-4911: Skipped check: %s (%d)", execname(), pid())); }
if (atsecure && has_tunable_string ())
raise (9);
}

3) Load the systemtap module into the running kernel:

    stap -g -F -m stap_block_suid_tunables stap_block_suid_tunables.stp

4) Ensure the module is loaded:

     lsmod | grep -i stap_block_suid_tunables
stap_block_suid_tunables 249856 0

5) Once the glibc package is updated to the version containing the fix, the systemtap generated kernel module can be removed by running:

    rmmod stap_block_suid_tunables

If Secure Boot is enabled on a system, the SystemTap module must be signed. An external compiling server can be used to sign the generated kernel module with a key enrolled into the kernel's keyring or starting with SystemTap 4.7 you can sign a module without a compile server. See further information here - https://www.redhat.com/sysadmin/secure-boot-systemtap

Common Vulnerability Scoring System (CVSS) Score Details

Info alert:Important note

CVSS scores for open source components depend on vendor-specific factors (e.g. version or build chain). Therefore, Red Hat's score and impact rating can be different from NVD and other vendors. Red Hat remains the authoritative CVE Naming Authority (CNA) source for its products and services (see Red Hat classifications).

CVSS v3 Score Breakdown

Red HatNVDcve.org
Base Score7.87.87.8
Attack VectorLocalLocalLocal
Attack ComplexityLowLowLow
Privileges RequiredLowLowLow
User InteractionNoneNoneNone
ScopeUnchangedUnchangedUnchanged
ConfidentialityHighHighHigh
Integrity ImpactHighHighHigh
Availability ImpactHighHighHigh

Vector

Red Hat: CVSS:3.1/AV:L/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:H

NVD: CVSS:3.1/AV:L/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:H

cve.org: CVSS:3.1/AV:L/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:H

Understanding the Weakness (CWE)

Availability

Technical Impact: DoS: Crash, Exit, or Restart; DoS: Resource Consumption (CPU); DoS: Resource Consumption (Memory)

Buffer overflows generally lead to crashes. Other attacks leading to lack of availability are possible, including putting the program into an infinite loop.

Integrity,Confidentiality,Availability,Access Control

Technical Impact: Execute Unauthorized Code or Commands; Bypass Protection Mechanism; Modify Memory

Buffer overflows often can be used to execute arbitrary code, which is usually outside the scope of a program's implicit security policy. Besides important user data, heap-based overflows can be used to overwrite function pointers that may be living in memory, pointing it to the attacker's code. Even in applications that do not explicitly use function pointers, the run-time will usually leave many in memory. For example, object methods in C++ are generally implemented using function pointers. Even in C programs, there is often a global offset table used by the underlying runtime.

Integrity,Confidentiality,Availability,Access Control,Other

Technical Impact: Execute Unauthorized Code or Commands; Bypass Protection Mechanism; Other

When the consequence is arbitrary code execution, this can often be used to subvert any other security service.

Acknowledgements

Red Hat would like to thank Qualys Research Labs for reporting this issue.

Frequently Asked Questions

Want to get errata notifications? Sign up here.