GHSA-442j-39wm-28r2: Handlebars Handlebars.js Has A Property Access Vulnerability
LOWGHSA-442j-39wm-28r2 is a LOW (CVSS 3.7) handlebars.js has a property access vulnerability (CWE-367: Time-of-check Time-of-use (TOCTOU) Race Condition) affecting Handlebars libraries in the npm ecosystem. The issue involves handlebars.js has a property access validation bypass in container.lookup. Remediation is available by upgrading affected packages to version 4.7.9.
GHSA-442j-39wm-28r2 at a Glance
Security Impact
CVSS: 3.7
The security impact metrics below are parsed directly from the CVSS v3.1 vector string (CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:U/C:L/I:N/A:N).
How to Fix GHSA-442j-39wm-28r2
To remediate this vulnerability, upgrade all affected Handlebars dependencies to a patched release. Both direct and transitive dependencies should be checked, as frameworks or security libraries may pull in vulnerable versions transitively.
npm install handlebars@4.7.9
Run the following command in your project directory to verify that all resolved dependencies use the patched release:
npm ls handlebars
How to Check if You Are Affected
To determine whether your Node.js application is affected by GHSA-442j-39wm-28r2, inspect your project dependencies using npm:
npm ls handlebars
Analyze the terminal output to locate any version of Handlebars in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than 4.7.9), your application is affected.
Note: The npm ls handlebars command inspects dependencies declared in your package.json and lockfile; it does not perform automated runtime dynamic scanning.
Technical Details
Vulnerability Mechanism & Technical Analysis
This vulnerability is classified under CWE-367: Time-of-check Time-of-use (TOCTOU) Race Condition, where the product checks the state of a resource before using that resource, but the resource's state can change between the check and the use in a way that invalidates the results of the check. In Handlebars, software state validation or input boundaries are circumvented during processing. Review the official source advisory statement below for specific affected components, classes, and reproduction details.
Source Advisory Statement
GHSA-442j-39wm-28r2 Affected Handlebars Versions
1 component(s)| Product / Package | Ecosystem | Affected Versions | Fixed Version |
|---|---|---|---|
|
handlebars
|
npm |
≥ 4.0.0
< 4.7.9
|
4.7.9
|
References
Frequently Asked Questions
What is GHSA-442j-39wm-28r2?
Which Handlebars versions are affected?
What version fixes GHSA-442j-39wm-28r2?
Is handlebars affected?
What is the CVSS score of GHSA-442j-39wm-28r2?
What CWE is associated with GHSA-442j-39wm-28r2?
How can I check npm dependencies for GHSA-442j-39wm-28r2?
Machine-readable OSV JSON
OSV v1.5 Schema
{
"schema_version" : "1.4.0",
"id" : "GHSA-442j-39wm-28r2",
"modified" : "2026-03-29T15:16:37Z",
"published" : "2026-03-29T15:16:37Z",
"aliases" : [ ],
"summary" : "Handlebars.js has a Property Access Validation Bypass in container.lookup",
"details" : "## Summary\n\nIn `lib/handlebars/runtime.js`, the `container.lookup()` function uses `container.lookupProperty()` as a gate check to enforce prototype-access controls, but then discards the validated result and performs a second, unguarded property access (`depths[i][name]`). This Time-of-Check Time-of-Use (TOCTOU) pattern means the security check and the actual read are decoupled, and the raw access bypasses any sanitization that `lookupProperty` may perform.\n\nOnly relevant when the **compat** compile option is enabled (`{compat: true}`), which activates `depthedLookup` in `lib/handlebars/compiler/javascript-compiler.js`.\n\n## Description\n\nThe vulnerable code in `lib/handlebars/runtime.js` (lines 137–144):\n\n```javascript\nlookup: function (depths, name) {\n const len = depths.length;\n for (let i = 0; i < len; i++) {\n let result = depths[i] && container.lookupProperty(depths[i], name);\n if (result != null) {\n return depths[i][name]; // BUG: should be `return result;`\n }\n }\n},\n```\n\n`container.lookupProperty()` (lines 119–136) enforces `hasOwnProperty` checks and `resultIsAllowed()` prototype-access controls. However, `container.lookup()` only uses `lookupProperty` as a boolean gate — if the gate passes (`result != null`), it then performs an independent, raw `depths[i][name]` access that circumvents any transformation or wrapped value that `lookupProperty` may have returned.\n\n## Workarounds\n\n- Avoid enabling `{ compat: true }` when rendering templates that include untrusted data.\n- Ensure context data objects are plain JSON (no Proxies, no getter-based accessor properties).",
"severity" : [ {
"type" : "CVSS_V3",
"score" : "CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:U/C:L/I:N/A:N"
} ],
"affected" : [ {
"package" : {
"ecosystem" : "npm",
"name" : "handlebars"
},
"ranges" : [ {
"type" : "ECOSYSTEM",
"events" : [ {
"introduced" : "4.0.0"
}, {
"fixed" : "4.7.9"
} ]
} ],
"database_specific" : {
"last_known_affected_version_range" : "<= 4.7.8"
}
} ],
"references" : [ {
"type" : "WEB",
"url" : "https://github.com/handlebars-lang/handlebars.js/security/advisories/GHSA-442j-39wm-28r2"
}, {
"type" : "WEB",
"url" : "https://github.com/handlebars-lang/handlebars.js/commit/68d8df5a88e0a26fe9e6084c5c6aaebe67b07da2"
}, {
"type" : "PACKAGE",
"url" : "https://github.com/handlebars-lang/handlebars.js"
}, {
"type" : "WEB",
"url" : "https://github.com/handlebars-lang/handlebars.js/releases/tag/v4.7.9"
} ],
"database_specific" : {
"cwe_ids" : [ "CWE-367" ],
"severity" : "LOW",
"github_reviewed" : true,
"github_reviewed_at" : "2026-03-29T15:16:37Z",
"nvd_published_at" : null
}
}