Skip to main content

CVE-2025-46734: CWE-79: Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting') in thephpleague commonmark

Medium
VulnerabilityCVE-2025-46734cvecve-2025-46734cwe-79
Published: Mon May 05 2025 (05/05/2025, 19:52:59 UTC)
Source: CVE
Vendor/Project: thephpleague
Product: commonmark

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.

AI-Powered Analysis

AILast updated: 07/06/2025, 18:57:18 UTC

Technical Analysis

CVE-2025-46734 is a cross-site scripting (XSS) vulnerability affecting the Attributes extension of the league/commonmark PHP Markdown parser library, versions 1.5.0 through 2.6.x. The vulnerability arises because the Attributes extension allows users to inject arbitrary HTML attributes into elements using Markdown syntax with curly braces. This capability can be exploited by remote attackers to insert malicious JavaScript code into HTML output, leading to XSS attacks. Although the library provides configuration options such as 'html_input: strip' to remove raw HTML and 'allow_unsafe_links: false' to block unsafe links, these protections are circumvented when the Attributes extension is enabled. The vulnerability enables injection of attributes starting with 'on' (e.g., onclick), which can execute JavaScript in the context of the victim's browser. Version 2.7.0 of the library addresses this issue by blocking all attributes starting with 'on' by default, introducing an explicit allowlist for HTML attributes, and ensuring that manually added 'href' and 'src' attributes respect the 'allow_unsafe_links' setting. If upgrading to 2.7.0 is not feasible, it is recommended to disable the Attributes extension for untrusted users or sanitize the rendered HTML output using libraries like HTMLPurifier to mitigate XSS risks. The CVSS 3.1 base score is 6.4 (medium severity), reflecting network attack vector, low attack complexity, requiring privileges but no user interaction, and impacting confidentiality and integrity with a scope change. No known exploits are currently reported in the wild.

Potential Impact

For European organizations, this vulnerability poses a significant risk especially for web applications that utilize the league/commonmark library with the Attributes extension enabled to render user-generated Markdown content. Successful exploitation can lead to execution of arbitrary JavaScript in users' browsers, enabling theft of session tokens, user impersonation, defacement, or delivery of further malware. This can compromise confidentiality and integrity of user data and potentially damage organizational reputation. Sectors such as finance, healthcare, government, and e-commerce, which often rely on PHP-based content management or collaboration platforms, may be particularly vulnerable. The vulnerability's ability to escalate privileges within the application context and affect multiple users through shared content increases its impact. Given the medium severity and absence of known exploits, the threat is moderate but warrants prompt remediation to prevent potential targeted attacks or automated exploitation campaigns.

Mitigation Recommendations

1. Upgrade the league/commonmark library to version 2.7.0 or later, which includes built-in protections against this XSS vector. 2. If immediate upgrade is not possible, disable the Attributes extension for any untrusted or external user input to prevent injection of unsafe attributes. 3. Implement server-side HTML sanitization of rendered Markdown output using robust libraries such as HTMLPurifier to remove or neutralize malicious scripts and attributes. 4. Review and tighten configuration settings: ensure 'html_input' is set to 'strip' and 'allow_unsafe_links' is false to minimize raw HTML and unsafe links. 5. Conduct code audits and penetration testing focused on Markdown rendering components to detect residual injection risks. 6. Educate developers and content managers about safe Markdown usage and the risks of enabling unsafe extensions. 7. Monitor web application logs for unusual input patterns or errors related to Markdown rendering that may indicate exploitation attempts.

Need more detailed analysis?Get Pro

Technical Details

Data Version
5.1
Assigner Short Name
GitHub_M
Date Reserved
2025-04-28T20:56:09.085Z
Cisa Enriched
true
Cvss Version
3.1
State
PUBLISHED

Threat ID: 682d981cc4522896dcbda9b5

Added to database: 5/21/2025, 9:08:44 AM

Last enriched: 7/6/2025, 6:57:18 PM

Last updated: 8/8/2025, 9:35:27 PM

Views: 8

Actions

PRO

Updates to AI analysis are available only with a Pro account. Contact root@offseq.com for access.

Please log in to the Console to use AI analysis features.

Need enhanced features?

Contact root@offseq.com for Pro access with improved analysis and higher rate limits.

Latest Threats