Skip to content

Commit 45c726f

Browse files
wiredfoolradarhere
authored andcommitted
Don't allow __ or builtins in env dictionarys for ImageMath.eval
1 parent c3af264 commit 45c726f

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

src/PIL/ImageMath.py

+4
Original file line numberDiff line numberDiff line change
@@ -237,6 +237,10 @@ def eval(expression, _dict={}, **kw):
237237
args.update(_dict)
238238
args.update(kw)
239239
for k, v in args.items():
240+
if '__' in k or hasattr(__builtins__, k):
241+
msg = f"'{k}' not allowed"
242+
raise ValueError(msg)
243+
240244
if hasattr(v, "im"):
241245
args[k] = _Operand(v)
242246

0 commit comments

Comments
 (0)