Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #106522

Re: Untrusted code execution

Path csiph.com!fu-berlin.de!uni-berlin.de!not-for-mail
From Ian Kelly <ian.g.kelly@gmail.com>
Newsgroups comp.lang.python
Subject Re: Untrusted code execution
Date Tue, 5 Apr 2016 08:50:16 -0600
Lines 27
Message-ID <mailman.71.1459867858.32530.python-list@python.org> (permalink)
References <slrnng31v9.19u.jon+usenet@wintry.unequivocal.co.uk> <slrnng7gj4.19u.jon+usenet@wintry.unequivocal.co.uk> <58de161a-ecdb-4ada-aab5-871876ea1574@googlegroups.com> <CALwzidk3-Cd0mhKUUMn2GJVCZ5-0eNEbfoVHMQVgkuXFfKVhgg@mail.gmail.com>
Mime-Version 1.0
Content-Type text/plain; charset=UTF-8
X-Trace news.uni-berlin.de 5FOHI4Pnq1CxAPo/YTWbPACmd4eT8s3FuANRmwyv6S9g==
Return-Path <ian.g.kelly@gmail.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.011
X-Spam-Evidence '*H*': 0.98; '*S*': 0.00; 'subject:code': 0.07; 'api': 0.09; 'ast': 0.09; 'namespace': 0.09; 'str,': 0.09; 'python': 0.10; '2016': 0.16; 'all?': 0.16; 'received:io': 0.16; 'received:psf.io': 0.16; 'wrote:': 0.16; 'else,': 0.18; 'thoughts': 0.18; 'tree': 0.18; 'issue.': 0.20; '"",': 0.22; 'int,': 0.22; 'am,': 0.23; 'code.': 0.23; 'header:In-Reply-To:1': 0.24; 'figure': 0.27; 'message-id:@mail.gmail.com': 0.27; 'said,': 0.27; 'idea': 0.28; 'values': 0.28; 'looks': 0.29; 'clever': 0.29; 'node': 0.29; 'raise': 0.29; "i'm": 0.30; 'work.': 0.30; 'code': 0.30; "i'd": 0.31; 'plans': 0.32; 'tue,': 0.34; 'received:google.com': 0.35; 'could': 0.35; 'execution': 0.35; 'but': 0.36; 'there': 0.36; 'received:209.85': 0.36; 'skip:{ 10': 0.36; 'to:addr:python-list': 0.36; 'subject:: ': 0.37; 'say': 0.37; 'received:209.85.213': 0.37; 'thought': 0.37; 'front': 0.38; 'received:209': 0.38; 'anything': 0.38; 'skip:p 20': 0.38; 'enough': 0.39; 'to:addr:python.org': 0.40; 'more': 0.63; 'dont': 0.64; 'apart': 0.70; '3.4': 0.84; 'experiment': 0.84; 'to:name:python': 0.84; 'utc+5:30,': 0.84
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to; bh=5CWV3jUQa1UxrzZAMMCbr9ZzGrST5atja4/ggyyA/t8=; b=Qnx0sjTACvZNWVcHeNBYOJi+RgQLTtUSXbDB86WxNJFZGSN9GIoqMggE6iHjbYXMdo 8GIABwWjlIHoT/Me6pNmtakOcyH7BbQTzfLHURecp5xGlvWG41QdrQWa4gISJTqtynHX u4v+qXFRm8lNm5msMRBMxcGgx6jBS1NobheBri9CW00Vjn4FP/UXuADDaaoV83j5LfC2 I+o0D9VDSAYagNpx6tz/qGifX4qfzDahyI8aQChjzCkwEOK/l6Q/jBtybU1ljwA9TH9s iMgvn2Zt3kbSl+LKjc/WTPKGoHAJvyiPhJBsq+8LbwyinyzLB3Sxf/VLlLMLbHxNH23q 7ikw==
X-Google-DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to; bh=5CWV3jUQa1UxrzZAMMCbr9ZzGrST5atja4/ggyyA/t8=; b=kbXTOzKjHZICKuN8/6hObZuvZYW7sdcNgLK/8jCWnxAwTczKAY0fgVg6zkDAcFw5YF P0K/9ecxRnhhvgNmDOXE3InST5qmtbXOSAzWiR9HCqvhUADyj76DRYyDPY6yogsnRF0q ezn9Vuz3s+g5vQLcz0D+0xEtsFKiQGb/n8ZXgpklUtJb81PJq2Em8D/8vTq8J5fXi2E2 F3SBgZTuxQgTby9Xv9RW+uWNebJ/WK97i/A+L+bGQ5FOBAn/htz3b/Hr9Q47Gk89vyAP b4EwYDKdVTRYddGza0EKq95D5mjAv1gGIS89qEX+OnjdMMLG0cS8+IkTz2Aweuwfny3I +tIA==
X-Gm-Message-State AD7BkJL4JU+T143p5NQDGkVeCN1I3A+ymtKRNDwASZUHlJ9bTq39fAtNtDzwlNaBmbI/utRbycvWT/pMEoPdbg==
X-Received by 10.50.112.10 with SMTP id im10mr17374096igb.93.1459867855959; Tue, 05 Apr 2016 07:50:55 -0700 (PDT)
In-Reply-To <58de161a-ecdb-4ada-aab5-871876ea1574@googlegroups.com>
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.21
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
X-Mailman-Original-Message-ID <CALwzidk3-Cd0mhKUUMn2GJVCZ5-0eNEbfoVHMQVgkuXFfKVhgg@mail.gmail.com>
X-Mailman-Original-References <slrnng31v9.19u.jon+usenet@wintry.unequivocal.co.uk> <slrnng7gj4.19u.jon+usenet@wintry.unequivocal.co.uk> <58de161a-ecdb-4ada-aab5-871876ea1574@googlegroups.com>
Xref csiph.com comp.lang.python:106522

