Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Yes, they can be maliciously exploited.</p> <p>If you really want safe sandboxing, you could look at <a href="http://codespeak.net/pypy/dist/pypy/doc/sandbox.html" rel="nofollow">PyPy's sandboxing features</a>, but be aware that sandboxing is not easy, and there may be better ways to accomplish whatever you are seeking.</p> <h2>Correction</h2> <p>Since you've updated your question to clarify that you're only parsing the untrusted input to AST, there is no need to sandbox anything: sandboxing is specifically about <em>executing</em> untrusted code (which most people probably assumed your goal was, by asking about sandboxing).</p> <p>Using <code>compile</code> / <code>compiler</code> only for parsing this way should be safe: Python source parsing does not have any hooks into code execution. (Note that this is not necessarily true of all languages: for example, Perl cannot be (completely) parsed without code execution.)</p> <p>The only other remaining risk is that someone may be able to craft some pathological Python source code that makes one of the parsers use runaway amounts of memory / processor time, but resource exhaustion attacks affect everything, so you'll just want to manage this as it becomes necessary. (For example, if your deployment is mission-critical and cannot afford a denial of service by an attacker armed with pathological source code, you can execute the parsing in a <a href="http://docs.python.org/library/resource.html" rel="nofollow">resource-limited</a> subprocess).</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload