Python eval: is it still dangerous if I disable builtins and attribute access?

后端 未结 6 948
甜味超标
甜味超标 2020-12-02 12:38

We all know that eval is dangerous, even if you hide dangerous functions, because you can use Python\'s introspection features to dig down into things and re-extract them. F

6条回答
  •  独厮守ぢ
    2020-12-02 13:12

    I don't believe Python is designed to have any security against untrusted code. Here's an easy way to induce a segfault via stack overflow (on the C stack) in the official Python 2 interpreter:

    eval('()' * 98765)
    

    From my answer to the "Shortest code that returns SIGSEGV" Code Golf question.

提交回复
热议问题