Skip to main content

Improper Control of Generation of Code ('Code Injection')

CVE-2021-21353

Severity High
Score 9/10

Summary

In the NPM package pug-code-gen, if a remote attacker was able to control the "pretty" option of the pug compiler, if you spread a user provided object such as the query parameters of a request into the pug-code-gen template inputs, it was possible for them to achieve Remote Code Execution on the node.js backend. This advisory is not exploitable if there is no way for untrusted input to be passed to pug-code-gen as the "pretty" option, if you compile templates in advance before applying user input to them, you do not need to upgrade. This issue affects versions of pug prior to 3.0.1, and pug-code-gen prior to 2.0.3, 3.0.0 prior to 3.0.2.

  • HIGH
  • NETWORK
  • HIGH
  • CHANGED
  • NONE
  • NONE
  • HIGH
  • HIGH

CWE-94 - Code Injection

Code injection is a type of vulnerability that allows an attacker to execute arbitrary code. This vulnerability fully compromises the machine and can cause a wide variety of security issues, such as unauthorized access to sensitive information, manipulation of data, denial of service attacks etc. Code injection is different from command injection in the fact that it is limited by the functionality of the injected language (e.g. PHP), as opposed to command injection, which leverages existing code to execute commands, usually within the context of a shell.

Advisory Timeline

  • Published