CVE-2026-139881: libexpat falls back to a predictable hash salt after a short read of /dev/urandom

ByLinuxtastic

December 1, 2026 #CVE, #libexpat

libexpat protects its internal hash tables, the ones that hold element and attribute names, against collision flooding by salting the hash with random bytes taken at parser creation. On Linux the first choice for those bytes is getrandom() and the next is /dev/urandom, read in writeRandomBytes_dev_urandom(). That function accepted a short read, fewer bytes than asked for, and fell back to a predictable salt rather than reading again. The VulnCheck record says attackers “can craft XML documents with names colliding in the parser’s hash tables, causing hash flooding and excessive CPU consumption”. The fix is pull request #1542, whose page GitHub rate-limited on every attempt for this page, so whether it is merged and which release carries it is not established, and this page is a draft until it is. Treat an unexplained CPU spike in an XML-parsing process as a possible collision flood, and update libexpat when a release names this CVE.

CVE-2026-139881 at a glance.

Componentlibexpat, writeRandomBytes_dev_urandom() in expat/lib/random_dev_urandom.c and the salt generation it feeds in xmlparse.c (generate_hash_secret_salt), used when getrandom() is unavailable or the build was told to use /dev/urandom
Affected versionslibexpat 2.2.3 through 2.11.0, per the VulnCheck CNA record
Fixed innot established on 1 December 2026: the record names pull request #1542 as the fix, and GitHub rate-limited its page on every attempt, so its state (open or merged), its milestone and its commit are unknown to this page. 2.11.0 of 23 November does not list the CVE in its Changes file, and no later release exists. The Debian, Ubuntu and Red Hat trackers also refused automated readers for this id. This is the unknown field that keeps the page a draft
SeverityVulnCheck (CNA) CVSS 4.0 6.3 Medium (AV:N/AC:H/AT:P/PR:N/UI:N/VC:N/VI:N/VA:L) and CVSS 3.1 3.7 Low (AV:N/AC:H/PR:N/UI:N/S:U/C:N/I:N/A:L), CWE-331 (insufficient entropy). No distribution rating could be read; NVD Awaiting Analysis with both VulnCheck scores and no score of its own
Exploited in the wildNot on CISA’s Known Exploited Vulnerabilities list as of 1 December 2026 (catalogue 2026.11.30). EPSS: no score yet on 1 December 2026
Who is exposedA process using libexpat on a host where the salt comes from /dev/urandom rather than getrandom(), which on a modern glibc Linux means a build configured with XML_DEV_URANDOM and without getrandom() support, or an old kernel; and then only when a read returns short, which /dev/urandom does rarely on Linux (a signal during the read is the usual cause). The attacker needs to predict the fallback salt and supply a document with thousands of colliding names, which is the AC:H in the vector; the result is CPU time, not memory corruption
PublishedCVE record 30 November 2026 (VulnCheck CNA); this page built 1 December 2026 as a draft, last updated 1 December 2026

What it is

A hash table is fast only while its keys spread across buckets; an attacker who knows the hash function can choose keys that all land in one bucket and turn every lookup into a linear scan. libexpat has defended against that for years by mixing a per-parser secret salt into the hash, so the attacker cannot predict which names collide. The salt has to come from somewhere, and libexpat tries, in order, the platform’s system random source (getrandom() or arc4random), then /dev/urandom, then a fallback built from the clock, the process id and addresses, which is predictable by design and is there only so the parser works on systems with nothing better.

The /dev/urandom reader asked for the salt’s worth of bytes in one read() and treated any positive return as success. A short read, legal for the device and seen in practice when a signal interrupts the call, left part of the buffer unfilled, and the code then fell through to the predictable fallback rather than looping to fill the rest. The record describes the outcome as insufficient entropy, CWE-331: on the affected path the salt is sometimes guessable, and a guessable salt is no defence against a collision flood. How often the path is taken on a given host is the practical question, and on a mainstream Linux build with getrandom() compiled in the answer is never.

The fix is pull request #1542. Its page could not be read for this page, GitHub having rate-limited it on every attempt, so its description, its merge state and the release it targets are not stated here; the record’s other references are the source lines in random_dev_urandom.c and xmlparse.c at the 2.11.0 tag, which is where the behaviour described above lives. When the pull request or a release note is readable, the Fixed-in row will be filled in and the page published.

Who is affected on Linux

Each row is what the distribution’s own security tracker said on 1 December 2026; the link in the row is the tracker page, which will be newer than this one. Three of the four trackers refused automated readers for this id, so the table is thinner than usual and nothing in it is inferred.

DistributionStatusFixed package
AlpineNot consulted for this page; the Alpine tracker has refused automated readers on every earlier run—
DebianTracker unreachable on 1 December 2026 (client error); nothing inferred—
UbuntuTracker unreachable on 1 December 2026 (client error on two attempts); nothing inferred—
RHEL, Rocky, Alma, CentOS StreamTracker unreachable on 1 December 2026 (client error on the hydra JSON); nothing inferred—
openSUSE/SLEPage returned empty on 1 December 2026; nothing inferred—
Static and vendored copies: Python’s bundled pyexpat, language runtimes, embedded firmware, container images built from sourceThe upstream release applies; each bundle is fixed when its own project rebuilds against a fixed libexpatper bundle

