PHP vulnerabilities

CVE-2024-2961: the glibc iconv flaw that targets PHP

Illustration: CVE-2024-2961, the glibc iconv flaw targeting PHP

In spring 2024, a twenty-four-year-old flaw in the Linux C library changed the risk level of many PHP applications. CVE-2024-2961 does not affect WordPress directly, but it can turn a simple file read into remote code execution. This article explains the mechanism without an exploitation recipe, who is affected, and above all how to check and fix your hosting.

What CVE-2024-2961 fixes

The flaw lies in the iconv() function of the GNU C Library (glibc), which converts text from one character set to another. When converting to the ISO-2022-CN-EXT character set, the function can write up to 4 bytes past the output buffer it was given. This overflow can crash the application or overwrite a neighboring variable in memory. According to the official glibc advisory, the faulty code was introduced in 2000 and had never been spotted.

The National Vulnerability Database gives it a CVSS 3.1 score of 7.3. The flaw was found by Charles Fol (Ambionics / Lexfo), reported on March 26, 2024 and disclosed on April 17, 2024, together with the fix.

Four-step diagram: file read, PHP filter, glibc overflow, code execution

Why PHP is the most exposed target

The key is the php://filter wrapper. PHP lets you apply convert.iconv conversions to any stream it reads. An attacker who has a way to make the application read a file can ask it to convert that stream to ISO-2022-CN-EXT, and thereby trigger the glibc bug. According to the researcher's analysis, all of PHP's standard read functions are affected:

  • file_get_contents(), file(), readfile(), fgets()
  • getimagesize() and SplFileObject
  • write functions such as file_put_contents() are affected too
  • on the other hand, functions that only test a file (file_exists(), is_file()) do not trigger the conversion

The technique was demonstrated on PHP versions from 7.0 to 8.3. In other words, updating PHP is not enough: it is the server's glibc that needs fixing. The phar:// wrapper is not involved here either, unlike in other deserialization attacks.

The filter is not the only way in. The researcher lists several ways to route a stream to iconv: an SQL injection abusing LOAD DATA LOCAL INFILE, an XXE flaw, and some image processing or translation libraries. The common thread is always the same: the attacker needs a way to make the application handle content they control, with an unpatched glibc underneath. That is why the fix happens at the system level, not in a single plugin.

A WordPress case and mass exploitation

The first public demonstration targeted a WordPress site running the BuddyForms 2.7.7 plugin, vulnerable to CVE-2023-26326 (unauthenticated deserialization). That plugin flaw provided the file read primitive needed to reach glibc. It is a useful reminder: a plugin flaw rated medium can become critical once chained with a system defect.

The danger did not stay theoretical. Starting in summer 2024, the campaign known as CosmicSting chained CVE-2024-34102 (an XXE flaw in Adobe Commerce / Magento) with CVE-2024-2961 to achieve code execution. According to Sansec, as reported by BleepingComputer in October 2024, more than 4,000 stores (about 5% of all Adobe Commerce and Magento stores) were compromised. The named victims included major brands.

Timeline of CVE-2024-2961, from 2000 to mass exploitation in late 2024

Affected and fixed glibc versions

The flaw affects glibc 2.39 and all earlier versions. It is fixed in version 2.40 and backported to the maintenance branches. On a server, what matters is almost always your distribution's package, not the upstream version.

SourceStatusDetails
Upstream glibc < 2.40VulnerableFaulty code present since the 2.1.93 branch
glibc 2.40FixedReference fix, April 2024
Branches 2.32 to 2.39Fixed by backportThrough distribution packages
Debian 12 (bookworm)Fixed2.36-9+deb12u6 and later
Debian 13 (trixie)Fixed2.37-18 and later

The package versions come from the Debian trackers and the glibc advisory; confirm the exact status with your own distribution's bulletins (Red Hat, Ubuntu, AlmaLinux, and so on).

How to tell if you are affected

On shared hosting, you do not always control glibc, but you can often check it and alert your support team. If you have SSH access:

  1. List the active character sets: iconv -l | grep -E 'CN-?EXT'. Output containing ISO-2022-CN-EXT means the vulnerable module is present.
  2. Compare the glibc package version (ldd --version) with the fix announced by your distribution.
  3. Ask your host when the glibc fix was applied to your servers.

According to Zend, an application is not exposed through this path if any of these conditions holds: it does not use the iconv extension, glibc is up to date, the ISO-2022-CN-EXT character set has been removed from the configuration, or the application only passes explicitly allowed character sets to iconv.

Fixing it and reducing the risk

The only real fix is to update glibc. As Zend and Red Hat point out, no PHP patch will be released, since the defect is in the system library. Until the update is applied, Red Hat and Rocky Linux document a temporary mitigation: remove the ISO-2022-CN-EXT character set by commenting out the three matching lines in gconv-modules-extra.conf, then rebuild the cache with iconvconfig. This is a job for a system administrator, after testing, because it can break applications that actually use that character set.

Beyond that, two habits limit the reach of such a chain. First, reduce the number of plugins that can read a file based on a parameter: they are what provides the initial primitive. Second, watch your logs for attempts to read sensitive files, often a sign of a reconnaissance phase before a chained attack. A system flaw patched quickly always beats detection after the fact.

Key takeaways

  • CVE-2024-2961 is an overflow in glibc (iconv, ISO-2022-CN-EXT character set), not in PHP: updating PHP alone does not protect you.
  • A file read through a plugin flaw, chained with this bug, can lead to code execution.
  • glibc 2.39 and earlier are affected; the fix is in 2.40 and in backported packages.
  • Check your host's glibc version and the date of the fix; keep PHP and your plugins up to date.

Where WP Feint fits

To be clear: WP Feint does not fix a flaw in glibc, PHP, a theme or a plugin. Its role is to reduce the attack surface and the noise, and to complement sound maintenance, never to replace it. Three contributions are relevant here. First, hardening and hiding public signatures slow down the automated profiling that often precedes exploitation. Second, bot traps count requests to sensitive paths (/.env, .sql backups, paths of other software), which gives an early signal of reconnaissance. Finally, core integrity checking (Pro) helps detect a modification after a compromise. The real protection remains updating glibc, PHP and plugins, backed by tested backups.

Videos to learn more

Sources

Other sources consulted: official documentation, official vendor pages, security research publications and trade press articles.

Start free, go Pro when you’re ready

The free version already hides WordPress and moves the login page. Pro adds aliases, two-factor authentication and monitoring.