6.4medium
league/commonmark Cross-site Scripting vulnerability in Attributes extension
- Severity
- 6.4medium CVSS:3.1 by GitHub_M
- Exploit likelihood
- 0.39% (higher than 35% of CVEs; EPSS, by FIRST)
- Published
- Last changed
- Assigned by
- GitHub_M
- Also known as
- GHSA-3527-qv2q-pfvx
Description
league/commonmark is a PHP Markdown parser. A 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. 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. Version 2.7.0 contains three changes to prevent this XSS attack vector: All attributes starting with `on` are considered unsafe and blocked by default; support for an explicit allowlist of allowed HTML attributes; and manually-added `href` and `src` attributes now respect the existing `allow_unsafe_links` configuration option. If upgrading is not feasible, please consider disabling the `AttributesExtension` for untrusted users and/or filtering the rendered HTML through a library like HTMLPurifier.
Affected
| Product or package | Versions | Reported by |
|---|---|---|
| thephpleague commonmark | < 2.7.0 | CVE List |
| league/commonmark (Packagist) | from 1.5.0 before 2.7.0 | GitHub Advisory Database |
All scores
| GitHub_M | 6.4medium CVSS:3.1 | CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:C/C:L/I:L/A:N |
| GitHub | 6.4medium CVSS:3.1 | CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:C/C:L/I:L/A:N |
Classification
SSVC (CISA-ADP): exploitation none, automatable no, technical impact partial.
What each source says
CVE List
league/commonmark is a PHP Markdown parser. A 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. 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. Version 2.7.0 contains three changes to prevent this XSS attack vector: All attributes starting with `on` are considered unsafe and blocked by default; support for an explicit allowlist of allowed HTML attributes; and manually-added `href` and `src` attributes now respect the existing `allow_unsafe_links` configuration option. If upgrading is not feasible, please consider disabling the `AttributesExtension` for untrusted users and/or filtering the rendered HTML through a library like HTMLPurifier.
GitHub Advisory Database
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
NVD (es)
league/commonmark es un analizador de PHP Markdown. Una vulnerabilidad de cross-site scripting (XSS) en la extensión Attributes de la librería league/commonmark (versiones 1.5.0 a 2.6.x) permite a atacantes remotos insertar llamadas JavaScript maliciosas en HTML. La librería league/commonmark ofrece opciones de configuración como `html_input: 'strip'` y `allow_unsafe_links: false` para mitigar los ataques de cross-site scripting (XSS) eliminando HTML sin formato y deshabilitando enlaces no seguros. Sin embargo, al habilitar la extensión Attributes, los usuarios pueden inyectar atributos HTML arbitrarios en elementos mediante la sintaxis Markdown, utilizando llaves. La versión 2.7.0 incluye tres cambios para prevenir este vector de ataque XSS: todos los atributos que empiezan por `on` se consideran no seguros y se bloquean por defecto; se admite una lista explícita de atributos HTML permitidos; y los atributos `href` y `src` añadidos manualmente ahora respetan la opción de configuración `allow_unsafe_links`. Si la actualización no es posible, considere deshabilitar `AttributesExtension` para usuarios no confiables y/o filtrar el HTML renderizado a través de una librería como HTMLPurifier.
References
Sources
| Source | Record | Licence |
|---|---|---|
| CVE List | CVE-2025-46734 changed 2025-05-06 | CVE Terms of Use |
| GitHub Advisory Database | GHSA-3527-qv2q-pfvx changed 2026-03-20 | CC-BY-4.0 |
| NVD | CVE-2025-46734 changed 2026-06-17 | Public domain |