WordPress pingback and Brotli RCE

Fortbridge diagram of the pinned WordPress pingback and Brotli command-execution path ending with web-process id output

Introduction and motivation

After our WordPress libheif RCE investigation, the Brotli decoder advisory caught our attention. We wanted to know whether another native-library flaw could be reached through an ordinary WordPress feature. Pingbacks gave us a concrete question: what happens when WordPress fetches a page that claims to link to a post, and that page serves a crafted Brotli response?

Pingbacks have a security history of their own. WordPress 3.5.1 addressed server-side request forgery and port scanning through pingbacks; Sonar described a different blind SSRF in pingback URL handling in 2022. Those are separate issues, not evidence that either old bug remains unfixed or that the Brotli flaw is in WordPress Core. Pingback is the gift that keeps on giving.

Background: why a pingback reaches Brotli

A pingback.ping request tells WordPress that another page links to a post. To check it, the pinned WordPress 7.1.3 PHP code calls wp_safe_remote_get() on the supplied URL.

WordPress starts the fetch in PHP, but its Requests library uses the PHP cURL extension to perform the HTTP transfer through native libcurl. Requests enables the encodings supported by that libcurl build. If the origin replies with Content-Encoding: br and Brotli support is present, libcurl invokes the native Brotli decoder while curl_exec() runs. This is where execution crosses from PHP into the affected C library; WordPress does not decode Brotli itself.

In the tested request, the crafted stream caused a content-decoding error. Requests then retried the URL with decoding disabled. The retry response headers enter a collection that lowercases string header names with strtolower(). The abridged source below shows the retry and header-handling steps:

// Requests/Transport/Curl.php, WordPress 7.1.3, abridged
if (curl_errno($this->handle) === CURLE_WRITE_ERROR ||
    curl_errno($this->handle) === CURLE_BAD_CONTENT_ENCODING) {
    curl_setopt($this->handle, CURLOPT_ENCODING, 'none');
    $this->response_data = '';
    $this->response_bytes = 0;
    curl_exec($this->handle);
}

// Requests/Response/Headers.php, same release, abridged
if (is_string($offset)) {
    $offset = strtolower($offset);
}

The pinned WordPress source sets a 150 KB response limit (153600 bytes). Requests applies that limit in its PHP body callback after libcurl has processed the compressed stream; it does not cap the native decoder work. This lab used a large crafted response, not just a malformed header.

Vulnerability and exploit path

The Brotli advisory describes an out-of-bounds write in the native decoder, not a WordPress Core bug.

After the decode error, Requests retries without Brotli decompression. An attacker-controlled header name in the retry reaches strtolower(). In the affected lab process, the corrupted handler redirects that call to system, and the XML-RPC client receives the WordPress web process’s id output.

In a separate, one-worker GDB-assisted request, a hardware watchpoint recorded strtolower.handler changing from the live zif_strtolower address to the live zif_system address after a Brotli decoder store. That request also returned id output. This route requires reachable XML-RPC pingbacks, a post accepting them, an allowed fetch of the attacker-controlled URL, and a cURL stack using the affected Brotli decoder.

Proof of concept and independent evidence

Direct PoC: web-process id output.

Observed native handler write

The short version: the first malicious HTTP response reaches Brotli and the live watchpoint records PHP’s strtolower handler changing; the second malicious HTTP response supplies a header name that PHP lowercases; the same request’s XML-RPC response then contains id output.

In the fresh one-worker debugger run, an eight-byte hardware watchpoint followed PHP’s strtolower.handler field at 0x60d8bd25fce8. It fired immediately after movups %xmm0,(%r8) in the stock Brotli decoder: the field changed from the live zif_strtolower pointer to the live zif_system pointer.

The observed libphp.so base address was 0x7c76dfcf2000. Read-only inspection of the pinned module supplied these ELF symbol values:

  • zif_strtolower: +0x3dbe20 → 0x7c76e00cde20 (old handler value).
  • zif_system: +0x3b2a00 → 0x7c76e00a4a00 (new handler value).

Those sums match the watchpoint’s old and new values.

Live GDB hardware watchpoint showing strtolower.handler change from zif_strtolower to zif_system; named ProcessCommandsInternal, SafeProcessCommands, and BrotliDecoderDecompressStream frames.
Live GDB watchpoint: the PHP strtolower handler changed from zif_strtolower to zif_system during Brotli decoding. Open full size.

Reading the live GDB stack

  1. Frame #0 — the writer: ProcessCommandsInternal(safe=1) at decode.c:2194, immediately after the 16-byte store. GDB’s symbol lookup at this PC also reports SafeProcessCommands + 2884.
  2. Frame #1 — the safe wrapper: SafeProcessCommands at decode.c:2261.
  3. Frame #2 — the decoder entry: BrotliDecoderDecompressStream at 0x7c76dec79510, decode.c:2700.

In the exact decoder source, the safe path calls memmove16(copy_dst, copy_src) at decode.c:2193. A later, separate one-worker debugger run measured its 16-byte load and store: the destination began ten bytes before the eight-byte strtolower.handler field. The final six bytes of that store wrote handler offsets 0–5; offsets 6–7 were outside it. The same store also covered ten bytes immediately before the handler in the strtolower internal-function record: the upper two bytes of run_time_cache, the four-byte T temporary-variable count and four bytes of alignment padding.

