CVE-2021-21353

Remote code execution in pug

CRITICAL
9
CVSS Score
Published: March 3, 2021 at 01:50 AM UTC
Updated: June 17, 2026 at 03:35 AM UTC
2 products affected across 1 vendorPugPug Code Gen

Using pug by pugjs?

Get instant alerts when new vulnerabilities affect pug - before attackers find them.

Real-time alertsTrack your software stackFree plan available
Severity
CRITICAL9
Exploit prediction
EPSS 4%

Description

Pug is an npm package which is a high-performance template engine. In pug before version 3.0.1, if a remote attacker was able to control the `pretty` option of the pug compiler, e.g. if you spread a user provided object such as the query parameters of a request into the pug template inputs, it was possible for them to achieve remote code execution on the node.js backend. This is fixed in version 3.0.1. This advisory applies to multiple pug packages including "pug", "pug-code-gen". pug-code-gen has a backported fix at version 2.0.3. This advisory is not exploitable if there is no way for un-trusted input to be passed to pug as the `pretty` option, e.g. if you compile templates in advance before applying user input to them, you do not need to upgrade.

Affected

Our own answer: ranges merged, affected separated from platform-only, with confidence and review flags.

v < 3.0.1
Affected range stops below 3.0.1, so it looks safe — our inference, not a vendor statement
v < 2.0.33.0.0 ≤ v < 3.0.2
Affected range stops below 2.0.3, so it looks safe — our inference, not a vendor statement
Affected range stops below 3.0.2, so it looks safe — our inference, not a vendor statement

Remediation

No guide yet

No remediation guidance has been written for this CVE yet. What the record does show:

References (7)

x_refsource_MISCExploitPatchThird Party Advisory
https://github.com/pugjs/pug/issues/3312
x_refsource_MISCPatchThird Party Advisory
https://github.com/pugjs/pug/pull/3314
x_refsource_MISCRelease NotesThird Party Advisory
https://github.com/pugjs/pug/releases/tag/pug%403.0.1
x_refsource_MISCProductThird Party Advisory
https://www.npmjs.com/package/pug
x_refsource_MISCProductThird Party Advisory
https://www.npmjs.com/package/pug-code-gen

CVSS

Attack Vector
NETWORK
Complexity
HIGH
Privileges
NONE
User Interaction
NONE
Scope
CHANGED
Confidentiality
HIGH
Integrity
HIGH
Availability
HIGH
Vector?

Quick Info

StatusANALYZED
CWE
CWE-74CWE-94

Get alerted

Stop reading CVE feeds looking for your own stack

Track the products you run and VulnTracker tells you when a new CVE affects them — with what is known about fixing it, and nothing about the rest.

Free plan, no card