Every CVE Search/ Get API key

CVE-2021-21353

Remote code execution in pug

6.8 MediumPublic exploitFix available

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.

Attack profile

How easy it is to exploit

Attack vector
Network
Complexity
High
Privileges needed
None
User interaction
None

What an attacker can affect

Confidentiality
None
Integrity
High
Availability
None

Exploit likelihood

4.27%Up 0.7 points since Apr 14, 2021
90%50%10%1%

What each source reports

CVE List Score used 6.8

Remote code execution in pug

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.

Record
CVE-2021-21353
CVSS 3.1
6.8 MediumCVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:C/C:N/I:H/A:N
Weakness
CWE-74
Updated
2026-11-02
EUVDEUVD-2021-0685 6.8

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.

Record
EUVD-2021-0685
CVSS 3.1
6.8 MediumCVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:C/C:N/I:H/A:N
Updated
2026-11-03
GitHub AdvisoriesGHSA-p493-635q-r6gr 6.8

Remote code execution via the `pretty` option.

Impact

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.

Patches

Upgrade to [email protected] or [email protected] or [email protected], which correctly sanitise the parameter.

Workarounds

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.

References

Original report: https://github.com/pugjs/pug/issues/3312

For more information

If you believe you have found other vulnerabilities, please DO NOT open an issue. Instead, you can follow the instructions in our Security Policy

Record
GHSA-p493-635q-r6gr
CVSS 3.1
6.8 MediumCVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:C/C:N/I:H/A:N
Weakness
CWE-74, CWE-94
Updated
2026-11-02
NVD 6.8

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.

Record
CVE-2021-21353
CVSS 3.1
6.8 MediumCVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:C/C:N/I:H/A:N
CVSS 3.1
9.0 CriticalCVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:C/C:H/I:H/A:H
CVSS 2.0
6.8 MediumAV:N/AC:M/Au:N/C:P/I:P/A:P
Weakness
CWE-74, CWE-94
Updated
2026-11-02
OSV 9.0

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.

Record
CVE-2021-21353
CVSS 3.1
9.0 CriticalCVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:C/C:H/I:H/A:H
Updated
2026-11-04
OSVGHSA-p493-635q-r6gr 6.8

Remote code execution via the `pretty` option.

Impact

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.

Patches

Upgrade to [email protected] or [email protected] or [email protected], which correctly sanitise the parameter.

Workarounds

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.

References

Original report: https://github.com/pugjs/pug/issues/3312

For more information

If you believe you have found other vulnerabilities, please DO NOT open an issue. Instead, you can follow the instructions in our Security Policy

Record
GHSA-p493-635q-r6gr
CVSS 3.1
6.8 MediumCVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:C/C:N/I:H/A:N
Weakness
CWE-74, CWE-94
Updated
2026-11-02
OSVCLSA-2026-1777250300 No score

TuxCare security update for pug (2 CVEs)

TuxCare rebuilt pug to address 2 CVEs. Fixed in 2.0.4-tuxcare.4.

Record
CLSA-2026-1777250300
Updated
2026-11-02
OSVROOT-APP-NPM-CVE-2021-21353 No score

CVE-2021-21353 in pug - Patched by Root

Root has patched CVE-2021-21353 in the pug package for Root:npm. Multiple fixed versions available.

Record
ROOT-APP-NPM-CVE-2021-21353
Updated
2026-11-02

Affected products

Affected packages

Affected packages
PackageAffectedFixed
pug
npm
before 3.0.1
3.0.1
pug-code-gen
npm
before 2.0.3
2.0.3
pug-code-gen
npm
3.0.0 up to 3.0.2
3.0.2
pug
TuxCare:npm
From an advisory covering 2 CVEs
2.0.4-tuxcare.0 up to 2.0.4-tuxcare.4, plus listed versions
2.0.42.0.4-tuxcare.12.0.4-tuxcare.22.0.4-tuxcare.3
2.0.4-tuxcare.4
pug
Root:npm
before 2.0.4-aikido.2
2.0.4-aikido.2
pug-code-gen
Root:npm
before 2.0.2-aikido.1
2.0.2-aikido.1
@rootio/pug
Root:npm
before 2.0.4-root.io.2
2.0.4-root.io.2
@rootio/pug-code-gen
Root:npm
before 2.0.2-root.io.1
2.0.2-root.io.1

Public exploits

Links only. Every CVE stores no exploit code.

Public exploits
SourceLinkDate
PoC in GitHubjinsu9758/PUG-RCE-CVE-2021-21353-POC2025-03-29

History

History
RecordedChangedSources
affected
factsOSV
aliasesEUVD
first indexedCVE List, GitHub Advisories, NVD, OSV, PoC in GitHub

Dates are when Every CVE recorded each change. Upstream dates may differ.

In short

CVE-2021-21353 is a medium vulnerability (CVSS 6.8) in Pugjs Pug, published March 3, 2021. Public exploit code exists. EPSS puts the chance of exploitation in the next 30 days at 4.27%, the 91st percentile. Fixed in pug 3.0.1.

References

MoveEnter Open