Executing code provided by untrusted user using exec eval or ast.literal eval

suggest change

It is not possible to use eval or exec to execute code from an untrusted user securely. Even ast.literal_eval can fail on hostile input. It is sometimes possible to guard against malicious code execution, but that does not make eval or exec safe, and it does not rule out parser or tokenizer failures.

To evaluate code from an untrusted user you need to turn to some third-party module, or perhaps write your own parser and your own virtual machine in Python.

Feedback about page:

Feedback:
Optional: your email if you want me to get back to you:



Table Of Contents