这是 python eval() 的安全使用吗? [英] Is this a safe use of python eval()?
本文介绍了这是 python eval() 的安全使用吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如果攻击者可以控制attacker_controlled_nasty_variable
的值,这一段代码是否容易受到攻击?
If an attacker can control the value of attacker_controlled_nasty_variable
, is this segment of code vulnerable?
dic={"one":1,
"nasty":attacker_controlled_nasty_variable,
}
store=str(dict)
...
dic=eval(store)
推荐答案
使用 ast.literal_eval()
而不是 eval()
.
这篇关于这是 python eval() 的安全使用吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文