ASTEVAL is an evaluator of Python expressions and statements. Prior to version 1.0.6, if an attacker can control the input to the asteval
library, they can bypass astevals restrictions and execute arbitrary Python code in the context of the application using the library. The vulnerability is rooted in how asteval
performs handling of FormattedValue
AST nodes. In particular, the on_formattedvalue
value uses the dangerous format method of the str class. The code allows an attacker to manipulate the value of the string used in the dangerous call fmt.format(__fstring__=val)
. This vulnerability can be exploited to access protected attributes by intentionally triggering an AttributeError
exception. The attacker can then catch the exception and use its obj
attribute to gain arbitrary access to sensitive or protected object properties. Version 1.0.6 fixes this issue.
The product uses a function that accepts a format string as an argument, but the format string originates from an external source.
Name | Vendor | Start Version | End Version |
---|---|---|---|
Python-asteval | Ubuntu | upstream | * |
When an attacker can modify an externally-controlled format string, this can lead to buffer overflows, denial of service, or data representation problems. It should be noted that in some circumstances, such as internationalization, the set of format strings is externally controlled by design. If the source of these format strings is trusted (e.g. only contained in library files that are only modifiable by the system administrator), then the external control might not itself pose a vulnerability.