GitHub Advisoryadvisory · PyPI

GHSA-vq2f-vcc9-j8mv Python Liquid: Infinite loop when parsing malformed `{% case %}` tags

MEDIUM Published 2026-06-19 Modified 2026-06-19 Official page ↗
Aliases
CVE-2026-55865
Ecosystem
PyPI
Packages
python-liquid
Severity
Moderate
CVSS vector
CVSS:4.0/AV:N/AC:L/AT:N/PR:L/UI:N/VC:N/VI:N/VA:L/SC:N/SI:N/SA:N
Weaknesses
CWE-835
Reviewed
2026-06-19

Affected packages

• PyPI python-liquid: < 2.2.1 → fixed in 2.2.1

Description

Impact Given a malformed `{% case %}` tag without associated `{% when %}` or `{% else %}` block, and no terminating `{% endcase %}` tag, Python Liquid hangs in an infinite loop at parse time. This allows malicious template authors to craft templates for a denial of service attack. Patches The issue is fixed in version 2.2.1 with the correction of the `liquid.TokenStream.eof` attribute. The `kind` and `value` of the special EOF token are now the same, so either can be tested against `liquid.token.TOKEN_EOF`. Workarounds Manually correct the definition of `liquid.TokenStream.eof` before parsing any templates. ```python import liquid from liquid.token import TOKEN_EOF liquid.stream.TokenStream.eof = liquid.Token(TOKEN_EOF, TOKEN_EOF, -1, "") ... ```

Related

Alias · CVE (1)

  • CVE-2026-55865 Python Liquid is a Python engine for the Liquid template language. vulnerability

Weakness · CWE (1)

  • CWE-835 Loop with Unreachable Exit Condition weakness

References