Show key headers only | View raw


On Tue, Apr 5, 2016 at 8:17 AM, Rustom Mody <rustompmody@gmail.com> wrote:
> On Tuesday, April 5, 2016 at 7:19:39 PM UTC+5:30, Jon Ribbens wrote:
>> On 2016-04-03, Jon Ribbens wrote:
>> > I'd just like to say up front that this is more of a thought experiment
>> > than anything else, I don't have any plans to use this idea on any
>> > genuinely untrusted code. Apart from anything else, there's the
>> > denial-of-service issue.
>> >
>> > That said, is there any way that the following Python 3.4 code could
>> > result in a arbitrary code execution security hole?
>> >
>> >     tree = compile(untrusted_code, "<script>", "eval", ast.PyCF_ONLY_AST)
>> >     for node in ast.walk(tree):
>> >         if (isinstance(node, ast.Name) and node.id.startswith("_") or
>> >             isinstance(node, ast.Attribute) and node.attr.startswith("_")):
>> >                 raise ValueError("Access to private values is not allowed.")
>> >     namespace = {"__builtins__": {"int": int, "str": str, "len": len}}
>> >     print(eval(compile(tree, "<script>", "eval"), namespace))
>>
>> Nobody has any thoughts on this at all?
>
> i actually did...
>
> But dont know enough of the AST API to figure out what you are trying/avoiding etc

Same here, although it looks to me like this approach could work. Or
I'm just not clever enough to see how it could be exploited.

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

Untrusted code execution Jon Ribbens <jon+usenet@unequivocal.co.uk> - 2016-04-03 21:12 +0000
  Re: Untrusted code execution Jon Ribbens <jon+usenet@unequivocal.co.uk> - 2016-04-05 13:46 +0000
    Re: Untrusted code execution Rustom Mody <rustompmody@gmail.com> - 2016-04-05 07:17 -0700
      Re: Untrusted code execution Ian Kelly <ian.g.kelly@gmail.com> - 2016-04-05 08:50 -0600
      Re: Untrusted code execution Jon Ribbens <jon+usenet@unequivocal.co.uk> - 2016-04-05 17:26 +0000
        Re: Untrusted code execution Jon Ribbens <jon+usenet@unequivocal.co.uk> - 2016-04-05 18:50 +0000
          Re: Untrusted code execution Jon Ribbens <jon+usenet@unequivocal.co.uk> - 2016-04-05 19:14 +0000
        Re: Untrusted code execution Jon Ribbens <jon+usenet@unequivocal.co.uk> - 2016-04-05 19:13 +0000
        Re: Untrusted code execution Steven D'Aprano <steve@pearwood.info> - 2016-04-06 11:43 +1000
          Re: Untrusted code execution Random832 <random832@fastmail.com> - 2016-04-06 09:14 -0400
            Re: Untrusted code execution Steven D'Aprano <steve@pearwood.info> - 2016-04-07 11:45 +1000
              Re: Untrusted code execution Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2016-04-07 14:48 +1000
              Re: Untrusted code execution Jon Ribbens <jon+usenet@unequivocal.co.uk> - 2016-04-07 15:18 +0000
                Re: Untrusted code execution Steven D'Aprano <steve@pearwood.info> - 2016-04-08 15:28 +1000
          Re: Untrusted code execution Jon Ribbens <jon+usenet@unequivocal.co.uk> - 2016-04-07 12:13 +0000
            Re: Untrusted code execution Jon Ribbens <jon+usenet@unequivocal.co.uk> - 2016-04-07 14:25 +0000
              Re: Untrusted code execution Steven D'Aprano <steve@pearwood.info> - 2016-04-08 15:26 +1000
            Re: Untrusted code execution Jon Ribbens <jon+usenet@unequivocal.co.uk> - 2016-04-07 17:20 +0000
              Re: Untrusted code execution Jon Ribbens <jon+usenet@unequivocal.co.uk> - 2016-04-07 17:35 +0000
              Re: Untrusted code execution Jon Ribbens <jon+usenet@unequivocal.co.uk> - 2016-04-10 17:06 +0000
      Re: Untrusted code execution Jon Ribbens <jon+usenet@unequivocal.co.uk> - 2016-04-05 17:40 +0000
    Re: Untrusted code execution Paul Rubin <no.email@nospam.invalid> - 2016-04-05 13:39 -0700
      Re: Untrusted code execution Jon Ribbens <jon+usenet@unequivocal.co.uk> - 2016-04-05 21:13 +0000
        Re: Untrusted code execution Paul Rubin <no.email@nospam.invalid> - 2016-04-07 00:08 -0700
          Re: Untrusted code execution Lele Gaifax <lele@metapensiero.it> - 2016-04-08 10:10 +0200

csiph-web