CVE-2025-29771: @jitbit/htmlsanitizer Cross-Site Scripting Vulnerability

MODERATE
Advisory Identifier: GHSA-vhv4-fh94-jm5x
CWE-79
Published
Advisory Summary

CVE-2025-29771 is a MODERATE cross-site scripting vulnerability (CWE-79: Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')) affecting @jitbit/htmlsanitizer libraries in the npm ecosystem. The issue involves js html sanitizer allows xss when used with contenteditable. Remediation is available by upgrading affected packages to version 2.0.3.

CVE-2025-29771 at a Glance

CVE Identifier CVE-2025-29771
GHSA Identifier GHSA-vhv4-fh94-jm5x
Severity MODERATE
CVSS v3.1 Base Score N/A
CWE Classification CWE-79: Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')
Affected Product @jitbit/htmlsanitizer
Package Ecosystem npm
Published Date
Last Updated

How to Fix CVE-2025-29771

To remediate this vulnerability, upgrade all affected @jitbit/htmlsanitizer dependencies to a patched release. Both direct and transitive dependencies should be checked, as frameworks or security libraries may pull in vulnerable versions transitively.

@jitbit/htmlsanitizer fixed: 2.0.3
npm install @jitbit/htmlsanitizer@2.0.3
Verify Direct and Transitive Dependencies

Run the following command in your project directory to verify that all resolved dependencies use the patched release:

npm ls @jitbit/htmlsanitizer

How to Check if You Are Affected

To determine whether your Node.js application is affected by CVE-2025-29771, inspect your project dependencies using npm:

npm ls @jitbit/htmlsanitizer

Analyze the terminal output to locate any version of @jitbit/htmlsanitizer in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than 2.0.3), your application is affected.

Note: The npm ls @jitbit/htmlsanitizer command inspects dependencies declared in your package.json and lockfile; it does not perform automated runtime dynamic scanning.

Technical Details

Vulnerability Mechanism & Technical Analysis

This vulnerability is classified under CWE-79: Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting'), where the product does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users. In @jitbit/htmlsanitizer, software state validation or input boundaries are circumvented during processing. Review the official source advisory statement below for specific affected components, classes, and reproduction details.

Source Advisory Statement

### Impact XSS vulnerability when the sanitizer is used with a `contentEditable` element to set the elements `innerHTML` to a sanitized string produced by the package. If the code is particularly crafted to abuse the code beautifier, that runs AFTER sanitation. ### Patches Patched in version 2.0.3

CVE-2025-29771 Affected @jitbit/htmlsanitizer Versions

1 component(s)
Fixed Versions:
2.0.3
Product / Package Ecosystem Affected Versions Fixed Version
@jitbit/htmlsanitizer
npm
< 2.0.3
2.0.3

References

Frequently Asked Questions

What is CVE-2025-29771?
CVE-2025-29771 is a security vulnerability in @jitbit/htmlsanitizer involving JS Html Sanitizer allows XSS when used with contentEditable under CWE-79: Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting').
Which @jitbit/htmlsanitizer versions are affected?
Affected versions include releases prior to 2.0.3 across affected packages: @jitbit/htmlsanitizer.
What version fixes CVE-2025-29771?
Upgrading to 2.0.3 (or the latest patched release for your respective branch) resolves the vulnerability.
Is @jitbit/htmlsanitizer affected?
Yes, @jitbit/htmlsanitizer is affected in releases prior to 2.0.3. Upgrade your dependency to 2.0.3 or later.
What CWE is associated with CVE-2025-29771?
CVE-2025-29771 is classified under CWE-79: Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting') (The product does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.).
How can I check npm dependencies for CVE-2025-29771?
Run the dependency tree command: 'npm ls @jitbit/htmlsanitizer'. This command lists direct and transitive dependencies in your build configuration so you can verify if a vulnerable version is resolved.
Machine-readable OSV JSON OSV v1.5 Schema
Normalized schema output
{
  "schema_version" : "1.4.0",
  "id" : "GHSA-vhv4-fh94-jm5x",
  "modified" : "2025-03-14T21:41:26Z",
  "published" : "2025-03-14T19:54:52Z",
  "aliases" : [ "CVE-2025-29771" ],
  "summary" : "JS Html Sanitizer allows XSS when used with contentEditable",
  "details" : "### Impact\nXSS vulnerability when the sanitizer is used with a `contentEditable` element to set the elements `innerHTML` to a sanitized string produced by the package. If the code is particularly crafted to abuse the code beautifier, that runs AFTER sanitation.\n\n### Patches\nPatched in version 2.0.3",
  "severity" : [ {
    "type" : "CVSS_V4",
    "score" : "CVSS:4.0/AV:N/AC:L/AT:N/PR:N/UI:N/VC:N/VI:N/VA:N/SC:L/SI:L/SA:N"
  } ],
  "affected" : [ {
    "package" : {
      "ecosystem" : "npm",
      "name" : "@jitbit/htmlsanitizer"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0"
      }, {
        "fixed" : "2.0.3"
      } ]
    } ]
  } ],
  "references" : [ {
    "type" : "WEB",
    "url" : "https://github.com/jitbit/HtmlSanitizer/security/advisories/GHSA-vhv4-fh94-jm5x"
  }, {
    "type" : "ADVISORY",
    "url" : "https://nvd.nist.gov/vuln/detail/CVE-2025-29771"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/jitbit/HtmlSanitizer/commit/af6d2a78877e7277cd01c825b7fb50edb5956963"
  }, {
    "type" : "PACKAGE",
    "url" : "https://github.com/jitbit/HtmlSanitizer"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-79" ],
    "severity" : "MODERATE",
    "github_reviewed" : true,
    "github_reviewed_at" : "2025-03-14T19:54:52Z",
    "nvd_published_at" : "2025-03-14T19:15:48Z"
  }
}