How to Fix CVE-2026-0540: Cross-site scripting in DOMPurify
By Sai Kiran Pandrala. Last verified: 2026-05-25.
CVE-2026-0540 is a cross-site scripting in cure53 DOMPurify. The fix is to apply the vendor patch noted below.
| Severity | 5.3 (Medium) |
|---|---|
| Actively exploited? | No public listing in CISA KEV |
| Affected | DOMPurify 3.1.3 to <=3.3.1; DOMPurify 2.5.3 to <=2.5.8 |
| Fixed in | See vendor advisory |
| Type (CWE) | CWE-79 Improper Neutralization of Input During Web Page Generation (XSS or 'Cross-site Scripting') |
Exploitation status
CVE-2026-0540 is not currently on the CISA Known Exploited Vulnerabilities (KEV) catalog, so there is no U.S.-government-confirmed in-the-wild exploitation on record for it. That is no proof of safety, though, since CISA KEV tends to lag actual exploitation, so schedule the fix by severity instead of waiting for confirmation.
Public exploit availability: as of now, no public exploit or Metasploit module appears in the cited references. Unpublished or privately held exploits could still exist, so weak public availability is not a reason to deprioritise.
What is CVE-2026-0540?
DOMPurify 3.1.3 through 3.3.1 and 2.5.3 through 2.5.8, fixed in commit 2726c74, contain a cross-site scripting vulnerability that allows attackers to bypass attribute sanitization by exploiting five missing rawtext elements (noscript, xmp, noembed, noframes, iframe) in the SAFE_FOR_XML regex. Attackers can include payloads like </noscript><img src=x onerror=alert(1)> in attribute values to execute JavaScript when sanitized output is placed inside these unprotected rawtext contexts. The CVSS base score is 5.3 (Medium). The official advisory is at https://github.com/cure53/DOMPurify.
Spot the symptom
Check the version of DOMPurify you are running and compare it against the Affected row above (DOMPurify 3.1.3 to <=3.3.1; DOMPurify 2.5.3 to <=2.5.8). If your build sits inside the affected range, you must patch.
Run the version check that fits your platform:
# Linux package check
dpkg -s dompurify 2>/dev/null | grep -i ^Version
rpm -q dompurify 2>/dev/null
command -v dompurify >/dev/null && dompurify --version 2>/dev/null
# Windows (PowerShell)
Get-Package -Name "*DOMPurify*" -ErrorAction SilentlyContinue | Select-Object Name, Version
winget list --name "DOMPurify" 2>$null
How to fix CVE-2026-0540
Upgrade DOMPurify to a patched build: See vendor advisory. The vendor advisory is the source of truth for the exact fixed version.
Ubuntu / Debian
sudo apt-get update
sudo apt-get install --only-upgrade dompurify
dpkg -s dompurify | grep -i ^Version
RHEL / CentOS / Rocky / AlmaLinux
sudo dnf upgrade --refresh dompurify -y
# or for older releases:
sudo yum update dompurify -y
rpm -q dompurify
SUSE / openSUSE
sudo zypper refresh
sudo zypper update dompurify
rpm -q dompurify
Complete PowerShell remediation script (Windows)
# Fix script for CVE-2026-0540 affecting DOMPurify
# Run as administrator. Detect -> backup -> upgrade -> verify -> log.
$ErrorActionPreference = "Stop"
$LogPath = "C:\Logs\CVE-2026-0540-fix-$(Get-Date -Format yyyyMMdd-HHmmss).log"
New-Item -ItemType Directory -Force (Split-Path $LogPath) | Out-Null
Start-Transcript -Path $LogPath -Append
try {
Write-Host "[1/4] Detect installed version"
$pkg = Get-Package -Name "*DOMPurify*" -ErrorAction SilentlyContinue
if ($pkg) { $pkg | Format-Table Name, Version }
else { Write-Host "Not detected via Get-Package; try winget list" }
Write-Host "[2/4] Backup configuration"
$backup = "C:\Backup\dompurify-$(Get-Date -Format yyyyMMdd)"
New-Item -ItemType Directory -Force $backup | Out-Null
Get-ChildItem "C:\ProgramData\DOMPurify" -ErrorAction SilentlyContinue |
Copy-Item -Destination $backup -Recurse -Force -ErrorAction SilentlyContinue
Write-Host "[3/4] Apply the upgrade to See vendor advisory"
winget upgrade --name "DOMPurify" --silent --accept-source-agreements --accept-package-agreements
if ($LASTEXITCODE -ne 0) {
# Fallback: pull latest via OS update channel
Install-Module -Name PSWindowsUpdate -Force -SkipPublisherCheck -ErrorAction SilentlyContinue
Import-Module PSWindowsUpdate
Install-WindowsUpdate -MicrosoftUpdate -AcceptAll -IgnoreReboot
}
Write-Host "[4/4] Verify the patched build"
winget list --name "DOMPurify"
Write-Host "Patch applied. Reboot if prompted."
exit 0
} catch {
Write-Error "Patch failed: $_"
exit 1
} finally {
Stop-Transcript
}
Complete Bash remediation script (Linux)
#!/usr/bin/env bash
# Fix script for CVE-2026-0540 affecting DOMPurify
# Detect -> backup -> upgrade -> verify -> log.
set -euo pipefail
LOG="/var/log/cve-2026-0540-fix-$(date +%Y%m%d-%H%M%S).log"
exec > >(tee -a "$LOG") 2>&1
echo "[1/4] Detect installed version"
if command -v dpkg >/dev/null; then
dpkg -s dompurify 2>/dev/null | grep -i ^Version || echo "dompurify not installed via dpkg"
elif command -v rpm >/dev/null; then
rpm -q dompurify || echo "dompurify not installed via rpm"
fi
echo "[2/4] Backup configuration"
BACKUP="/root/backup-cve-2026-0540-$(date +%Y%m%d)"
mkdir -p "$BACKUP"
for d in /etc/dompurify /etc/dompurify.d /etc/dompurify.conf; do
[ -e "$d" ] && cp -a "$d" "$BACKUP/" || true
done
echo "[3/4] Apply the upgrade (target: See vendor advisory)"
if command -v apt-get >/dev/null; then
apt-get update
apt-get install --only-upgrade -y dompurify
elif command -v dnf >/dev/null; then
dnf upgrade --refresh -y dompurify
elif command -v yum >/dev/null; then
yum update -y dompurify
elif command -v zypper >/dev/null; then
zypper --non-interactive update dompurify
fi
echo "[4/4] Verify the patched build"
if command -v dpkg >/dev/null; then
dpkg -s dompurify 2>/dev/null | grep -i ^Version
elif command -v rpm >/dev/null; then
rpm -q dompurify
fi
echo "Done. Restart any service that loaded the old library."
If you can't patch immediately
Apply at least one of the following inline controls until you can deploy the patched build. None replace the upgrade.
Restrict exposure with nftables (Linux)
# Allow only trusted CIDR to reach the affected service ports
sudo nft add table inet filter 2>/dev/null || true
sudo nft 'add chain inet filter input { type filter hook input priority 0 ; }' 2>/dev/null || true
sudo nft 'add rule inet filter input tcp dport {80, 443} ip saddr != 10.0.0.0/8 drop'
sudo nft list ruleset
Block at the host firewall (Windows)
New-NetFirewallRule -DisplayName "Block-CVE-2026-0540" -Direction Inbound -Action Block -Protocol TCP -LocalPort 80,443 -RemoteAddress Any -Enabled True
Get-NetFirewallRule -DisplayName "Block-CVE-2026-0540"
Disable the affected service (Linux)
sudo systemctl stop dompurify 2>/dev/null || true
sudo systemctl disable dompurify 2>/dev/null || true
If the vendor advisory lists an official workaround, prefer that wording verbatim. If no workaround is published, the only safe remediation is the patch.
Full fix path
After upgrading, confirm the installed version matches the patched build and that no old library is still loaded by a long-running process.
# Linux
dpkg -s dompurify 2>/dev/null | grep -i ^Version
rpm -q dompurify 2>/dev/null || true
# Pid map check for old library handles
sudo lsof +c0 2>/dev/null | grep -i "DEL.*lib" || true
# Windows
Get-Package -Name "*DOMPurify*" | Select-Object Name, Version
Get-HotFix | Sort-Object InstalledOn -Descending | Select-Object -First 5
Expected: the reported version is at or above See vendor advisory. Restart the affected service (systemctl restart <service> on Linux, or restart the Windows service) so it loads the patched binary.
Is CVE-2026-0540 actively exploited?
There is no public confirmation of exploitation in the wild listed in CISA KEV at the time of this writing. Patch anyway. Public exploits commonly follow disclosure within weeks.
Do I need to reboot after patching CVE-2026-0540?
For kernel and OS-level updates, yes. For most userland packages a systemctl restart <service> is enough on Linux, and restarting the Windows service or app on Windows. Any process that loaded the old library keeps using it until restarted.
What is the CVSS score for CVE-2026-0540?
5.3 (Medium). Vector: CVSS:4.0/AV:N/AC:L/AT:N/PR:N/UI:P/VC:N/VI:N/VA:N/SC:L/SI:L/SA:N.
Where is the official advisory for CVE-2026-0540?
The vendor advisory is at https://github.com/cure53/DOMPurify. The NVD record is at https://nvd.nist.gov/vuln/detail/CVE-2026-0540.
References
- Official vendor advisory: https://github.com/cure53/DOMPurify
- NVD: https://nvd.nist.gov/vuln/detail/CVE-2026-0540
- CISA KEV catalog: https://www.cisa.gov/known-exploited-vulnerabilities-catalog
- Additional reference: https://github.com/cure53/DOMPurify/commit/302b51de22535cc90235472c52e3401bedd46f80
- Additional reference: https://github.com/cure53/DOMPurify/releases/tag/3.3.2
- Additional reference: https://fluidattacks.com/advisories/daft
Related fixes
Related weaknesses in the same component worth addressing at the same time:
- How to Fix CVE-2026-28217: Missing authorization in hoppscotch
- How to Fix CVE-2026-24993: SQL Injection in Advanced WooCommerce Product Sales Reporting
- How to Fix CVE-2026-4726: Critical Vulnerability in Firefox
- How to Fix CVE-2026-41425: CWE-352: Cross-Site Request Forgery (CSRF) in authlib
- How to Fix CVE-2026-34954: PraisonAI (Bundle Sibling)
People also ask
Is CVE-2026-0540 actively exploited?
There is no public confirmation of exploitation in the wild listed in CISA KEV at the time of this writing. Patch anyway. Public exploits commonly follow disclosure within weeks.
Do I need to reboot after patching CVE-2026-0540?
For kernel and OS-level updates, yes. For most userland packages a `systemctl restart <service>` is enough on Linux, and restarting the Windows service or app on Windows. Any process that loaded the old library keeps using it until restarted.
What is the CVSS score for CVE-2026-0540?
5.3 (Medium). Vector: `CVSS:4.0/AV:N/AC:L/AT:N/PR:N/UI:P/VC:N/VI:N/VA:N/SC:L/SI:L/SA:N`.
Where is the official advisory for CVE-2026-0540?
The vendor advisory is at [https://github.com/cure53/DOMPurify](https://github.com/cure53/DOMPurify). The NVD record is at https://nvd.nist.gov/vuln/detail/CVE-2026-0540.