CVE-2024-36361 Pug allows JavaScript code execution if an application accepts untrusted input

Medium 6.8 Published Updated

Attackers can execute arbitrary JavaScript if untrusted input is passed to specific Pug compilation functions, requiring developers to avoid such usage.

Exploited in the wild
Not known
Login needed
Not needed
Attackable
Over the internet
Victim action needed
A user has to click or open something
Fix
Available

What is CVE-2024-36361?

CVE-2024-36361 is a medium-severity code injection vulnerability in n/a, published on 24 May 2024. An attacker can exploit it over the internet without logging in, and only if a user opens a file or follows a link.

Official description

Pug through 3.0.2 allows JavaScript code execution if an application accepts untrusted input for the name option of the compileClient, compileFileClient, or compileClientWithDependenciesTracked function. NOTE: these functions are for compiling Pug templates into JavaScript, and there would typically be no reason to allow untrusted callers.

Weakness: CWE-94

Which versions are affected by CVE-2024-36361?

4 open source packages ship an affected version, including pug and pug-code-gen.

PackageAffectedFixed in
pug npmAll versions3.0.3
pug npmAll versions3.0.3
pug-code-gen npmAll versions3.0.3
pug-code-gen npmAll versions3.0.3

How do I fix CVE-2024-36361?

Upgrade pug to 3.0.3 or later.

Upgrade, and never evaluate templates, expressions or code built from user input. More about Code injection.

Is CVE-2024-36361 being exploited?

It is not confirmed as exploited in the wild, but public exploit code for CVE-2024-36361 exists.

Sources

Also known as CLSA-2026-1786620685, GHSA-3965-hpx2-q597, ROOT-APP-NPM-CVE-2024-36361.

Is CVE-2024-36361 in your software?

Upload an SBOM and sbomify checks it against every vulnerability here, every day.

Check your SBOMs for free