Remote code execution in pug
Summary
| CVE | CVE-2021-21353 |
|---|---|
| State | PUBLISHED |
| Assigner | GitHub_M |
| Source Priority | CVE Program / NVD first with legacy fallback |
| Published | 2021-03-03 02:15:13 UTC |
| Updated | 2026-11-02 18:18:32 UTC |
| 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. |
Risk And Classification
Primary CVSS: v3.1 9 CRITICAL from [email protected]
CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:C/C:H/I:H/A:H
Problem Types: CWE-74 | CWE-94 | CWE-74 CWE-74: Improper Neutralization of Special Elements in Output Used by a Downstream Component ('Injection')
| Version | Source | Type | Score | Severity | Vector |
|---|---|---|---|---|---|
| 3.1 | [email protected] | Primary | 9 | CRITICAL | CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:C/C:H/I:H/A:H |
| 3.1 | [email protected] | Secondary | 6.8 | MEDIUM | CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:C/C:N/I:H/A:N |
| 3.1 | CNA | DECLARED | 6.8 | MEDIUM | CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:C/C:N/I:H/A:N |
| 2.0 | [email protected] | Primary | 6.8 | AV:N/AC:M/Au:N/C:P/I:P/A:P |
CVSS v3.1 Breakdown
Attack Vector
NetworkAttack Complexity
HighPrivileges Required
NoneUser Interaction
NoneScope
ChangedConfidentiality
HighIntegrity
HighAvailability
HighCVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:C/C:H/I:H/A:H
CVSS v2.0 Breakdown
Access Vector
NetworkAccess Complexity
MediumAuthentication
NoneConfidentiality
PartialIntegrity
PartialAvailability
PartialAV:N/AC:M/Au:N/C:P/I:P/A:P
NVD Known Affected Configurations (CPE 2.3)
| Type | Vendor | Product | Version | Update | Edition | Language |
|---|---|---|---|---|---|---|
| Application | Pugjs | Pug | All | All | All | All |
| Application | Pugjs | Pug-code-gen | All | All | All | All |
Vendor Declared Affected Products
References
| Reference | Source | Link | Tags |
|---|---|---|---|
| fix: sanitise and escape the `pretty` option by ForbesLindesay · Pull Request #3314 · pugjs/pug · GitHub | af854a3a-2127-422b-91ae-364da2661108 | github.com | Patch, Third Party Advisory |
| Code injection vulnerability in visitMixin and visitMixinBlock through "pretty" option · Issue #3312 · pugjs/pug · GitHub | af854a3a-2127-422b-91ae-364da2661108 | github.com | Exploit, Patch, Third Party Advisory |
| Release [email protected] · pugjs/pug · GitHub | af854a3a-2127-422b-91ae-364da2661108 | github.com | Release Notes, Third Party Advisory |
| pug | af854a3a-2127-422b-91ae-364da2661108 | www.npmjs.com | Product, Third Party Advisory |
| pug-code-gen | af854a3a-2127-422b-91ae-364da2661108 | www.npmjs.com | Product, Third Party Advisory |
| fix: sanitise and escape the `pretty` option (#3314) · pugjs/pug@991e78f · GitHub | af854a3a-2127-422b-91ae-364da2661108 | github.com | Patch, Third Party Advisory |
| Remote code execution via the `pretty` option. · Advisory · pugjs/pug · GitHub | af854a3a-2127-422b-91ae-364da2661108 | github.com | Third Party Advisory |
| CVE Program record | CVE.ORG | www.cve.org | canonical |
| NVD vulnerability detail | NVD | nvd.nist.gov | canonical, analysis |
No vendor comments have been submitted for this CVE.
Legacy QID Mappings
- 982929 Nodejs (npm) Security Update for pug-code-gen (GHSA-p493-635q-r6gr)