CVE-2021-21353

MEDIUM

pug < 3.0.1 - Remote Code Execution via Pretty Option Injection

Title source: llm
STIX 2.1

Exploitation Summary

EIP tracks 1 public exploit for CVE-2021-21353. PoCs published by jinsu9758.

AI-analyzed exploit summary This repository contains a functional exploit PoC for CVE-2021-21353, a remote code execution vulnerability in PugJS. The exploit leverages template injection via the 'pretty' query parameter to execute arbitrary JavaScript code on the server.

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.

Exploits (1)

nomisec WORKING POC 2 stars
by jinsu9758 · poc
https://github.com/jinsu9758/PUG-RCE-CVE-2021-21353-POC

This repository contains a functional exploit PoC for CVE-2021-21353, a remote code execution vulnerability in PugJS. The exploit leverages template injection via the 'pretty' query parameter to execute arbitrary JavaScript code on the server.

Classification
Working Poc 95%
Attack Type
Rce
Complexity
Trivial
Reliability
Reliable
Target: PugJS (pug <= 3.0.0, pug-code-gen < 3.0.2)
No auth needed
Prerequisites: Vulnerable PugJS version · Exposed Express.js application using Pug templates
devstral-2 · analyzed Feb 18, 2026 Full analysis →

References (7)

Core 7
Core References
Exploit, Patch, Third Party Advisory x_refsource_misc
https://github.com/pugjs/pug/issues/3312
Patch, Third Party Advisory x_refsource_misc
https://github.com/pugjs/pug/pull/3314
Release Notes, Third Party Advisory x_refsource_misc
https://github.com/pugjs/pug/releases/tag/pug%403.0.1
Product, Third Party Advisory x_refsource_misc
https://www.npmjs.com/package/pug
Product, Third Party Advisory x_refsource_misc
https://www.npmjs.com/package/pug-code-gen

Scores

CVSS v3 6.8
EPSS 0.0176
EPSS Percentile 83.1%
Attack Vector NETWORK
CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:C/C:N/I:H/A:N

Details

CWE
CWE-74 CWE-94
Status published
Products (4)
npm/pug 0 - 3.0.1npm
npm/pug-code-gen 0 - 2.0.3npm
pugjs/pug < 3.0.1
pugjs/pug-code-gen < 2.0.3
Published Mar 03, 2021
Tracked Since Feb 18, 2026