Skip to content

[Security] Bump league/commonmark from 2.4.2 to 2.6.0

Bumps league/commonmark from 2.4.2 to 2.6.0. This update includes a security fix.

Vulnerabilities fixed

league/commonmark's quadratic complexity bugs may lead to a denial of service

Impact

Several polynomial time complexity issues in league/commonmark may lead to unbounded resource exhaustion and subsequent denial of service.

Malicious users could trigger that inefficient code with carefully crafted Markdown inputs that are specifically designed to ensure the worst-case performance is reached. Sending multiple such requests in parallel could tie up all available CPU resources and/or PHP-FPM processes, leading to denial of service for legitimate users.

Patches

These vulnerabilities have been patched in version 2.6.0. All users on older versions are highly encouraged to upgrade as soon as possible.

Workarounds

If you cannot upgrade, you may be able to mitigate the issues by:

  • Setting very low memory_limit and max_execution_time PHP configurations to prevent runaway resource usage
  • Implementing rate-limiting, bot protection, or other approaches to reduce the risk of simultaneous bad requests hitting your site
  • Limiting the size of inputs fed into this library (specifically the max length of each line)
  • Limiting the use of this library to trusted users

References

... (truncated)

Patched versions: 2.6.0
Affected versions: < 2.6.0

Release notes

Sourced from league/commonmark's releases.

2.6.0

This is a security release to address potential denial of service attacks when parsing specially crafted, malicious input from untrusted sources (like user input). See https://github.com/thephpleague/commonmark/security/advisories/GHSA-c2pc-g5qf-rfrf for more details.

Added

  • Added max_delimiters_per_line config option to prevent denial of service attacks when parsing malicious input
  • Added table/max_autocompleted_cells config option to prevent denial of service attacks when parsing large tables
  • The AttributesExtension now supports attributes without values (#985, #986)
  • The AutolinkExtension exposes two new configuration options to override the default behavior (#969, #987):
    • autolink/allowed_protocols - an array of protocols to allow autolinking for
    • autolink/default_protocol - the default protocol to use when none is specified
  • Added RegexHelper::isWhitespace() method to check if a given character is an ASCII whitespace character
  • Added CacheableDelimiterProcessorInterface to ensure linear complexity for dynamic delimiter processing
  • Added Bracket delimiter type to optimize bracket parsing

Changed

  • [ and ] are no longer added as Delimiter objects on the stack; a new Bracket type with its own stack is used instead
  • UrlAutolinkParser no longer parses URLs with more than 127 subdomains
  • Expanded reference links can no longer exceed 100kb, or the size of the input document (whichever is greater)
  • Delimiters should always provide a non-null value via DelimiterInterface::getIndex()
    • We'll attempt to infer the index based on surrounding delimiters where possible
  • The DelimiterStack now accepts integer positions for any $stackBottom argument
  • Several small performance optimizations

2.5.3

Changed

  • Made compatible with CommonMark spec 0.31.1, including:
    • Remove source, add search to list of recognized block tags

Full Changelog: https://github.com/thephpleague/commonmark/compare/2.5.2...2.5.3

2.5.2

Changed

  • Boolean attributes now require an explicit true value (#1040)

Fixed

  • Fixed regression where text could be misinterpreted as an attribute (#1040)

Full Changelog: https://github.com/thephpleague/commonmark/compare/2.5.1...2.5.2

2.5.1

Fixed

... (truncated)

Changelog

Sourced from league/commonmark's changelog.

[2.6.0] - 2024-12-07

This is a security release to address potential denial of service attacks when parsing specially crafted, malicious input from untrusted sources (like user input).

Added

  • Added max_delimiters_per_line config option to prevent denial of service attacks when parsing malicious input
  • Added table/max_autocompleted_cells config option to prevent denial of service attacks when parsing large tables
  • The AttributesExtension now supports attributes without values (#985, #986)
  • The AutolinkExtension exposes two new configuration options to override the default behavior (#969, #987):
    • autolink/allowed_protocols - an array of protocols to allow autolinking for
    • autolink/default_protocol - the default protocol to use when none is specified
  • Added RegexHelper::isWhitespace() method to check if a given character is an ASCII whitespace character
  • Added CacheableDelimiterProcessorInterface to ensure linear complexity for dynamic delimiter processing
  • Added Bracket delimiter type to optimize bracket parsing

Changed

  • [ and ] are no longer added as Delimiter objects on the stack; a new Bracket type with its own stack is used instead
  • UrlAutolinkParser no longer parses URLs with more than 127 subdomains
  • Expanded reference links can no longer exceed 100kb, or the size of the input document (whichever is greater)
  • Delimiters should always provide a non-null value via DelimiterInterface::getIndex()
    • We'll attempt to infer the index based on surrounding delimiters where possible
  • The DelimiterStack now accepts integer positions for any $stackBottom argument
  • Several small performance optimizations

[2.5.3] - 2024-08-16

Changed

  • Made compatible with CommonMark spec 0.31.1, including:
    • Remove source, add search to list of recognized block tags

[2.5.2] - 2024-08-14

Changed

  • Boolean attributes now require an explicit true value (#1040)

Fixed

  • Fixed regression where text could be misinterpreted as an attribute (#1040)

[2.5.1] - 2024-07-24

Fixed

  • Fixed attribute parsing incorrectly parsing mustache-like syntax (#1035)
  • Fixed incorrect Table start line numbers (#1037)

... (truncated)

Commits
  • d150f91 Prepare to release 2.6.0
  • 2f1e520 Merge commit from fork
  • d777db8 Add pathological test for deeply-nested blocks
  • 92dbad9 Flag this as a security release
  • 8b9d95e Fix pathological test suite failing not loading extensions in CI
  • 5156796 Add max_delimiters_per_line config option
  • 5ce491f Optimize repeated parsing of links without closing brace
  • 540d850 Fix quadratic complexity parsing long backtick code spans with no matching cl...
  • e1cfa8d Use recursive lookup as a last resort to avoid throwing
  • b61bbd4 Use delimiter position to optimize processing
  • Additional commits viewable in compare view

Merge request reports

Loading