Affected versions

Twig Markdown Extra versions <3.31.1 are affected by this security issue.

The issue has been fixed in Twig Markdown Extra 3.31.1.

Description

The html_to_markdown filter of twig/markdown-extra keeps an HtmlConverter for each distinct mapping of options it receives. They're kept in a static array, with no size limit and no eviction. The options are an argument of the filter. A template that passes options taken from the input, or a sandboxed template, can therefore make this cache grow without limit. The cache outlives the environment, so it fills the memory of long-running workers.

Resolution

The cache now keeps at most 100 converters, like the formatter caches of IntlExtension.

The patch for this issue is available here for branch 3.x.

Credits

We would like to thank Nicolas Grekas for reporting the issue.