CVE-2021-21353
Remote code execution in pug
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.
Fixes and workarounds
Fix
pug (npm): OSV reports a fixed version 3.0.1. Check the advisory for supported release branches.
Source: OSV GHSA-p493-635q-r6grFix
pug-code-gen (npm): OSV reports a fixed version 2.0.3. Check the advisory for supported release branches.
Source: OSV GHSA-p493-635q-r6grFix
pug-code-gen (npm): OSV reports a fixed version 3.0.2. Check the advisory for supported release branches.
Source: OSV GHSA-p493-635q-r6grAffected products and versions
| Product | Versions | Authority |
|---|---|---|
| pug pugjs |
< 3.0.1 (affected) | CNA: GitHub_M |
pugpug
npm |
≥ 0; < 3.0.1 (affected, semver); OSV events: introduced 0; fixed 3.0.1Source events (semver)
Other versions: unaffected |
OSV GHSA-p493-635q-r6gr |
pug-code-genpug-code-gen
npm |
≥ 0; < 2.0.3 (affected, semver); OSV events: introduced 0; fixed 2.0.3Source events (semver)
Other versions: unaffected |
OSV GHSA-p493-635q-r6gr |
pug-code-genpug-code-gen
npm |
≥ 3.0.0; < 3.0.2 (affected, semver); OSV events: introduced 3.0.0; fixed 3.0.2Source events (semver)
Other versions: unaffected |
OSV GHSA-p493-635q-r6gr |
Version ranges are source assertions. Check the vendor advisory and your installed configuration before determining exposure.
CVSS assessments
| Version / score | Vector | Authority |
|---|---|---|
| 3.1 / 6.8 medium |
CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:C/C:N/I:H/A:N | CNA: GitHub_M |
Exploit evidence
No exploit evidence in collected sources. This is not proof of no exploitation.
References
- https://github.com/pugjs/pug/security/advisories/GHSA-p493-635q-r6grCNA: GitHub_M · x_refsource_CONFIRM
- https://github.com/pugjs/pug/issues/3312CNA: GitHub_M · x_refsource_MISC
- https://github.com/pugjs/pug/pull/3314CNA: GitHub_M · x_refsource_MISC
- https://github.com/pugjs/pug/commit/991e78f7c4220b2f8da042877c6f0ef5a4683be0CNA: GitHub_M · x_refsource_MISC
- https://github.com/pugjs/pug/releases/tag/pug%403.0.1CNA: GitHub_M · x_refsource_MISC
- https://www.npmjs.com/package/pugCNA: GitHub_M · x_refsource_MISC
- https://www.npmjs.com/package/pug-code-genCNA: GitHub_M · x_refsource_MISC
- https://github.com/pugjs/pug/security/advisories/GHSA-p493-635q-r6grADP: CVE · x_refsource_CONFIRM, x_transferred
- https://github.com/pugjs/pug/issues/3312ADP: CVE · x_refsource_MISC, x_transferred
- https://github.com/pugjs/pug/pull/3314ADP: CVE · x_refsource_MISC, x_transferred
- https://github.com/pugjs/pug/commit/991e78f7c4220b2f8da042877c6f0ef5a4683be0ADP: CVE · x_refsource_MISC, x_transferred
- https://github.com/pugjs/pug/releases/tag/pug%403.0.1ADP: CVE · x_refsource_MISC, x_transferred
- https://www.npmjs.com/package/pugADP: CVE · x_refsource_MISC, x_transferred
- https://www.npmjs.com/package/pug-code-genADP: CVE · x_refsource_MISC, x_transferred
- https://github.com/advisories/GHSA-p493-635q-r6grOSV / GitHub Security Advisories · advisory
- https://osv.dev/vulnerability/GHSA-p493-635q-r6grOSV / GitHub Security Advisories · osv
For agents and automation
Read public disclosures for free as Markdown or JSON. Compatible browsers also expose native WebMCP tools to search disclosures, read this page, and discover API access.
Use the ontology-linked Cyber API with x402 pay per request, or a Y2 Pro or Elite API key with the intel:cyber scope.
Endpoints and access details
https://api.y2.dev/api/v2/cyber/cveshttps://api.y2.dev/api/v2/cyber/cves/{cveId}
A workspace owner or admin can create a Pro or Elite API key. Send Authorization: Bearer <Y2_API_KEY> from your trusted agent runtime.
For x402, omit Authorization and read the HTTP 402 payment challenge before signing a retry. Public browser tools do not make payments.