Arbitrary Code Execution in handlebars
Key facts
- Attack vector
- —
- Privileges required
- —
- User interaction
- —
- Attack complexity
- —
- Impact type
- Code execution
- Confidentiality · integrity · availability
- —
- Fix status
- Fixed
No CVSS vector from any source. Fix status from GitHub. Impact type from CWE-94.
Summary
Versions of `handlebars` prior to 3.0.8 or 4.5.2 are vulnerable to Arbitrary Code Execution. The package's lookup helper fails to properly validate templates, allowing attackers to submit templates that execute arbitrary JavaScript in the system. It can be used to run arbitrary code in a server processing Handlebars templates or on a victim's browser (effectively serving as Cross-Site Scripting). The following template can be used to demonstrate the vulnerability: ```{{#with "constructor"}} {{#with split as |a|}} {{pop (push "alert('Vulnerable Handlebars JS');")}} {{#with (concat (lookup join (slice 0 1)))}} {{#each (slice 2 3)}} {{#with (apply 0 a)}} {{.}} {{/with}} {{/each}} {{/with}} {{/with}} {{/with}}``` ## Recommendation Upgrade to version 3.0.8, 4.5.2 or later.
Why it matters now
SSVC decision points
Not available: CISA has not published SSVC decision points for this record.
Affected products
| Vendor | Product | Affected versions | Fixed in | Status | Source |
|---|---|---|---|---|---|
| — | handlebars (npm) | before 3.0.8 | 3.0.8 | Patch available | GHSA-2cf5-4w76-r9qv |
| — | handlebars (npm) | 4.0.0 to before 4.5.2 | 4.5.2 | Patch available | GHSA-2cf5-4w76-r9qv |
- handlebars (npm) Vendor— Affected before 3.0.8 Fixed in 3.0.8 Patch available GHSA-2cf5-4w76-r9qv
- handlebars (npm) Vendor— Affected 4.0.0 to before 4.5.2 Fixed in 4.5.2 Patch available GHSA-2cf5-4w76-r9qv
Remediation
- Fix · GHSA-2cf5-4w76-r9qv handlebars (npm) Fixed in 3.0.8 Advisory →
- Fix · GHSA-2cf5-4w76-r9qv handlebars (npm) Fixed in 4.5.2 Advisory →
Timeline
- 2026-10-03 Threatist record created from GHSA-2cf5-4w76-r9qv
References
Sources
This product uses the NVD API but is not endorsed or certified by the NVD. Sources and licences