CVE-2021-21353: pugjs pug Injection
Vulnerability summary
CVE-2021-21353 is a critical (CVSS 9.0) Injection vulnerability in pugjs pug. EPSS estimates a 4.30% chance of exploitation in the next 30 days, higher than 91% of scored vulnerabilities. 1 public exploit is recorded.
Advisory lineage
Upstream 0 · Downstream 0 · Related 9Timeline
- 03-03-2021PublishedVulnerability first disclosed.
- 16-04-2025Last modifiedVulnerability information updated.
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.
CVSS metrics
6 scores · 5 sources · 2 versions- CVE.orgCNA6.8MediumCVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:C/C:N/I:H/A:NDiffers
- OSV · WolfiEcosystem advisory · calculated9.0CriticalCVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:C/C:H/I:H/A:H
- OSV · NpmEcosystem advisory · calculated6.8MediumCVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:C/C:N/I:H/A:NDiffers
- OSV · ChainguardEcosystem advisory · calculated9.0CriticalCVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:C/C:H/I:H/A:H
EPSS trend
Probability
4.30%
Chance of exploitation in the next 30 days
Percentile
91%
Versus all other CVEs
30-day change
0.00 pp
From 4.30% on 19-09-2026
Known exploited
Compare KEV catalogsNot in any of the 3 tracked catalogs.
Public exploits
1 foundPug
Maturity: poc
Weaknesses
CWE · root cause- CWE-74Improper Neutralization of Special Elements in Output Used by a Downstream Component ('Injection')The product constructs all or part of a command, data structure, or record using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify how it is parsed or interpreted when it is sent to a downstream component.
- CWE-94Improper Control of Generation of Code ('Code Injection')The product constructs all or part of a code segment using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the syntax or behavior of the intended code segment.
Affected systems
Chainguard72 products
- code-serverAll versions (No fix recorded)
- code-server-compatAll versions (No fix recorded)
- commercial-gitlab-rails-ee-assets-19.1All versions (No fix recorded)
- commercial-gitlab-rails-ee-assets-19.2All versions (No fix recorded)
- commercial-gitlab-rails-ee-assets-19.3All versions (No fix recorded)
Npm2 products
- pug< 3.0.1
- pug-code-gen< 2.0.3 | ≥ 3.0.0, < 3.0.2
Pugjs2 products
- pug< 3.0.1
- pug-code-gen< 2.0.3 | ≥ 3.0.0, < 3.0.2
Wolfi2 products
- code-serverAll versions (No fix recorded)
- code-server-compatAll versions (No fix recorded)
4 vendors · 78 products
References
8 links- github.com/pugjs/pug/security/advisories/GHSA-p493-635q-r6grX Refsource CONFIRMAdvisoryWEBThird Party Advisory
- github.com/pugjs/pug/commit/991e78f7c4220b2f8da042877c6f0ef5a4683be0X Refsource MISCFIXWEBPatchThird Party Advisory
- github.com/pugjs/pug/releases/tag/pug%403.0.1X Refsource MISCAdvisoryWEBRelease NotesThird Party Advisory