Skip to content
RCE Write-up Advanced

Diving Deeper into WatchGuard Pre-Auth RCE – CVE-2022-26318

A pre-authentication buffer overflow in the WatchGuard Firebox wgagent service allowed an unauthenticated attacker to execute arbitrary code by sending a crafted XML request. The overflow occurs because the service concatenates XML element names into a fixed-size buffer without bounds checking.

blog.assetnote.io

Published on blog.assetnote.io

The reverse engineering of this CVE was performed by Dylan Pindur.

Assetnote Team, on blog.assetnote.io

The full write-up lives on its author's site

It belongs to its author, so we link to it rather than copy it. The other two tabs are our own rewrites, checked against it.

Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.

How it worked

Root cause

The startElementNs callback uses strcat to append XML element names to a fixed global buffer without any length check, allowing a heap overflow that overwrites a nearby SAX handler function pointer.

Impact

An unauthenticated attacker could execute arbitrary code on the appliance, potentially taking full control of the device.

What the attacker needed

Network access to the appliance; no authentication required

How it was found

  1. Start a vulnerable WatchGuard Firebox VM and gain shell access by mounting the disk image and replacing the root password.
  2. Install BusyBox and remount the filesystem read-write to get basic utilities.
  3. Attach gdbserver to the wgagent process and connect from a debugging machine.
  4. Send a gzip-compressed XML payload with a long element name to trigger a segfault in libxml2.
  5. Set a breakpoint on the function calling xmlParseChunk and confirm the crash occurs inside it.
  6. Watch the heap address of the startElementNs callback and observe it being overwritten by the repeated payload bytes.

Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.

Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.

A buffer overflow happens when a program writes more data into a fixed-size memory area than it can hold, spilling into neighbouring memory. Here, the WatchGuard service kept appending XML tag names to a buffer without checking length, so a long request could overwrite a function pointer stored nearby. The attacker could then redirect execution to their own code and run commands on the device without logging in.

What is RCE?

Running the attacker's code on the target's servers: through command or code injection, unsafe deserialisation or template injection.

Similar reports

View all

Same bug class and techniques, clearest first.

Remote code execution

The lesson behind this report.

Running the attacker's code on the target's servers: through command or code injection, unsafe deserialisation or template injection.