{"id":"GHSA-m7fp-h3p4-hr49","revision":"d7cad36d0360478f993d5f4a320cee19","records":[{"revision":"d7cad36d0360478f993d5f4a320cee19","observedAt":"2026-10-24T13:17:17.793+00:00","statement":{"source":"osv","id":"GHSA-m7fp-h3p4-hr49","aliases":["CVE-2026-61556"],"title":"LiquidJS has an infinite loop vulnerability in its `strip_html` filter","description":"### Summary\nThe current implementation of `strip_html` can cause an infinite loop when the input string contains `<`, has at least one character before `<`, and no `>` appears after `<`.\n\n### Details\nThe problem is in `src/filters/html.ts`.\nSpecifically, the following part has the infinite loop.\n\n```\n// Raw-text blocks (HTML5) plus '<...>' as the catch-all kind; a regex\n// equivalent is O(n^2) in V8 on unclosed openers.\nexport function strip_html (this: FilterImpl, v: string) {\n  const str = stringify(v)\n  this.context.memoryLimit.use(str.length)\n  const blocks = new Map([['<script', '</script>'], ['<style', '</style>'], ['<!--', '-->'], ['<', '>']])\n  let out = ''\n  let i = 0\n  while (i < str.length) {\n    const lt = str.indexOf('<', i)\n    if (lt < 0) return out + str.slice(i)\n    out += str.slice(i, lt)\n    for (const [opener, closer] of blocks) {\n      if (!str.startsWith(opener, lt)) continue\n      const e = str.indexOf(closer, lt + opener.length)\n      if (e >= 0) { i = e + closer.length; break }\n      blocks.delete(opener)\n    }\n    if (i === lt) return out + str.slice(lt)\n  }\n  return out\n}\n```\n\nFor the input \"a<\", the variable `lt` is updated to 1 by `const lt = str.indexOf('<', i)`. However, the variable `i` is never updated from its initial value of 0. This is because in `const e = str.indexOf(closer, lt + opener.length)`, `e` becomes -1, since there is no > after <. Therefore, when execution reaches `if (i === lt) return out + str.slice(lt)`, `i` is 0. This is the same state as at the beginning of the loop. As a result, the same thing is repeated again from that state, causing an infinite loop.\n\n\n### PoC\n```\nconst { Liquid } = require('liquidjs');\n\nconst engine = new Liquid();\n\nengine.parseAndRender('{{ html | strip_html }}', {\n  html: 'a<'\n}).then(console.log);\n\nconsole.log(\"This is never displayed.\");\n```\n\n### Impact\nThis is an infinite loop vulnerability (cf. https://cwe.mitre.org/data/definitions/835.html). This results in a denial of service (DoS). Although a ReDoS vulnerability has previously been reported in the affected function (cf. https://github.com/harttle/liquidjs/security/advisories/GHSA-r7g9-xpmj-5fcq), this issue can cause a more severe impact than that ReDoS vulnerability with an input of only two characters at minimum.\n\n### Recommended Fix\nThere is an issue with the following conditional branch.\n\n```\nif (i === lt) return out + str.slice(lt);\n```\n\nThe following should fix the issue.\n\n```\nif (i <= lt) return out + str.slice(lt);\n```","state":0,"publishedAt":"2026-09-03T17:45:26+00:00","modifiedAt":"2026-09-03T18:00:04.4473682+00:00","affected":[{"ecosystem":"npm","name":"liquidjs","ranges":[{"type":"SEMVER","events":[{"kind":"introduced","version":"10.26.0"},{"kind":"fixed","version":"10.27.1"}]}],"versions":[],"rawVersionEvidence":null}],"metrics":[{"system":"CVSS_V4","vector":"CVSS:4.0/AV:N/AC:L/AT:N/PR:N/UI:N/VC:N/VI:N/VA:H/SC:N/SI:N/SA:N","score":null,"severity":null},{"system":"Publisher rating","vector":null,"score":null,"severity":"HIGH"}],"references":["https://github.com/harttle/liquidjs/security/advisories/GHSA-m7fp-h3p4-hr49","https://nvd.nist.gov/vuln/detail/CVE-2026-61556","https://github.com/harttle/liquidjs/pull/917","https://github.com/harttle/liquidjs/commit/5c3522f33928aae66f0fe85c36e1d9015c768fe2","https://github.com/harttle/liquidjs","https://github.com/harttle/liquidjs/releases/tag/v10.27.1"],"sourceUrl":"https://github.com/advisories/GHSA-m7fp-h3p4-hr49","license":"GitHub Advisory Database · CC-BY-4.0","key":"osv:GHSA-m7fp-h3p4-hr49","identifiers":["GHSA-m7fp-h3p4-hr49","CVE-2026-61556"]},"retained":false,"historicalAffected":[]}],"coverage":[]}