league/commonmark contains a XSS vulnerability in Attributes extension
Published 5 May 2025 · Updated 20 Mar 2026
Is your project on an affected league/commonmark?
Look after several Laravel or PHP apps? Indie watches up to 15 repos, private ones too, for $5 a month. See Indie
Affected package
- Affected
- >=1.5.0 <2.7.0
- Fixed in
- 2.7.0
composer require league/commonmark:^2.7.0Details
Summary
Cross-site scripting (XSS) vulnerability in the Attributes extension of the league/commonmark library (versions 1.5.0 through 2.6.x) allows remote attackers to insert malicious JavaScript calls into HTML.
Details
The league/commonmark library provides configuration options such as html_input: 'strip' and allow_unsafe_links: false to mitigate cross-site scripting (XSS) attacks by stripping raw HTML and disallowing unsafe links. However, when the Attributes Extension is enabled, it introduces a way for users to inject arbitrary HTML attributes into elements via Markdown syntax using curly braces.
As a result, even with the secure configuration shown above, an attacker can inject dangerous attributes into applications using this extension via a payload such as:
![](){onerror=alert(1)}Which results in the following HTML:
<p><img onerror="alert(1)" src="" alt="" /></p>
Which causes the JS to execute immediately on page load.
Patches
Version 2.7.0 contains three changes to prevent this XSS attack vector:
- All attributes starting with
onare considered unsafe and blocked by default - Support for an explicit allowlist of allowed HTML attributes
- Manually-added
hrefandsrcattributes now respect the existingallow_unsafe_linksconfiguration option
Workarounds
If upgrading is not feasible, please consider:
- Disabling the
AttributesExtensionfor untrusted users - Filtering the rendered HTML through a library like HTMLPurifier
Is GHSA-3527-qv2q-pfvx in any of your client repos?
Checking one package by hand is fine. Checking it across forty client projects is not. NPMscan reads the lockfiles in every GitHub repo you pick, finds each project with an affected league/commonmark, and gives you the command that fixes it.
More advisories for league/commonmark
- MediumCVE-2026-105829league/commonmark: DisallowedRawHtml bypassed when a disallowed tag name ends the raw-HTML literal · 30 Sept 2026
- HighCVE-2026-105830league/commonmark: Quadratic-time denial of service in the GitHub Flavored Markdown Table extension block-start scan · 30 Sept 2026
- HighCVE-2026-86428league/commonmark: Denial of service via distinctly-named attributes in the Attributes extension · 1 Sept 2026
- HighCVE-2026-86429league/commonmark: Denial of service in the SmartPunct and Attributes extensions · 1 Sept 2026
- HighCVE-2026-86431league/commonmark XSS: `on*` event-handler filter in `AttributesExtension` bypassed with a U+000C form feed · 1 Sept 2026
- HighCVE-2026-86430league/commonmark: Denial of service via crafted code fences, reference links, and emphasis delimiters · 1 Sept 2026
References
Advisory data from OSV.dev (opens OSV.dev in a new tab), refreshed daily.