eval or exec with user input enables remote code execution
criticalsecurityUpdated Mar 2, 2026(via Exa)
Technologies:
How to detect:
Code uses eval() or exec() functions with user-controlled input to implement dynamic behavior, allowing attackers to execute arbitrary Python code on the server.
Recommended action:
Never use eval or exec with user input. Replace with explicit mapping of allowed actions: ACTIONS = {"activate": lambda user: user.activate(), ...}; handler = ACTIONS.get(action). Use allow-list pattern for dynamic behavior. Validate and sanitize all input before processing.