---
id: CVE-2021-21353
title: Remote code execution in pug
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 quer…
severity: medium
cvss: 6.8
cvssVector: 'CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:C/C:N/I:H/A:N'
cvssSource: cna
cwe:
  - CWE-74
vendor: pugjs
product: pug
affected:
  - pug < 3.0.1
ssvc:
  exploitation: none
  automatable: 'no'
  technicalImpact: total
  timestamp: '2026-11-02T17:59:45.476555Z'
exploitAvailable: true
published: '2021-03-03'
updated: '2026-11-02'
sourceUpdated: '2026-11-02T17:59:55.421Z'
source: CVEORG
sourceUrl: 'https://www.cve.org/CVERecord?id=CVE-2021-21353'
references:
  - url: 'https://github.com/pugjs/pug/security/advisories/GHSA-p493-635q-r6gr'
    label: 'https://github.com/pugjs/pug/security/advisories/GHSA-p493-635q-r6gr'
  - url: 'https://github.com/pugjs/pug/issues/3312'
    label: 'https://github.com/pugjs/pug/issues/3312'
  - url: 'https://github.com/pugjs/pug/pull/3314'
    label: 'https://github.com/pugjs/pug/pull/3314'
  - url: >-
      https://github.com/pugjs/pug/commit/991e78f7c4220b2f8da042877c6f0ef5a4683be0
    label: >-
      https://github.com/pugjs/pug/commit/991e78f7c4220b2f8da042877c6f0ef5a4683be0
  - url: 'https://github.com/pugjs/pug/releases/tag/pug%403.0.1'
    label: 'https://github.com/pugjs/pug/releases/tag/pug%403.0.1'
  - url: 'https://www.npmjs.com/package/pug'
    label: 'https://www.npmjs.com/package/pug'
  - url: 'https://www.npmjs.com/package/pug-code-gen'
    label: 'https://www.npmjs.com/package/pug-code-gen'
tags:
  - cve.org
  - exploit-available
epss: 0.04269
epssPercentile: 0.91117
exploits:
  github: 1
  githubRepos:
    - 'https://github.com/jinsu9758/PUG-RCE-CVE-2021-21353-POC'
  checkedAt: '2026-11-05T19:31:18.368Z'
ingestedAt: '2026-11-05T19:30:42.760Z'
---

## Overview

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.

## Affected

- `pug < 3.0.1`

## Remediation

Refer to the linked advisories for vendor-supplied fixes and affected version ranges.
