Skip to content
Putting technology to work.
Insights to guide decisions and action.

Search articles

Settings to review with league/commonmark 2.10.9

Table of contents · 7 items

On screens that convert user-written Markdown to HTML for display, such as announcements, comments, inquiry bodies, and internal wikis, a single conversion setting can let raw HTML or dangerous links be output as is. One of the libraries that handles this conversion in PHP is league/commonmark, which Laravel's Str::markdown() also uses internally. This library released 2.10.8 on November 24 and 2.10.9 on November 25.

The changelog lists three processing-time problems with advisory numbers (GHSA), and a fix without an advisory number for a problem where "writing attribute names in uppercase could overwrite link targets and image sources." Which of these apply to your screens depends on the conversion settings, the extensions you have added, the PHP environment, and the size of the input.

In this article, based on the changelog, advisories, fix commits, tests, and documentation source in the league/commonmark repository, we sort out the conditions under which the issues apply and the steps to check. The three advisories were published in the repository at the same time as the fixed versions (the two for 2.10.8 on November 24, 15:45, and the one for 2.10.9 on November 25, 20:11 (UTC)). However, as of November 26, they are not listed in Packagist's advisory API or GitHub's advisory database.

What was fixed in 2.10.8 and 2.10.9

According to Packagist, 2.10.8 was released on November 24, 15:44 (UTC), and 2.10.9 on November 25, 20:08 (UTC). The previous version, 2.10.7, was released on October 31. As of November 26, 2.10.9 is the latest.

