How to Fix CVE-2026-22787: Critical Vulnerability in html2pdf.js
Related fixes
Other vulnerabilities in the same area that are worth patching alongside this one:
- How to Fix CVE-2026-27767: Missing authentication in swtchenergy.com — Missing authentication in swtchenergy.com
- How to Fix CVE-2026-7446: OS Command Injection in mcp-server-semgrep — OS Command Injection in mcp-server-semgrep
- How to Fix CVE-2026-6405: Cross-Site Scripting in Anomify AI – Anomaly Detection and Alerting , Cross-Site Scripting in Anomify AI – Anomaly Detection and Alerting
- How to Fix CVE-2026-32261: RCE via SSTI for users with permissions to access the Craft CMS Webhooks plugin , RCE via SSTI for users with permissions to access the Craft CMS Webhooks plugin
- How to Fix CVE-2026-30287: n/a (Bundle Sibling) , n/a (Bundle Sibling)
*By Sai Kiran Pandrala*
| Severity | CVSS 8.7 - High |
|---|---|
| Actively exploited? | Not currently listed in CISA KEV |
| Affected | < 0.14.0 |
| Fixed in | html2pdf.js |
| Type (CWE) | CWE-79: Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting') |
What is CVE-2026-22787?
CVE-2026-22787 is a security flaw in html2pdf.js. html2pdf.js converts any webpage or element into a printable PDF entirely client-side. Prior to 0.14.0, html2pdf.js contains a cross-site scripting (XSS) vulnerability when given a text source rather than an element.
Why this CVE matters
Unpatched network-facing software is the leading initial-access vector in public breach reporting. Treat any CVSS-9 class flaw on an internet-reachable system as urgent, regardless of whether public exploit code has been observed yet.
For deployments of html2pdf.js that have been exposed to the public internet during the disclosure window, the operating assumption should be that scanning has already happened. Even where exploitation has not been publicly observed, scanning for the vulnerable fingerprint is cheap and routine. Patching closes the door; log review and credential rotation close out the rest of the response.
Am I affected?
You are affected if your installation matches any of these version ranges:
- html2pdf.js: < 0.14.0
Check your installed version against the list above. If you cannot determine the version, treat the system as affected and follow the upgrade path below.
Open html2pdf.js's About dialog or run the vendor-documented version-check command. Compare the result against the affected ranges in the advisory.
How to fix CVE-2026-22787
- Read the vendor advisory in full: https://github.com/eKoopmans/html2pdf.js/security/advisories/GHSA-w8x4-x68c-m6fc
- Upgrade html2pdf.js to the patched build listed in the vendor advisory.
- Back up the configuration (and database, where applicable) before upgrading.
- Apply the patch in a maintenance window. For HA pairs, upgrade the standby node first, fail over, then upgrade the former primary.
- Restart the affected service so the patched binary loads, then verify the new version (see verification section).
Ubuntu / Debian
_Verify the exact patched build against the vendor advisory: https://github.com/eKoopmans/html2pdf.js/security/advisories/GHSA-w8x4-x68c-m6fc_
sudo apt-get update
sudo apt-get install --only-upgrade html2pdf.js
dpkg -s html2pdf.js | grep -i version
RHEL / Rocky / AlmaLinux / Fedora
sudo dnf upgrade --refresh html2pdf.js -y
rpm -q html2pdf.js
openSUSE
sudo zypper refresh
sudo zypper update html2pdf.js
rpm -q html2pdf.js
Bash detect / upgrade / verify runner (Linux)
_Verify the exact patched build against the vendor advisory: https://github.com/eKoopmans/html2pdf.js/security/advisories/GHSA-w8x4-x68c-m6fc_
#!/usr/bin/env bash
# CVE-2026-22787 remediation runner. Re-runnable; exits non-zero on failure.
set -euo pipefail
log() { printf '%s %s\n' "$(date -Is)" "$*" | tee -a /var/log/cve-2026-22787-fix.log; }
PKG="html2pdf.js"
TARGET_VERSION="see vendor advisory"
log "Detect: reading current $PKG version"
if command -v dpkg >/dev/null 2>&1; then
current=$(dpkg-query -W -f='${Version}' "$PKG" 2>/dev/null || echo "not-installed")
elif command -v rpm >/dev/null 2>&1; then
current=$(rpm -q --qf '%{VERSION}-%{RELEASE}' "$PKG" 2>/dev/null || echo "not-installed")
else
current="unknown"
fi
log "Current: $current (target per advisory: $TARGET_VERSION)"
log "Backup: snapshotting /etc/$PKG if present"
backup="/var/backups/cve-2026-22787-$(date +%Y%m%d-%H%M)"
mkdir -p "$backup"
[ -d "/etc/$PKG" ] && cp -a "/etc/$PKG" "$backup/" || true
log "Upgrade: applying vendor patch"
if command -v apt-get >/dev/null 2>&1; then
sudo apt-get update -qq
sudo apt-get install -y --only-upgrade "$PKG"
elif command -v dnf >/dev/null 2>&1; then
sudo dnf upgrade -y "$PKG"
elif command -v yum >/dev/null 2>&1; then
sudo yum update -y "$PKG"
fi
log "Verify: re-reading $PKG version"
if command -v dpkg >/dev/null 2>&1; then
after=$(dpkg-query -W -f='${Version}' "$PKG")
else
after=$(rpm -q --qf '%{VERSION}-%{RELEASE}' "$PKG")
fi
log "After: $after"
if [ "$after" != "$current" ]; then
log "SUCCESS: $PKG upgraded"
else
log "WARN: version unchanged. Confirm the patched build is in your repository."
exit 1
fi
Verify the fix landed
# 1. Confirm the running version matches the patched build
# (target per advisory: see vendor advisory)
# Use the platform-specific version probe shown above.
# 2. Re-scan the host with your vulnerability scanner (Nessus, Qualys, Tenable,
# Rapid7, OpenVAS). The scanner should no longer flag CVE-2026-22787.
# 3. Inspect service and kernel logs for crash-loops or rollback events
journalctl --since "10 minutes ago" | grep -iE 'error|fail|panic'
dmesg --since "10 minutes ago" | tail -50
If you cannot patch immediately
No official workaround exists beyond restricting network exposure to the affected component. Apply the vendor patch as the primary remediation.
How to verify the fix worked
- After applying the patch, verify the running version in the product's admin UI or via the vendor-documented CLI command.
- Confirm the patched build matches the version listed in the vendor advisory.
- Run an authenticated vulnerability scan with a current signature set and confirm the scanner no longer flags CVE-2026-22787.
- Review logs for the entire pre-patch window for indicators of compromise listed in the vendor or CISA advisory.
- Confirm any network-layer mitigations that were applied as a stopgap have been reverted (or left in place intentionally) once the patch is verified.
If your installation was internet-reachable during the disclosure window, treat log review as part of the remediation rather than an optional follow-up. Look for log entries that do not match your normal request patterns, especially repeated requests to the same uncommon endpoint, and any administrative changes you cannot tie back to a known operator.
Frequently asked questions
Is CVE-2026-22787 being exploited in the wild?
Public exploitation has not been confirmed by CISA at the time of writing. Treat the patch as time-sensitive anyway; reports often lag actual abuse.
Will a WAF or IDS rule fully mitigate CVE-2026-22787?
No. Network-layer filters can reduce noise and slow opportunistic scanners, but they will not stop a determined attacker. The vendor patch is the only durable fix.
How long should I plan for the upgrade?
Typical vendor-documented upgrade windows for html2pdf.js run from a few minutes to under an hour depending on cluster size. Test in a staging environment first and follow the vendor's documented HA upgrade order.
References
- Official vendor advisory: https://github.com/eKoopmans/html2pdf.js/security/advisories/GHSA-w8x4-x68c-m6fc
- NVD entry: https://nvd.nist.gov/vuln/detail/CVE-2026-22787
- CISA KEV catalog: https://www.cisa.gov/known-exploited-vulnerabilities-catalog
- Additional vendor or research reference: https://github.com/eKoopmans/html2pdf.js/issues/865
- Additional vendor or research reference: https://github.com/eKoopmans/html2pdf.js/pull/877
- Additional vendor or research reference: https://github.com/eKoopmans/html2pdf.js/commit/988826e336035b39a8608182d7b73c0e3cd78c7b
- Additional vendor or research reference: https://github.com/eKoopmans/html2pdf.js/releases/tag/v0.14.0
*This guide was assembled from the official vendor advisory, the NVD record, and the CISA KEV catalog entry on 2026-05-25. Always confirm against the vendor advisory before applying changes in production.*