An open API service providing security vulnerability metadata for many open source software ecosystems.

MDE2OlNlY3VyaXR5QWR2aXNvcnlHSFNBLXA0OTMtNjM1cS1yNmdy

Moderate EPSS: 0.04161% (0.8831 Percentile) EPSS:

Remote code execution via the `pretty` option.

Affected Packages Affected Versions Fixed Versions
npm:pug-code-gen
PURL: pkg:npm/pug-code-gen
>= 3.0.0, < 3.0.2, < 2.0.3 3.0.2, 2.0.3
52 Dependent packages
164,548 Dependent repositories
9,279,504 Downloads last month

Affected Version Ranges

All affected versions

0.0.0, 0.0.5, 0.0.6, 0.0.7, 1.0.0, 1.0.1, 1.1.0, 1.1.1, 2.0.0, 2.0.1, 2.0.2, 3.0.0, 3.0.0-canary-1, 3.0.0-canary-2, 3.0.1, 3.0.1-canary-3

All unaffected versions

2.0.3, 3.0.2, 3.0.3

npm:pug
PURL: pkg:npm/pug
< 3.0.1 3.0.1
5,864 Dependent packages
231,297 Dependent repositories
9,300,045 Downloads last month

Affected Version Ranges

All affected versions

0.0.0, 0.1.0, 2.0.0, 2.0.0-alpha1, 2.0.0-alpha2, 2.0.0-alpha3, 2.0.0-alpha4, 2.0.0-alpha5, 2.0.0-alpha6, 2.0.0-alpha7, 2.0.0-alpha8, 2.0.0-beta.12, 2.0.0-beta1, 2.0.0-beta2, 2.0.0-beta3, 2.0.0-beta4, 2.0.0-beta5, 2.0.0-beta6, 2.0.0-beta7, 2.0.0-beta8, 2.0.0-beta9, 2.0.0-beta10, 2.0.0-beta11, 2.0.0-rc.1, 2.0.0-rc.2, 2.0.0-rc.3, 2.0.0-rc.4, 2.0.1, 2.0.2, 2.0.3, 2.0.4, 3.0.0, 3.0.0-canary-1, 3.0.0-canary-2

All unaffected versions

3.0.1, 3.0.2, 3.0.3

Impact

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.

Patches

Upgrade to pug@3.0.1 or pug-code-gen@3.0.2 or pug-code-gen@2.0.3, which correctly sanitise the parameter.

Workarounds

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.

References

Original report: https://github.com/pugjs/pug/issues/3312

For more information

If you believe you have found other vulnerabilities, please DO NOT open an issue. Instead, you can follow the instructions in our Security Policy

References: