{"answers":{"affected":"2 open source packages ship an affected version, including handlebars.","exploited":"There is no known exploitation of GHSA-442j-39wm-28r2 in the wild and no public exploit code.","fix":"Upgrade handlebars to 4.7.9 or later.","what":"GHSA-442j-39wm-28r2 is a vulnerability in handlebars, published on 29 Mar 2026. An attacker can exploit it over the internet without logging in, with no action from the victim."},"fix_prompt":"Check this codebase for GHSA-442j-39wm-28r2 and fix it if it is affected.\n\nWhat it is: GHSA-442j-39wm-28r2 is a vulnerability in handlebars, published on 29 Mar 2026. An attacker can exploit it over the internet without logging in, with no action from the victim.\nExploitation: There is no known exploitation of GHSA-442j-39wm-28r2 in the wild and no public exploit code.\n\nAffected packages and fixed versions:\n- handlebars (npm): affected from 4.0.0; fixed in 4.7.9\n- handlebars (npm): affected from 4.0.0; fixed in 4.7.9\n\nTask:\n1. Search the dependency manifests and lockfiles (for example package.json, package-lock.json, requirements.txt, poetry.lock, uv.lock, pom.xml, build.gradle, go.mod, Cargo.lock, Gemfile.lock) and any Dockerfiles for the affected packages, including transitive dependencies.\n2. If an affected version is in use, upgrade it to the fixed version for its release line with the project's package manager, so the lockfile is regenerated. Prefer the smallest upgrade that fixes it.\n3. If there is no fix, or the upgrade would break the build, do not guess: explain the risk and the safest workaround instead.\n4. Run the tests and summarise what changed and why.\n5. If nothing in the project is affected, say so and change nothing.\n\nReference: https://insights.sbomify.com/GHSA-442j-39wm-28r2/ (Markdown: https://insights.sbomify.com/GHSA-442j-39wm-28r2/index.md)","id":"GHSA-442j-39wm-28r2","markdown":"https://insights.sbomify.com/GHSA-442j-39wm-28r2/index.md","name":"GHSA-442j-39wm-28r2","record":{"aliases":[],"analysis":{"component_type":"library","fix_type":"patch","impacts":["data_read","security_bypass"],"network_reachable":"yes","non_default_config":true,"product_category":"JavaScript templating library","requires_auth":"none","summary":"Attackers can bypass prototype access controls in Handlebars.js when compat mode is enabled, potentially reading restricted properties from context objects.","user_interaction":"not_required","vuln_class":"security_feature_bypass"},"analysis_generated_by":"qwen3.8-flash-next","assigner":null,"cpe":[],"cvss":{"score":null,"severity":null,"source":null,"vector":null,"version":null},"cwes":[],"description":"## 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 \u003c len; i++) {\n    let result = depths[i] \u0026\u0026 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).","ecosystems":["npm"],"exploits":{"exploitdb":null,"first_seen":null,"github_poc":null,"max_poc_stars":null,"metasploit":null,"nuclei":null,"refs":[],"tier":null},"has_fix":true,"headline":"Handlebars.js has a Property Access Validation Bypass in container.lookup","id":"GHSA-442j-39wm-28r2","indexable":true,"kev":null,"kind":"advisory","links":{"ecosystem":"npm","product":null,"products":[],"type":"security_feature_bypass","year":"2026"},"n_packages":2,"n_references":null,"packages":[{"ecosystem":"npm","fixed":["4.7.9"],"introduced":["4.0.0"],"last_affected":[],"package":"handlebars","purl":null,"source":"GHSA-442j-39wm-28r2"},{"ecosystem":"npm","fixed":["4.7.9"],"introduced":["4.0.0"],"last_affected":[],"package":"handlebars","purl":"pkg:npm/handlebars","source":"GHSA-442j-39wm-28r2"}],"products":null,"published":"2026-03-29","related":[],"sources":[{"class":"attribution","licence":"CC BY 4.0","name":"GitHub Advisory Database","prefix":"GHSA"}],"ssvc":{"automatable":null,"exploitation":null,"technical_impact":null},"state":null,"updated":null,"vendors":null},"summary":"Attackers can bypass prototype access controls in Handlebars.js when compat mode is enabled, potentially reading restricted properties from context objects.","url":"https://insights.sbomify.com/GHSA-442j-39wm-28r2/"}