How to check

Two questions: does the installed libexpat take its salt from getrandom(), in which case the /dev/urandom reader is never called, and if not, is any process that parses untrusted XML showing the CPU profile of a collision flood. The first is a build-configuration question and settles it for most hosts.

# 1. which libexpat is installed, and which build variant: libexpat.so.1 is the byte build, libexpatw.so.1 the XML_UNICODE (wide) build
dpkg -l libexpat1 2>/dev/null | awk '/^ii/ {print $2, $3}'; rpm -q expat 2>/dev/null; apk info -v expat 2>/dev/null
ls -l /usr/lib/*/libexpat*.so.1* /usr/lib64/libexpat*.so.1* 2>/dev/null
strings $(ls /usr/lib/*/libexpat.so.1 /usr/lib64/libexpat.so.1 2>/dev/null | head -1) | grep -E '^expat_[0-9]' | head -1

# 2. which random source the build uses: a getrandom()-capable build imports it; a /dev/urandom build opens the device
objdump -T $(ls /usr/lib/*/libexpat.so.1 /usr/lib64/libexpat.so.1 2>/dev/null | head -1) 2>/dev/null | grep -E ' (getrandom|arc4random)' || echo "no getrandom/arc4random import: /dev/urandom path in use"
grep -sE 'HAVE_GETRANDOM|HAVE_SYSCALL_GETRANDOM|XML_DEV_URANDOM' /usr/include/expat_config.h 2>/dev/null
# confirm at run time: a getrandom build never opens the device
strace -f -e trace=openat,getrandom python3 -c 'import xml.parsers.expat as e; e.ParserCreate()' 2>&1 | grep -E 'urandom|getrandom' | head -3

# 3. a collision flood looks like one parsing process pinned at 100% on a small document
top -b -n 1 | awk 'NR>7 && $9>90 {print $1, $9, $12}'

A library that imports getrandom(), or whose strace shows a getrandom call and no /dev/urandom open, never reaches the affected reader and has nothing to do beyond the normal update. A build that opens the device is in the path, and the exposure is then whether it parses attacker-supplied XML; a process pinned on CPU for a small document is the symptom. Note that glibc’s getrandom() wrapper has been available since 2.25 (2017), so a distribution build on the device path would be unusual.

How to fix it

There is no fixed release to install on 1 December. When one appears, the update is the normal package update followed by a restart of whatever maps the library; this page will name the version. Until then the control is at the application: cap what an attacker can make the parser do.

# when a fixed libexpat ships (watch the Changes file and your distribution's notice for CVE-2026-139881)
sudo apt update && sudo apt install --only-upgrade libexpat1      # Debian / Ubuntu
sudo dnf update expat                                             # RHEL family
sudo zypper update expat libexpat1                                # openSUSE / SLE
# then restart every process with the old library mapped
sudo needrestart -r a 2>/dev/null || grep -l 'libexpat.*(deleted)' /proc/[0-9]*/maps 2>/dev/null | cut -d/ -f3 | sort -un

A collision flood needs a document with a great many distinct names, so a size limit in front of the parser bounds the damage whether or not the salt is predictable. For an application you control, a cap on the request body before parsing is the simplest form; for a service behind a reverse proxy, the proxy does it:

# NGINX in front of an XML-accepting service: refuse bodies that could carry thousands of names
client_max_body_size 1m;

# Python: refuse before parsing rather than after
if len(data) > 1_000_000:
    raise ValueError("XML document too large")
parser = xml.parsers.expat.ParserCreate()
parser.Parse(data, True)

Do not patch around this by seeding the salt yourself with XML_SetHashSalt() from a value you computed: the function exists, but a salt derived from anything the attacker can observe is the problem this CVE describes, and a fixed one is worse. And do not disable the billion-laughs protections to “save CPU” while investigating a spike; they address a different amplification and removing them only adds a second way to burn time.

Sources

  • CVE-2026-139881 at CVE.org — the VulnCheck CNA record (30 November 2026): the description, the 2.2.3–2.11.0 range, the CVSS 4.0 and 3.1 vectors and CWE-331
  • libexpat pull request #1542 — the fix named in the record; GitHub rate-limited the page on every attempt for this page, so its state and content are not described here
  • random_dev_urandom.c at R_2_11_0 and xmlparse.c at R_2_11_0 — the affected reader and the salt generation, as the record cites them
  • libexpat Changes at R_2_11_0 — the 2.11.0 release notes of 23 November 2026, which do not list this CVE
  • NVD entry — Awaiting Analysis; published 30 November; VulnCheck’s 3.7 (3.1, primary) and 6.3 (4.0, secondary); CWE-331; no NVD score
  • Distribution trackers: Debian, Ubuntu and Red Hat all unreachable on 1 December 2026; SUSE empty page
  • CISA KEV catalogue 2026.11.30, not listed · EPSS: no score on 1 December 2026

Related reading

This advisory page was assembled from the primary sources listed above on 1 December 2026 and is updated when they change. The facts are theirs; the checks and the ordering are ours. If a row in the distribution table is out of date, the tracker link in that row is the current word.