/

CVE-2026-86431

Severity:

HIGH RISK

(7.2)

XSS (CWE-79) in league/commonmark AttributesExtension

CVE-2026-86431

Analyzed

Vulnerability type

Category:

Cross-Site Scripting

CWE:

CWE-79

Impact:

Client-Side Script Execution

Severity:

HIGH RISK

(7.2)

CVSS version:

3.1

Catch this CVE while code is being written

Detect vulnerable code directly in pull requests, so CVEs are fixed before merge.

Summary

A cross-site scripting vulnerability in league/commonmark allows specially formatted Markdown attributes to bypass filtering of event-handler attributes and unsafe URLs. When untrusted Markdown is rendered with the AttributesExtension enabled, injected JavaScript may execute in a viewer's browser.

Affected context

The issue occurs in applications using league/commonmark versions within the affected range and enabling the AttributesExtension while processing Markdown from untrusted or insufficiently trusted sources. It becomes risky when rendered output is delivered as HTML without an additional security boundary that prevents browser interpretation of injected event handlers or unsafe URI schemes.

Exploit preconditions

  • Attack surface: Markdown-to-HTML rendering through league/commonmark
  • Required access: Ability to submit or influence Markdown content that the application renders
  • Trigger point: Attribute parsing and filtering performed by the AttributesExtension
  • Why exploitation is possible: A form-feed-prefixed attribute name can bypass application-level checks while remaining interpretable by browsers as an event-handler attribute or unsafe URI attribute

Why this happens

The vulnerability results from inconsistent normalization between PHP-side filtering and browser-side HTML parsing. The filtering logic relies on trim() and checks attribute names and values before output, but a leading U+000C form-feed character is not removed by that normalization path. The resulting attribute can therefore bypass checks intended to block event handlers and unsafe URL schemes, while the browser treats it as a genuine attribute. This behavior maps to CWE-79: Improper Neutralization of Input During Web Page Generation, because attacker-controlled Markdown is emitted into HTML without reliably neutralizing executable content.

Potential impact

  • An attacker may execute JavaScript in the context of a viewer's browser.
  • Session information or page content could be exposed.
  • User actions may be performed through the affected application.
  • Rendered pages could be modified or used for phishing.
  • Unsafe javascript: links may bypass application-level URL restrictions.

General mitigation guidance

Mitigation generally focuses on consistent input normalization, strict output encoding, and reducing trust in user-supplied Markdown.

Common defensive patterns include:

  • Use a parser configuration or component behavior that does not permit raw event-handler attributes or unsafe URI schemes.
  • Normalize Unicode and control characters before attribute validation, using the same semantics expected by the HTML consumer.
  • Apply context-appropriate HTML sanitization after rendering, with an allowlist for permitted elements, attributes, and URL schemes.
  • Treat rendered Markdown as untrusted content and isolate it where appropriate using browser security controls such as a restrictive Content Security Policy.
  • Avoid granting rendered-content processes unnecessary access to sensitive application data or privileged browser capabilities.

How teams detect issues like this

Organizations can identify similar issues through:

  • Static analysis and code review checks for inconsistent trimming, Unicode normalization, or validation of HTML attribute names.
  • Tests covering control characters and alternate whitespace forms at attribute boundaries.
  • Security-focused rendering tests that verify event-handler attributes and unsafe URI schemes cannot reach output.
  • Dependency and configuration policy checks requiring safe Markdown rendering settings and explicit sanitization boundaries.
  • Runtime monitoring for unexpected event-handler attributes, unsafe URI schemes, or suspicious script execution in rendered-content responses.

Sources

SourceLink
github.comgithub.com/thephpleague/commonmark/commit/43207253ea5f14867c77c697cd3838c446cadcea
github.comgithub.com/thephpleague/commonmark/security/advisories/GHSA-f8fg-pg57-v4j8
vulncheck.comvulncheck.com/advisories/commonmark-before-2.9.1-xss-via-attributesextension-form-feed-bypass

Frequently asked

questions

It can be exploited through an application's normal Markdown submission or content-ingestion path when an attacker can influence Markdown that is later rendered and viewed.

Authentication is deployment-dependent. Any account, integration, or external content source permitted to submit Markdown may provide the required access.

Use consistent normalization and strict allowlist-based sanitization for rendered HTML, while disabling event-handler attributes and unsafe URI schemes.

Treat Markdown as untrusted input, test parser filters with control characters and Unicode edge cases, enforce restrictive browser policies, and include dependency and security tests in development pipelines.

Find out what's already
exploitable in your codebase.