The vulnerability exists in the handling of nested {% block %} tags with the same name within a {% layout %} structure in the liquidjs library. The root cause is an uncontrolled recursion.
When a template contains a block nested inside another block of the same name (e.g., {% block a %}{% block a %}{% endblock %}{% endblock %}), the rendering process enters an infinite loop. This occurs in the Block.getBlockRender function located in src/tags/block.ts.
The vulnerable logic works as follows: when rendering the inner block, the getBlockRender function looks up the render function for that block name. It finds the render function of the outer block and calls it. This re-renders the content of the outer block, which includes the inner block, causing the process to repeat indefinitely.
This infinite recursion rapidly consumes system memory, leading to a JavaScript heap out of memory error that crashes the Node.js process, resulting in a Denial of Service (DoS). Any user with permission to submit Liquid templates can trigger this vulnerability.
The patch addresses this by introducing a blockStack in the rendering context. Before a block is rendered, it's pushed onto the stack. A check is added to ensure a block is not already on the stack before rendering, effectively breaking the infinite loop by throwing a 'block tag cannot be nested' error if a circular reference is detected.