{"id":"CVE-2021-21353","published":"2021-03-03T01:50:18Z","modified":"2026-11-02T17:59:55Z","title":"Remote code execution in pug","vendor":"pugjs","product":"pug","tier":"tail","description":{"text":"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.","provenance":"source","from":"CVE.org"},"cvss":{"score":6.8,"severity":"MEDIUM","version":"3.1","vector":"CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:C/C:N/I:H/A:N","provenance":"source","from":"CVE.org CNA"},"epss":{"score":0.04269,"percentile":0.91316,"provenance":"source"},"cwes":[{"id":"CWE-74","name":"Improper Neutralization of Special Elements in Output Used by a Downstream Component"}],"references":[{"url":"https://github.com/pugjs/pug/security/advisories/GHSA-p493-635q-r6gr","tags":["x_refsource_CONFIRM"]},{"url":"https://github.com/pugjs/pug/issues/3312","tags":["x_refsource_MISC"]},{"url":"https://github.com/pugjs/pug/pull/3314","tags":["x_refsource_MISC"]},{"url":"https://github.com/pugjs/pug/commit/991e78f7c4220b2f8da042877c6f0ef5a4683be0","tags":["x_refsource_MISC"]},{"url":"https://github.com/pugjs/pug/releases/tag/pug%403.0.1","tags":["x_refsource_MISC"]},{"url":"https://www.npmjs.com/package/pug","tags":["x_refsource_MISC"]},{"url":"https://www.npmjs.com/package/pug-code-gen","tags":["x_refsource_MISC"]}],"priority":{"score":28.0,"factors":[{"name":"EPSS percentile","points":18.26},{"name":"Public exploit code","points":5.0},{"name":"CVSS severity","points":4.76}]},"exploitSources":{"pocGithub":{"count":1,"skipped":0,"earliest":"2025-03-29","earliestUrl":"https://github.com/jinsu9758/PUG-RCE-CVE-2021-21353-POC","repos":[{"name":"jinsu9758/PUG-RCE-CVE-2021-21353-POC","url":"https://github.com/jinsu9758/PUG-RCE-CVE-2021-21353-POC","stars":2,"created":"2025-03-29"}]},"first":{"date":"2025-03-29","source":"PoC-in-GitHub","url":"https://github.com/jinsu9758/PUG-RCE-CVE-2021-21353-POC"},"provenance":"source"},"vendorSlug":"pugjs","affectedVersions":[{"vendor":"pugjs","product":"pug","versions":["< 3.0.1"]}],"ssvc":{"exploitation":"none","automatable":"no","technicalImpact":"total","timestamp":"2026-11-02T17:59:45.476555Z","from":"CISA ADP","provenance":"source"},"affected":[{"ecosystem":"npm","package":"pug","vulnerableRanges":["<3.0.1"],"patched":["3.0.1"],"from":["GHSA-p493-635q-r6gr"],"provenance":"source"},{"ecosystem":"npm","package":"pug-code-gen","vulnerableRanges":["<2.0.3",">=3.0.0, <3.0.2"],"patched":["2.0.3","3.0.2"],"from":["GHSA-p493-635q-r6gr"],"provenance":"source"}],"summary":{"text":"The pug npm package, a Node.js template engine, contains a code injection flaw in its compiler, in the handling of the pretty option, which is also present in the pug-code-gen component. An attacker who can control the pretty option, for example by passing user-supplied objects such as request query parameters into template inputs, can execute code on the Node.js backend remotely, provided the application does not compile templates in advance so that untrusted input never reaches that option.","provenance":"ai","model":"claude-haiku-5-5","generatedAt":"2026-11-21T04:19:11Z"},"euvd":{"id":"EUVD-2021-0685","exploited":false,"provenance":"source"},"lineage":{"familyId":"fam-pugjs-pug-cve-2021-21353","children":[{"from":"CVE-2021-21353","to":"CVE-2024-36361","relation":"related","confidence":"medium","kind":"lineage","evidence":[{"kind":"same-code","provenance":"machine","files":["packages/pug-code-gen/index.js"],"commits":["https://github.com/pugjs/pug/commit/991e78f7c4220b2f8da042877c6f0ef5a4683be0","https://github.com/pugjs/pug/commit/32acfe8f197dc44c54e8af32c7d7b19aa9d350fb"],"basis":"shared function","functions":["Compiler"]}]}]}}