# CVE-2021-21353: Remote code execution in pug

- Severity: Medium 6.8 (CVSS:3.1, scored by GitHub_M) `CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:C/C:N/I:H/A:N`
- Known to be exploited: not in CISA's catalogue, which lists only what CISA has confirmed
- Likelihood of exploitation in the next 30 days (EPSS): 4.45%, higher than 91% of CVEs (2026-12-01)
- Public exploit code or proof of concept: one link below, marked "exploit"
- Published: 2021-03-03T01:50:18.000Z
- Modified: 2026-11-02T18:18:32.957Z
- Also known as: GHSA-p493-635q-r6gr
- Weaknesses: CWE-74, CWE-94
- SSVC (CISA-ADP): exploitation none, automatable no, technical impact total
- Assigned by: GitHub_M

## 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.

(As written by CVE List.)

## Affected

- pugjs pug: < 3.0.1; before 3.0.1
- pug (npm): before 3.0.1
- pug-code-gen (npm): before 2.0.3; from 3.0.0 before 3.0.2
- pugjs pug-code-gen: before 2.0.3; from 3.0.0 before 3.0.2

## Every score

- GitHub_M: CVSS:3.1 6.8 Medium `CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:C/C:N/I:H/A:N`
- GitHub: CVSS:3.1 6.8 Medium `CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:C/C:N/I:H/A:N`
- NVD: CVSS:3.1 9.0 Critical `CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:C/C:H/I:H/A:H`
- NVD: CVSS:2.0 6.8 Medium `AV:N/AC:M/Au:N/C:P/I:P/A:P`

## References

- <https://github.com/pugjs/pug/issues/3312> (exploit, patch, third-party-advisory, web)
- <https://github.com/pugjs/pug/security/advisories/GHSA-p493-635q-r6gr> (third-party-advisory, web)
- <https://github.com/pugjs/pug/pull/3314> (patch, third-party-advisory, web)
- <https://github.com/pugjs/pug/commit/991e78f7c4220b2f8da042877c6f0ef5a4683be0> (patch, third-party-advisory, web)
- <https://github.com/pugjs/pug/releases/tag/pug%403.0.1> (release-notes, third-party-advisory, web)
- <https://www.npmjs.com/package/pug> (product, third-party-advisory, web)
- <https://www.npmjs.com/package/pug-code-gen> (product, third-party-advisory, web)
- <https://nvd.nist.gov/vuln/detail/CVE-2021-21353> (advisory)

## Sources

- CVE List: [CVE-2021-21353](https://www.cve.org/CVERecord?id=CVE-2021-21353), CVE Terms of Use, modified 2026-11-02
- GitHub Advisory Database: [GHSA-p493-635q-r6gr](https://github.com/advisories/GHSA-p493-635q-r6gr), CC-BY-4.0, modified 2026-09-10
- NVD: [CVE-2021-21353](https://nvd.nist.gov/vuln/detail/CVE-2021-21353), Public domain, modified 2026-11-02

---

Page: https://cve.day/CVE-2021-21353 · Whole record: https://cve.day/CVE-2021-21353.json · Rebuilt by cve.day 2026-11-25T22:58:00.119Z
