Skip to content
Fencer Vulns
medium 6.8

CVE-2021-21353 json

Remote code execution in pug

published 2021-03-03 5 y ago modified 2026-11-02 6 d ago also GHSA-p493-635q-r6gr , EUVD-2021-0685

cvss
6.8
version 3.1, CNA
cisa kev
Not listed
not in CISA's catalog
epss
4.3%
EPSS 4.3% chance of exploitation in 30 days, percentile 91%
public exploits
0
none known

Summary

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.

Patch / fix

  • npm pug 3.0.1
  • npm pug-code-gen 2.0.3, 3.0.2
  • pugjs pug 3.0.1
  • pugjs pug-code-gen 2.0.3, 3.0.2

Vendor advisories

What the vendors themselves say about their products: affected, fixed or not affected, and what to do.

red hat product security vex CVE-2021-21353 updated cvss 9.0

pug: user provided objects as input to pug templates can achieve remote code execution

  • Red Hat Logging Subsystem for Red Hat OpenShift openshift-logging/kibana6-rhel8
    affected: no fix available

Red Hat CSAF VEX © Red Hat, Inc., from https://security.access.redhat.com/data/csaf/v2/vex/; changed: reduced to product statuses and remediations. CC BY 4.0 · csaf

CISA SSVC

Exploitation
none
Automatable
no
Technical impact
total
Assessed
6 d ago

Exploit prediction

4.27% chance of exploitation in the next 30 days, higher than 91% of all scored CVEs (FIRST EPSS, 2026-11-08).

Exploits and checks

  • github.com https://github.com/pugjs/pug/issues/3312 referenced PoC, tagged "exploit" by a source, unverified

CVSS scores

assigned by version score vector
CNA 3.1 6.8 CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:C/C:N/I:H/A:N
NVD 3.1 9.0 CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:C/C:H/I:H/A:H
NVD 2.0 6.8 AV:N/AC:M/Au:N/C:P/I:P/A:P
GitHub 3.1 6.8 CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:C/C:N/I:H/A:N

Affected packages

ecosystem package affected fixed in
npm pug
<3.0.1
3.0.1
npm pug-code-gen
<2.0.3
>=3.0.0, <3.0.2
2.0.3
3.0.2

Affected products

  • pugjs pug

Classification

Weakness
  • CWE-74 Improper Neutralization of Special Elements in Output Used by a Downstream Component
  • CWE-94 Improper Control of Generation of Code

References

Sources

Fencer Vulns keeps one entry per vulnerability: the CVE id wins, then GHSA, and records that alias each other are merged, except that two CVEs always keep separate entries. The same data is available as JSON.