CyberSecBulletin

Improper Neutralization of Directives in Dynamically Evaluated Code

CWE-95

The product receives input from an upstream component, but it does not neutralize or incorrectly neutralizes code syntax before using the input in a dynamic evaluation call (e.g. eval).

We track 182 vulnerabilities of this type. 100% are rated high or critical, and the average CVSS score is 9.0. 4 have been exploited in real attacks.

How this weakness is prevented

  • Architecture and Design Implementation: If possible, refactor your code so that it does not need to use eval() at all.
  • Implementation: For Python programs, it is frequently encouraged to use the ast.literal_eval() function instead of eval, since it is intentionally designed to avoid executing code. However, an adversary could still cause excessive memory or stack consumption via deeply nested structures, so the python documentation discourages use of ast.literal_eval() on untrusted data.

Latest Improper Neutralization of Directives in Dynamically Evaluated Code vulnerabilities