Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Security Fix for Arbitrary Code Execution - huntr.dev #1120

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions tensorlayer/files/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
import pickle
import re
import shutil
# import ast
import ast
import sys
import tarfile
import time
Expand Down Expand Up @@ -231,25 +231,25 @@ def eval_layer(layer_kwargs):
layer_type = args.pop('layer_type')
if layer_type == "normal":
generate_func(args)
return eval('tl.layers.' + layer_class)(**args)
return ast.literal_eval('tl.layers.' + layer_class)(**args)
elif layer_type == "layerlist":
ret_layer = []
layers = args["layers"]
for layer_graph in layers:
ret_layer.append(eval_layer(layer_graph))
args['layers'] = ret_layer
return eval('tl.layers.' + layer_class)(**args)
return ast.literal_eval('tl.layers.' + layer_class)(**args)
elif layer_type == "modellayer":
M = static_graph2net(args['model'])
args['model'] = M
return eval('tl.layers.' + layer_class)(**args)
return ast.literal_eval('tl.layers.' + layer_class)(**args)
elif layer_type == "keraslayer":
M = load_keras_model(args['fn'])
input_shape = args.pop('keras_input_shape')
_ = M(np.random.random(input_shape).astype(np.float32))
args['fn'] = M
args['fn_weights'] = M.trainable_variables
return eval('tl.layers.' + layer_class)(**args)
return ast.literal_eval('tl.layers.' + layer_class)(**args)
else:
raise RuntimeError("Unknown layer type.")

Expand Down