{"id":"CVE-2026-33940","published":"2026-03-27T21:11:10Z","modified":"2026-09-04T12:04:53Z","title":"Handlebars.js has JavaScript Injection via AST Type Confusion when passing an object as dynamic partial","vendor":"handlebars-lang","product":"handlebars.js","tier":"tail","description":{"text":"Handlebars provides the power necessary to let users build semantic templates. In versions 4.0.0 through 4.7.8, a crafted object placed in the template context can bypass all conditional guards in `resolvePartial()` and cause `invokePartial()` to return `undefined`. The Handlebars runtime then treats the unresolved partial as a source that needs to be compiled, passing the crafted object to `env.compile()`. Because the object is a valid Handlebars AST containing injected code, the generated JavaScript executes arbitrary commands on the server. The attack requires the adversary to control a value that can be returned by a dynamic partial lookup. Version 4.7.9 fixes the issue. Some workarounds are available. First, use the runtime-only build (`require('handlebars/runtime')`). Without `compile()`,  the fallback compilation path in `invokePartial` is unreachable. Second, sanitize context data before rendering: Ensure no value in the context is a non-primitive  object that could be passed to a dynamic partial. Third, avoid dynamic partial lookups (`{{> (lookup ...)}}`) when context data is user-controlled.","provenance":"source","from":"CVE.org"},"cvss":{"score":8.1,"severity":"HIGH","version":"3.1","vector":"CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:U/C:H/I:H/A:H","provenance":"source","from":"CVE.org CNA"},"epss":{"score":0.00782,"percentile":0.56919,"provenance":"source"},"cwes":[{"id":"CWE-94","name":"Improper Control of Generation of Code"},{"id":"CWE-843","name":"Access of Resource Using Incompatible Type"}],"references":[{"url":"https://github.com/handlebars-lang/handlebars.js/security/advisories/GHSA-xhpv-hc6g-r9c6","tags":["x_refsource_CONFIRM"]},{"url":"https://github.com/handlebars-lang/handlebars.js/commit/68d8df5a88e0a26fe9e6084c5c6aaebe67b07da2","tags":["x_refsource_MISC"]},{"url":"https://github.com/handlebars-lang/handlebars.js/releases/tag/v4.7.9","tags":["x_refsource_MISC"]},{"url":"https://access.redhat.com/security/cve/CVE-2026-33940","tags":["vdb-entry","x_refsource_REDHAT"]},{"url":"https://bugzilla.redhat.com/show_bug.cgi?id=2452521","tags":["issue-tracking","x_refsource_REDHAT"]},{"url":"https://security.access.redhat.com/data/csaf/v2/vex/2026/cve-2026-33940.json","tags":["x_sadp-csaf-vex"]},{"url":"https://access.redhat.com/errata/RHSA-2026:34342","tags":["vendor-advisory","x_refsource_REDHAT"]},{"url":"https://access.redhat.com/errata/RHSA-2026:10175","tags":["vendor-advisory","x_refsource_REDHAT"]}],"priority":{"score":17.1,"factors":[{"name":"EPSS percentile","points":11.38},{"name":"CVSS severity","points":5.67}]},"vendorSlug":"handlebars-lang","affectedVersions":[{"vendor":"handlebars-lang","product":"handlebars.js","versions":[">= 4.0.0, < 4.7.9"]}],"ssvc":{"exploitation":"poc","automatable":"no","technicalImpact":"total","timestamp":"2026-03-31T00:00:00+00:00","from":"CISA ADP","provenance":"source"},"affected":[{"ecosystem":"npm","package":"handlebars","vulnerableRanges":[">=4.0.0, <4.7.9"],"patched":["4.7.9"],"from":["GHSA-xhpv-hc6g-r9c6"],"provenance":"source"}],"summary":{"text":"Handlebars.js versions 4.0.0 through 4.7.8 contain a code injection flaw in the resolvePartial() and invokePartial() logic, which together with the runtime's fallback compilation path affects the template rendering engine. An attacker who can supply a crafted object that is returned by a dynamic partial lookup, with no authentication or user interaction required but high attack complexity, can cause the server to compile and execute arbitrary commands.","provenance":"ai","model":"claude-haiku-5-5","generatedAt":"2026-11-20T21:00:25Z"},"euvd":{"id":"EUVD-2026-16860","exploited":false,"provenance":"source"}}