Skip to main content
Public proof of conceptFix available

CVE-2021-21353

Remote code execution in pug

A public proof of concept exists; no exploitation attested.

  • Published2021-03-03
  • Fixed in3.0.2 · 2.0.3
  • WeaknessCWE-74 · CWE-94

Am I affected?

With a domain, we read the version its public headers and pages expose. A distribution build can carry the fix under an older number.

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.

Timeline

dates in UTC
  1. 2021-03-0301:50CVE publishedCNA
  2. 2021-03-0302:15CVE publishedNVD

Versions per branch

NVD · OSV
Pugjs pug-code-gen
BranchAffectedFixed in
3.0≥ 3.0.0, < 3.0.23.0.2
2.0< 2.0.32.0.3
Pugjs pug
BranchAffectedFixed in
3.0< 3.0.13.0.1

as publishedRanges as NVD and OSV publish them; a distribution’s build can be fixed under an older number.

Products declared by the CNA1 product

As GitHub_M, the CNA that assigned this CVE, declared them in the CVE record; versions as written.

  • pugjs pug
    Affected
    • = < 3.0.1no fix stated

Source: the CNA record (CVE Program), © The MITRE Corporation,CVE terms of useCVE recordupdated 2025-04-16

Distribution builds and vendor advisories

Packages from OSV.dev and products from the vendors' CSAF advisories.

version not verifiedVersions not verified: read as OSV.dev and the vendors publish them, not checked against each vendor's release list.

Packages

  • @rootio/pugRoot:npmall versions · fixed in 2.0.4-root.io.2
  • @rootio/pug-code-genRoot:npmall versions · fixed in 2.0.2-root.io.1
  • code-serverWolfiall versions · fixed in 0and 1 other package
  • code-serverChainguardall versions · fixed in 0and 61 other packages
  • commercial-gitlab-rails-ee-assets-19.1Chainguardall versions · no fixed version listedand 5 other packages
  • gitlab-rails-19.1MinimOSall versions · fixed in 0and 1 other package
  • pugTuxCare:npmfrom 2.0.4-tuxcare.0 · fixed in 2.0.4-tuxcare.4
  • pugRoot:npmall versions · fixed in 2.0.4-aikido.2

1 more package range on OSV.dev

Vendor advisories

  • CVE-2021-21353 Red Hat Product Security1 known affected

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

    openshift-logging/kibana6-rhel8 as a component of Logging Subsystem for Red Hat OpenShift

Full record on NVD

Fix

  1. Update Pugjs pug-code-gen to 3.0.2 · 2.0.3
  2. No fix available, says the vendor Red Hat Product Security CVE-2021-21353 · 1 productAffected

Advisories and patches

Detection

read 2026-11-01 01:02 UTC
Nuclei template
none so far
ProjectDiscovery
Exploit-DB
no entry
Exploit-DB
Proof of concept
Metasploit modules
none listed
Metasploit Framework

Sources

  • CISA-ADPSSVC decisionnone2026-11-02
  • CNACVSS 3.16.82025-04-16
  • NVDCVSS 3.19read 2026-11-02
  • NVDCVSS 2.06.8read 2026-11-02
  • CNAweakness (CWE)CWE-742025-04-16
  • NVDweakness (CWE)CWE-94read 2026-11-02
  • FIRST EPSSEPSS score4.5 %2026-12-03
  • PoC-in-GitHubproof of concept1known since 2026-11-01
  • OSVaffected packages—
  • GitHub AdvisoriesadvisoryModerate2021-03-03

Identifiers

Technical details

CVSS v3 vector
CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:C/C:H/I:H/A:H
Published
2021-03-03
Last modified
2026-11-02
NVD status
Analyzed
GitHub advisory
GHSA-p493-635q-r6gr

Frequently asked questions

What is CVE-2021-21353?

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.

Is CVE-2021-21353 actively exploited?

Active exploitation of CVE-2021-21353 has not been confirmed. Its EPSS score was 4.5% on 2026-12-03, the estimated probability of exploitation in the next 30 days.

What is the CVSS score for CVE-2021-21353?

CVE-2021-21353 has a CVSS v3 base score of 9 (Critical severity), with vector string CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:C/C:H/I:H/A:H.

Running pug-code-gen? Hear about its next vulnerability

Surveillance reads the versions in your stack — a domain, a lockfile or a list — checks each CVE against the ranges its sources publish, and alerts you when one you run is exploited or enters CISA KEV. A version it cannot read stays « version not verified ».

No credit card required · No monthly cap on website checks · 250 API requests/month

Sources for this record