Vulnerabilities in pkg:npm/pug-code-gen
PACKAGECVE-2024-36361 is a MODERATE (CVSS 6.8) pug allows javascript code execution vulnerability (CWE-94: Improper Control of Generation of Code ('Code Injection')) affecting Pug code gen libraries in the npm ecosystem. The issue involves pug allows javascript code execution if an application accepts untrusted input. Remediation is available by upgrading affected packages to version 3.0.3.
pkg:npm/pug-code-gen
Vulnerability advisories affecting package pkg:npm/pug-code-gen. Select an advisory below to view technical details or fixes.
| Advisory ID | CVE / NVD | Severity | Summary |
|---|---|---|---|
| GHSA-3965-hpx2-q597 | CVE-2024-36361 | MODERATE | Pug allows JavaScript code execution if an application accepts untrusted input |
| GHSA-p493-635q-r6gr | CVE-2021-21353 | MODERATE | Remote code execution via the `pretty` option. |
CVE-2024-36361 at a Glance
Security Impact
CVSS: 6.8
The security impact metrics below are parsed directly from the CVSS v3.1 vector string (CVSS:3.1/AV:N/AC:H/PR:N/UI:R/S:U/C:H/I:H/A:N).
How to Fix CVE-2024-36361
To remediate this vulnerability, upgrade all affected Pug code gen dependencies to a patched release. Both direct and transitive dependencies should be checked, as frameworks or security libraries may pull in vulnerable versions transitively.
npm install pug-code-gen@3.0.3
npm install pug@3.0.3
Run the following command in your project directory to verify that all resolved dependencies use the patched release:
npm ls pug-code-gen
How to Check if You Are Affected
To determine whether your Node.js application is affected by CVE-2024-36361, inspect your project dependencies using npm:
npm ls pug-code-gen
Analyze the terminal output to locate any version of Pug code gen in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than 3.0.3), your application is affected.
Note: The npm ls pug-code-gen command inspects dependencies declared in your package.json and lockfile; it does not perform automated runtime dynamic scanning.
Technical Details
Vulnerability Mechanism & Technical Analysis
This vulnerability is classified under CWE-94: Improper Control of Generation of Code ('Code Injection'), where the product constructs all or part of a code segment using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the syntax or behavior of the intended code segment. In Pug code gen, software state validation or input boundaries are circumvented during processing. Review the official source advisory statement below for specific affected components, classes, and reproduction details.
Source Advisory Statement
CVE-2024-36361 Affected Pug code gen Versions
2 component(s)| Product / Package | Ecosystem | Affected Versions | Fixed Version |
|---|---|---|---|
|
pug-code-gen
|
npm |
< 3.0.3
|
3.0.3
|
|
pug
|
npm |
< 3.0.3
|
3.0.3
|
References
Frequently Asked Questions
What is CVE-2024-36361?
Which Pug code gen versions are affected?
What version fixes CVE-2024-36361?
Is pug-code-gen affected?
Is pug affected?
What is the CVSS score of CVE-2024-36361?
What CWE is associated with CVE-2024-36361?
How can I check npm dependencies for CVE-2024-36361?
Machine-readable OSV JSON
OSV v1.5 Schema
{
"schema_version" : "1.4.0",
"id" : "GHSA-3965-hpx2-q597",
"modified" : "2025-04-28T14:20:50Z",
"published" : "2024-05-24T14:45:02Z",
"aliases" : [ "CVE-2024-36361" ],
"summary" : "Pug allows JavaScript code execution if an application accepts untrusted input",
"details" : "Pug through 3.0.2 allows JavaScript code execution if an application accepts untrusted input for the name option of the `compileClient`, `compileFileClient`, or `compileClientWithDependenciesTracked` function. NOTE: these functions are for compiling Pug templates into JavaScript, and there would typically be no reason to allow untrusted callers.",
"severity" : [ {
"type" : "CVSS_V3",
"score" : "CVSS:3.1/AV:N/AC:H/PR:N/UI:R/S:U/C:H/I:H/A:N"
} ],
"affected" : [ {
"package" : {
"ecosystem" : "npm",
"name" : "pug-code-gen"
},
"ranges" : [ {
"type" : "ECOSYSTEM",
"events" : [ {
"introduced" : "0"
}, {
"fixed" : "3.0.3"
} ]
} ],
"database_specific" : {
"last_known_affected_version_range" : "<= 3.0.2"
}
}, {
"package" : {
"ecosystem" : "npm",
"name" : "pug"
},
"ranges" : [ {
"type" : "ECOSYSTEM",
"events" : [ {
"introduced" : "0"
}, {
"fixed" : "3.0.3"
} ]
} ],
"database_specific" : {
"last_known_affected_version_range" : "<= 3.0.2"
}
} ],
"references" : [ {
"type" : "ADVISORY",
"url" : "https://nvd.nist.gov/vuln/detail/CVE-2024-36361"
}, {
"type" : "WEB",
"url" : "https://github.com/pugjs/pug/pull/3428"
}, {
"type" : "WEB",
"url" : "https://github.com/pugjs/pug/pull/3438"
}, {
"type" : "WEB",
"url" : "https://github.com/pugjs/pug/commit/32acfe8f197dc44c54e8af32c7d7b19aa9d350fb"
}, {
"type" : "WEB",
"url" : "https://github.com/Coding-Competition-Team/hackac-2024/tree/main/web/pug"
}, {
"type" : "PACKAGE",
"url" : "https://github.com/pugjs/pug"
}, {
"type" : "WEB",
"url" : "https://github.com/pugjs/pug/blob/4767cafea0af3d3f935553df0f9a8a6e76d470c2/packages/pug/lib/index.js#L328"
}, {
"type" : "WEB",
"url" : "https://github.com/pugjs/pug/releases/tag/pug%403.0.3"
}, {
"type" : "WEB",
"url" : "https://pugjs.org/api/reference.html"
}, {
"type" : "WEB",
"url" : "https://www.npmjs.com/package/pug-code-gen"
} ],
"database_specific" : {
"cwe_ids" : [ "CWE-94" ],
"severity" : "MODERATE",
"github_reviewed" : true,
"github_reviewed_at" : "2024-05-24T14:45:02Z",
"nvd_published_at" : "2024-05-24T06:15:08Z"
}
}