Skip to content

Commit

Permalink
Don't allow __ or builtins in env dictionarys for ImageMath.eval
Browse files Browse the repository at this point in the history
  • Loading branch information
wiredfool authored and radarhere committed Dec 29, 2023
1 parent c3af264 commit 45c726f
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/PIL/ImageMath.py
Expand Up @@ -237,6 +237,10 @@ def eval(expression, _dict={}, **kw):
args.update(_dict)
args.update(kw)
for k, v in args.items():
if '__' in k or hasattr(__builtins__, k):
msg = f"'{k}' not allowed"
raise ValueError(msg)

if hasattr(v, "im"):
args[k] = _Operand(v)

Expand Down

0 comments on commit 45c726f

Please sign in to comment.