CVE-2021-33391
Critical · 9.8CVSS
9.8
EPSS
1.1%
Published
Feb 17, 2023
CISA due date
—
Cloudanix analysis
A bug in an HTML cleanup tool lets attackers run their own code on computers if the tool is used on specially crafted files with a particular command option.
- Exploitation
- Remote Unauthenticated
- Attacker needs
- None
- Complexity
- Low
- Impact
- Remote Code Execution
- Component
- Library
- Class
- Use After Free
- Remediation
- Upgrade
- Effort
- Medium
- Patch risk
- Low
What it actually does
Use-after-free in CleanNode() of gdoc.c allows arbitrary code execution when the -g option processes attacker-controlled input in HTACG HTML Tidy.
Why it matters to the business
Remote attackers can fully compromise any system running the affected tidy binary, enabling data theft or malware deployment; the flaw has been public for over three years with no listed fixes and available exploits.
How an attack unfolds
An attacker supplies a crafted input file and runs the tidy binary using the -g flag, triggering the use-after-free in CleanNode() to achieve code execution on the target host.
How to fix it
Upgrade HTACG HTML Tidy to a version containing the fix for this use-after-free; if no patched release is available, disable or restrict the -g option for untrusted content and consider alternative HTML processors.
How to confirm the fix worked
Reproduce the issue with known trigger inputs under the -g option, then confirm absence of crashes or memory errors after applying updates; scan for remaining vulnerable binaries via package inventory.
Typical attack path
- Identify systems exposing or using the tidy binary on untrusted input
- Craft malicious input that triggers the use-after-free path in gdoc.c
- Invoke tidy with the -g option against the input
- Leverage the resulting memory corruption for arbitrary code execution
How to detect it
Review command-line audit logs and process execution records for tidy invocations containing the -g flag; correlate with subsequent suspicious child processes or memory-related crashes in tidy.
What your security team should do
- Inventory all deployments of HTACG tidy and remove or isolate instances using the -g option
- Apply updates or workarounds immediately given the public exploit availability and multi-year exposure window
- Block or log invocations of tidy -g on untrusted data sources
- Replace tidy usage with maintained HTML sanitization libraries where possible
The record
An issue in HTACG HTML Tidy v5.7.28 allows attacker to execute arbitrary code via the -g option of the CleanNode() function in gdoc.c.
Affected packages
| Ecosystem | Package | Introduced | Fixed |
|---|---|---|---|
| Debian:11 | tidy-html5 | 0 | No fix |
| Debian:12 | tidy-html5 | 0 | No fix |
| Debian:13 | tidy-html5 | 0 | No fix |
| Ubuntu:18.04:LTS | tidy-html5 | 0 | No fix |
| Ubuntu:20.04:LTS | tidy-html5 | 0 | 2:5.6.0-11ubuntu0.20.04.1 |
| Ubuntu:22.04:LTS | tidy-html5 | 0 | 2:5.6.0-11ubuntu0.22.04.1 |
| Ubuntu:23.10 | tidy-html5 | 0 | 2:5.6.0-11ubuntu0.23.10.1 |
| Ubuntu:24.04:LTS | tidy-html5 | 0 | 2:5.6.0-11ubuntu1 |
| Ubuntu:Pro:18.04:LTS | tidy-html5 | 0 | No fix |
Related vulnerabilities
- CVE-2026-109618 PHP uses longjmp() for out-of-memory (OOM) errors to exit the current context and abort… CWE-416
- CVE-2026-109619 PHP has various global state that temporarily points into request memory. CWE-416
- CVE-2026-112402 Pillow is a Python imaging library. CWE-416
- CVE-2026-112396 Pillow is a Python imaging library. CWE-416
- CVE-2025-55654 A use-after-free in the gf_filter_pid_get_packet function (filter_core/filter_pid.c) of… CWE-416
- CVE-2026-17591 A flaw was found in libarchive. CWE-416
- CVE-2026-92392 During an upload, curl mishandles HTTP/2 `RST_STREAM` received from the server (with… CWE-416
- CVE-2026-109268 ImageMagick before 6.9.13-57 and 7.x before 7.1.2-32 contains a use after free… CWE-416