The stock decoder’s base address observed in this process was 0x7c76dec72000. Adding the ELF virtual addresses 0x5fa4 and 0x7510 yields the writer and decoder runtime PCs 0x7c76dec77fa4 and 0x7c76dec79510.

Cropped GNOME Terminal static libphp.so symbols: zif_system 0x3b2a00 and zif_strtolower 0x3dbe20; not a live debugger trace.
Separate static symbol inspection: zif_system +0x3b2a00 and zif_strtolower +0x3dbe20 in pinned libphp.so.

How the HTTP requests reach the handler

In each run, the client talks to WordPress; WordPress makes the two GETs to the supplied source-page URL.

  1. Client → WordPress: one 404-byte, unauthenticated POST /xmlrpc.php carries pingback.ping and a source-page URL. The client does not connect directly to the origin.
  2. WordPress → origin, first GET: GET /stock-trigger advertises Accept-Encoding: deflate, gzip, br, zstd. The origin’s scripted response declares Content-Encoding: br and records sending 23,069,816 body bytes in two fragments. During this fetch, native libcurl enters Brotli; the watched handler field changes while execution is in the decoder.
  3. WordPress → origin, second GET: the saved request to the same path now says Accept-Encoding: none, consistent with the decode-error retry in the pinned Requests source shown above. The origin records an HTTP 200 retry response with an attacker-controlled header name carrying the id command. When Requests lowercases that name with strtolower(), the watched handler now points to PHP’s existing system implementation.
  4. WordPress → client: the saved 666-byte HTTP/1.1 200 OK is an XML-RPC fault response, not a successful pingback confirmation. Its body contains the complete uid=33(www-data) gid=33(www-data) groups=33(www-data) line.

Why ASLR, NX and PIE did not stop this chain

The published PoC describes a partial overwrite of strtolower‘s internal-function handler. Our later debugger run independently confirmed the exact overlap: a 16-byte Brotli store copied six bytes into the low end of that eight-byte pointer. The copied six matched the low six bytes of the live zif_system pointer; the upper two bytes were untouched. The complete handler consequently pointed to zif_system, although only three of its byte values differed from the old zif_strtolower pointer. The disjoint source bytes matched the vector actually written. Both handlers were in the same randomized libphp.so mapping, so this reused a live pointer rather than predicting an absolute address.

The lab required Linux ASLR mode 2. In a read-only inspection of the exact pinned image, Apache was a PIE (Type: DYN) with a non-executable stack (GNU_STACK RW). The PHP module was also a shared DYN ELF.

Cropped GNOME Terminal static Apache ELF inspection: Type DYN and GNU_STACK RW 0x10; not a live exploit trace.
Pinned Apache is PIE and requests a non-executable stack.

Reproduction code: Fortbridge WordPress pingback and Brotli PoC.

Root cause and fix

The security boundary crosses a native decoder and a web application fetch. Updating WordPress alone is not a demonstrated fix for a vulnerable Brotli library in the image. Replace affected Brotli builds or the image with a vendor-fixed package, then restart processes that loaded the old library. Upstream issued fixes on maintained branches in 1.0.10, 1.1.1 and 1.2.1. Distribution backports mean the displayed package version is not sufficient by itself: check the vendor advisory and package changelog for the deployed image.

Until the update is deployed, reduce untrusted Brotli decoding paths and disable XML-RPC pingbacks if not needed. Those are exposure-reduction measures, not substitutes for patching the affected decoder. Assess whether cURL’s Brotli support and outbound fetch policy make the route reachable in your own installation.

Beyond WordPress: other software carrying the Brotli flaw

WordPress was our tested CMS route, not the limit of the underlying decoder vulnerability. Vendor advisories and the PyPA advisory database identify affected components and conditional decoding paths:

  • Node.js: pre-fix builds in its 22.x, 24.x and 26.x lines bundled the affected decoder; security releases 22.23.4, 24.22.1 and 26.12.1 addressed it. The path matters when an application decompresses attacker-supplied Brotli data through node:zlib.
  • Bun: versions 1.0.21–1.4.3 bundled the affected decoder; relevant paths include fetch, node:zlib and DecompressionStream when they process untrusted data.
  • Python’s PyPI Brotli package: versions through 1.2.0 shipped the affected decoder; 1.2.1 contains the fix. This does not make every Python application exploitable.
  • .NET runtime and NativeAOT packages: affected applications must enable Brotli decompression or explicitly decode untrusted data. ASP.NET Core request decompression and HttpClient response decompression are not enabled by default; .NET Framework is not affected.
  • Envoy Proxy: the advisory concerns deployments with the Brotli decompressor configured, not every Envoy installation.
  • Brotli4j: Java applications using affected native binding versions through 1.23.0 can reach the bundled decoder; 1.24.0 is the patched release.
  • FrankenPHP standalone binaries: versions 1.8.0–1.13.1 included an affected brotli extension. Loading it alone is not an exploit path, and the maintainers did not demonstrate code execution in FrankenPHP.

References

About Post Author