ReleaseFix (per the changelog)SeverityConditions under which it applies (per the advisory)
2.10.8GHSA-h4px-59g8-q37c: Long runs of _ or * deepen emphasis nesting, and rendering takes quadratic timeLowRegardless of settings. Even with max_delimiters_per_line set, a run was counted as one
2.10.8GHSA-8q9g-2c37-97xp: On lines with many unclosed {, attribute parsing backtracks excessivelyMediumAttributesExtension is added
2.10.9GHSA-jj45-w5cj-2hc8: Processing time grows long with inline HTML comments, URL autolinks, and moreMediumParagraphs of about 500KB or more even with default settings. PCRE JIT disabled, GFM autolinks with PHP 8.2 or earlier, and others
2.10.9#1176: Uppercase attribute names such as {HREF=...} take precedence in browsers over attributes set by the rendererNo advisoryAttributesExtension is added
2.10.9#1177: When a regular expression hits the PCRE limit, raw HTML stripping and dangerous link checks are bypassedNo advisoryDisallowedRawHtmlExtension or allow_unsafe_links is used

For severity, each advisory's "low" is shown as Low and "medium" as Medium.

The GHSA-jj45-w5cj-2hc8 advisory lists three cases. The first is with default settings (JIT enabled), where parsing a paragraph of about 500KB or more, in which a declaration starting with <! is followed by a long run of letters, takes about one minute. This happens even without extensions. The second is GFM autolinks: in 2.9.0 and later, only on PHP 7.4–8.2, lines with many www. and similar take quadratic time. The third is environments with JIT disabled (pcre.jit=0), where inline HTML comments, autolinks, footnotes, and more take quadratic time. According to the advisory, with JIT disabled, the mitigations for vulnerabilities disclosed in 2023 (CVE-2023-22483 and CVE-2023-22484) could also be bypassed with only slight changes to the input.

According to the GHSA-8q9g-2c37-97xp advisory, even with default settings, a single 24KB line takes more than 20 seconds. Advisories about AttributesExtension processing time were also issued in August (GHSA-g2gp-3wwq-f4ph, GHSA-jjv6-8j6v-6j52, GHSA-8rr7-cvq3-gmfh), but the advisory explains that this one is a different processing path. Even if you applied the earlier fixes, you need to update to this release.

A diagram sorting the league/commonmark 2.10.8 and 2.10.9 fixes by the conditions under which they apply. If AttributesExtension is added, attribute parsing backtracking and overwriting href or src with uppercase attribute names apply. With GFM conversion, the bypass of raw HTML stripping when the PCRE limit is hit and autolink processing time apply. Runs of emphasis characters slow rendering regardless of settings, and after the fix can be prevented with max_delimiters_per_line. Processing-time problems are more likely in environments with JIT disabled, before PHP 8.3, and with large paragraphs

Uppercase attribute names could overwrite link targets (#1176)

AttributesExtension is an extension that lets you add HTML attributes from within Markdown, as in [リンク](https://example.com){target=_blank}. Before the fix, it output attribute names with their uppercase and lowercase letters unchanged.

A comment in the fix commit explains the reason: "Browsers keep only the first of two names differing in case, and user attributes are rendered before those added by renderers and other extensions." Because HTML attribute names are case-insensitive, when HREF and href appear together, the browser uses the one that comes first. Attributes written in the document come before those added by the renderer, so a user-written HREF won over the link's original href.

The added test confirms that after the fix, the original targets remain for the following input.

[l](http://ok.com){HREF="http://evil.com"}
![i](http://ok.com/a.png){SRC="http://evil.com/b.png"}
[l](http://ext.com){TARGET=_self}

The first line becomes <a href="http://ok.com">, and the second becomes <img src="http://ok.com/a.png" ...>. In the third line, the target="_blank" from the setting that opens external links in a new tab (ExternalLinkExtension) remains. The changelog says that the footnote reference href and HeadingPermalinkExtension's id could likewise be overwritten.

After the fix, attribute names are normalized to lowercase. The list of allowed attributes (attributes/allow) is also no longer case-sensitive. According to the changelog, entries previously written as 'ID' or 'CLASS' did not match #id or .class.

This issue has no advisory number. However, the editorial team believes that the ability to replace a link target with a different URL through user-written Markdown cannot be overlooked on bulletin boards and comment sections that use AttributesExtension.

What settings can and cannot prevent

league/commonmark's default settings are not on the safe side, because they follow the CommonMark specification. The descriptions in the configuration documentation (docs/2.x/configuration.md) and the security page (docs/2.x/security.md) can be summarized as follows.

ConfigurationDefaultsGuidance for handling user input
html_inputallow (outputs raw HTML as is)"Strongly" recommends escape or strip
allow_unsafe_linkstruefalse to remove javascript: and the like
max_nesting_levelPHP_INT_MAX100
max_delimiters_per_linePHP_INT_MAXAround 100–1000 depending on the use case

However, these settings do not prevent the current processing-time problems. The GHSA-jj45-w5cj-2hc8 and GHSA-8q9g-2c37-97xp advisories state that the four settings above (and also attributes/allow for 8q9g) do not limit these cases. max_delimiters_per_line became able to prevent the emphasis issue only after its counting was fixed in 2.10.8. The advisory also states that while PHP's max_execution_time stops long conversions in web requests, CLI scripts and queue workers have no time limit by default.

In 2.10.9, a "PCRE JIT and Input Size" section was added to the security page. It advises checking whether ini_get('pcre.jit') is "1" in the SAPI that actually handles requests, or whether "PCRE JIT Support => enabled" appears in phpinfo(). It says JIT is effectively disabled if the settings differ between CLI and FPM, or if "Allocation of JIT memory failed" appears in the logs. For input size, it recommends limiting not only line length but the whole input to what the use case requires. The GHSA-jj45-w5cj-2hc8 advisory states that in 2.9.0 and later, apps on PHP 8.3 or later with JIT enabled that limit user Markdown to under about 100KB per paragraph are effectively unaffected.

AttributesExtension is not part of the GFM (GitHub Flavored Markdown) extension bundle. What GithubFlavoredMarkdownExtension adds in 2.10.9 is autolinks, partial raw HTML stripping (DisallowedRawHtml), strikethrough, tables, and task lists. The two attribute issues apply to code that adds AttributesExtension itself.

How it is used in Laravel

The composer.json of Laravel 13.x requires "league/commonmark": "^2.8.1". 2.10.9 falls within this range, so you can update with composer update league/commonmark without upgrading Laravel itself.

  • Str::markdown() and str()->markdown(): Use new GithubFlavoredMarkdownConverter($options). If no options are passed, the defaults in the table above remain (html_input is allow, and allow_unsafe_links is true)
  • Str::inlineMarkdown(): Conversion with InlinesOnlyExtension added to the GFM extensions. Settings are handled the same way
  • Markdown mail (Illuminate\Mail\Markdown): Sets allow_unsafe_links to false and uses the CommonMark core and the table extension

Str::markdown() is a GFM conversion, so it includes autolinks and is subject to GHSA-jj45-w5cj-2hc8. AttributesExtension is not included unless added through an argument.

For screens that pass user input to Str::markdown(), it is worth checking whether options are specified. For example, you can specify them as follows (example by the editorial team). Even this does not prevent the three processing-time issues, so updating the library and limiting input size are needed separately.

Str::markdown($post->body, [
    'html_input' => 'escape',
    'allow_unsafe_links' => false,
    'max_nesting_level' => 100,
    'max_delimiters_per_line' => 1000,
]);

Note that Laravel 13.44.0, released on November 24, includes "Fix attribute escaping in secured Markdown mail" (#62597). This change fixes, on the Laravel side, the escaping of values embedded in Markdown mail templates, and is separate from the current league/commonmark fixes. For Markdown mail, advisory GHSA-5xc4-gpwg-p8wq (severity: low) was also published in the Laravel repository on November 18. It concerns protection not taking effect, even when using Markdown::withSecuredEncoding(), if views were pre-generated with php artisan view:cache or similar, and it was fixed in 13.43.0 and 12.73.0. This is also separate from league/commonmark.

Steps to check (editorial suggestion)

  1. Check the version. Use composer show league/commonmark to see whether it is earlier than 2.10.9. These three issues are not listed in the advisory databases, so if you wait for composer audit or Dependabot notifications, you may not notice them
  2. List the places that do conversion. Find candidates with the following expression and check one by one whether user-written strings reach them
grep -rnE "Str::markdown|inlineMarkdown|->markdown\(|CommonMarkConverter|GithubFlavoredMarkdownConverter|MarkdownConverter|AttributesExtension" app/ src/ resources/
  1. Review the settings. Check whether conversions that handle user input specify the four settings in the table above. If you use AttributesExtension, allow only the attributes you need with attributes/allow
  2. Check JIT and input size. Check pcre.jit in production FPM, and set upper limits on body size in forms and APIs. If you convert in queue workers or the CLI, also keep in mind that there is no time limit
  3. Update and check the display. From 2.10.8, max_delimiters_per_line counts the characters one by one, so with low values, emphasis may be output as plain characters. Attribute lists over 8192 bytes and malformed attribute lists also remain as plain text. If raw HTML is allowed (allow), in 2.10.9 genuine tags after an escaped < or a code span are output as HTML

Scope of verification

On November 26, 2026, we checked the changelog (CHANGELOG.md) for tags 2.10.7 to 2.10.9 of thephpleague/commonmark, the descriptions, diffs, and tests of the fix commits (71c0cc8, 11a4613, 0773fc7, 5d3c1af, eb20850, 2dd9abf), the documentation source (docs/2.x/security.md, configuration.md, extensions/attributes.md) and the security page on the documentation site, and Packagist's publication dates and times and advisory API. We checked the text, severity, affected versions, and publication dates and times of the three advisories by opening the repository's advisories through the GitHub API. We also confirmed via the API on November 26 that the three are not listed in GitHub's advisory database. For Laravel, we checked composer.json, Str.php, and Mail/Markdown.php in laravel/framework 13.x, commit 90e6a60, and advisory GHSA-5xc4-gpwg-p8wq (desk research). We have not checked reproductions of each issue, the processing times stated in the advisories, or the behavior of the versions before and after the fixes.

We covered PHP CMS updates in our baserCMS article, the advisory for a Laravel admin panel component in our Filament Curator article, and processing-time problems in a component that removes dangerous markup from user input in our .NET HtmlSanitizer article.

For maintenance of Laravel sites and business systems with screens where users post content, or how to approach library updates, please contact us through Development, AI, and automation consultation.

References

Share this articleXFacebook
Kakeru Suzuki

Fascinated by the possibilities of technology, has had a deep interest in programming and digital art since student days

Turn this article's theme into your company's next step

Concrete steps forward for your organization.

We organize your desired architecture, legacy systems, and operational requirements to formulate your next steps toward execution.

  • Desired architecture
  • Integration with existing environments
  • Operational requirements
Consult on development & operations initiatives

You can consult with us from the initial conceptual stage. Details from this article will be carried over to the inquiry form.

Receive the latest articles by email