Return-Path: X-Original-To: apmail-groovy-users-archive@minotaur.apache.org Delivered-To: apmail-groovy-users-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 4F4DB18A55 for ; Thu, 27 Aug 2015 05:52:39 +0000 (UTC) Received: (qmail 98405 invoked by uid 500); 27 Aug 2015 05:52:39 -0000 Delivered-To: apmail-groovy-users-archive@groovy.apache.org Received: (qmail 98366 invoked by uid 500); 27 Aug 2015 05:52:39 -0000 Mailing-List: contact users-help@groovy.incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: users@groovy.incubator.apache.org Delivered-To: mailing list users@groovy.incubator.apache.org Received: (qmail 98356 invoked by uid 99); 27 Aug 2015 05:52:39 -0000 Received: from Unknown (HELO spamd4-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 27 Aug 2015 05:52:39 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd4-us-west.apache.org (ASF Mail Server at spamd4-us-west.apache.org) with ESMTP id 943CDC0979 for ; Thu, 27 Aug 2015 05:52:38 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd4-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: 1.001 X-Spam-Level: * X-Spam-Status: No, score=1.001 tagged_above=-999 required=6.31 tests=[KAM_LAZY_DOMAIN_SECURITY=1, URIBL_BLOCKED=0.001] autolearn=disabled Received: from mx1-eu-west.apache.org ([10.40.0.8]) by localhost (spamd4-us-west.apache.org [10.40.0.11]) (amavisd-new, port 10024) with ESMTP id tLdiU-GsTj7k for ; Thu, 27 Aug 2015 05:52:26 +0000 (UTC) Received: from nskntmtas04p.mx.bigpond.com (nskntmtas04p.mx.bigpond.com [61.9.168.146]) by mx1-eu-west.apache.org (ASF Mail Server at mx1-eu-west.apache.org) with ESMTPS id BE5D325CD9 for ; Thu, 27 Aug 2015 05:52:25 +0000 (UTC) Received: from nskntcmgw08p ([61.9.169.168]) by nskntmtas04p.mx.bigpond.com with ESMTP id <20150827055216.ULOI17640.nskntmtas04p.mx.bigpond.com@nskntcmgw08p> for ; Thu, 27 Aug 2015 05:52:16 +0000 Received: from [127.0.0.1] ([101.183.141.110]) by nskntcmgw08p with BigPond Outbound id 9hsF1r01F2P6x1R01hsFUf; Thu, 27 Aug 2015 05:52:16 +0000 X-Authority-Analysis: v=2.0 cv=D6DF24tj c=1 sm=1 a=Uq/rMs9ARnPK5oUvht4vxQ==:17 a=v5IiRebxAAAA:8 a=AGkejYDSTmIA:10 a=S-fXuzkwAAAA:8 a=mV9VRH-2AAAA:8 a=mXMxpItyAAAA:8 a=NEAV23lmAAAA:8 a=_6GpL_ENAAAA:8 a=GrL9Ad6-JiyQSdtb6WEA:9 a=QEXdDO2ut3YA:10 a=KDBlCPimNscA:10 a=Uq/rMs9ARnPK5oUvht4vxQ==:117 Message-ID: <55DEA594.20008@asert.com.au> Date: Thu, 27 Aug 2015 15:52:20 +1000 From: Paul King User-Agent: Mozilla/5.0 (Windows NT 6.3; WOW64; rv:31.0) Gecko/20100101 Thunderbird/31.7.0 MIME-Version: 1.0 To: users@groovy.incubator.apache.org Subject: Re: Security feedback request: Setting system properties via configuration settings References: <55D2FA6F.9020001@asert.com.au> <5C676E6359909E478C7B811BDB48CA3540DEF1@CWWAPP478.windstream.com> In-Reply-To: <5C676E6359909E478C7B811BDB48CA3540DEF1@CWWAPP478.windstream.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit X-Antivirus: avast! (VPS 150826-3, 26/08/2015), Outbound message X-Antivirus-Status: Clean It isn't limited to scripts. Scripts are the main use case for @Grab but it will work with normal classes too. I am not sure non-script usage changes the risk profile. System.setProperty can be used in both scripts and classes as well. Where to perform the System.setProperty raises some interesting design decisions. In the initial PR I placed that within Grap.grab. This has the advantage that with a security manager in place you would have one spot to toggle whether setting those properties would be allowed. The disadvantage is that you couldn't easily discriminate between different groups of script/class, e.g. system scripts vs user-defined ones. Grape.grab is also called during compilation - which also sets the system properties - as would be required to actually compile the script. This does though need to be considered from a security point of view and I wasn't really considering the full impact of that previously, so I'm glad you raised the points. So it's easy enough to move setting the system properties into the class/script initializer. If done naively, there would be a change in behavior to above - where currently the system properties wouldn't be set if the global grape "kill-switch", 'groovy.grape.enable' was set to false. So, we'd need to wrap the property setting inside an appropriate check. That just leaves the question of whether to run setting those properties within the compiler or not. Obviously, such settings might be needed to enable the compilation process to succeed. If groovy was more like java with more obviously distinct compile and run steps, it would probably make sense to tease apart those concerns but since groovy scripts are often run in an all-in-one compile and then run process, there would certainly be a case for not forcing the user to enter such information twice. However, given the security concerns in question here, I am inclined to require that info twice for now and make the documentation clear on that aspect. Later, if we can find a safe way, we could streamline to remove the need for the duplicate info. I'll create a new PR in the coming days. Cheers, Paul. On 18/08/2015 10:33 PM, Winnebeck, Jason wrote: > Is this limited to scripts? Looking at the docs > http://docs.groovy-lang.org/latest/html/documentation/grape.html it > doesn't say it's strictly limited to the Script class with the main > method running the application, but I've never tried to use grapes > outside of this context. If @Grab works anywhere, it could be a risky > move. > > I would say the set property should occur with the security > privileges of annotated class, as if that class had > System.setProperty in its static constructor, if there is a > SecurityManager. I think this is important as one can run scripts as > embedded Groovy script engines, and this is a concern. I'm thinking > of GroovyShell's evaluate/run method. You wouldn't want > SecurityManager to block setProperty in such a script but NOT to > block it when used with @Grab. Also, even if there is not a > SecurityManager, it might be reasonable for an GroovyShell/class > loader option to block @Grab from calling setProperty, because in > these cases it would not be a good idea to modify global state when > not running a dedicated JVM for the script. > > That leads into a project I saw announced on this list, whose name I > cannot remember now, that was basically a Groovy script daemon to > eliminate the JVM startup time by shipping the scripts to the daemon > to run. Calling setProperty for SSL or proxy purposes in that daemon > would not work, much less not be safe. In this case that daemon > should be able to suppress Grape's setProperty, even if the script > might call other setProperty, and the daemon itself should control > proxy/SSL settings. > > Jason > > -----Original Message----- From: Paul King > [mailto:paulk@asert.com.au] Sent: Tuesday, August 18, 2015 5:27 AM > To: users@groovy.incubator.apache.org; > dev@groovy.incubator.apache.org; security@apache.org Subject: > Security feedback request: Setting system properties via > configuration settings > > > Hi folks, > > We are planning to add the ability to set system properties via the > @GrabConfig annotation[1]. This will allow scripts which use @Grab to > access an Ivy/Maven repo via a proxy (e.g. using system property > http.proxyHost) or specify a trust certificate store (using the > javax.net.ssl.keystore system property) or set other needed system > properties. This will use System.setProperty under the covers[2], so > a well-defined security mechanism is in place. > > We don't see this proposed feature as creating any additional > security risk since you could just as easily add such system > properties when invoking the JVM at the command-line or have > System.setProperty lines in your script - the only difference in the > latter case is the timing since @Grab does it's magic during class > initialization and adds the grabbed jars to the classpath if needed, > so the properties must be set before the script is run. > > While we don't believe this introduces any new risks, we thought we'd > ask for wider feedback and see if anyone else perceives any possible > security risk that we might not be aware of and allow us to modify > the proposed approach[2] if needed to mitigate any such risks. > > Cheers, Paul. [1] https://issues.apache.org/jira/browse/GROOVY-7548 > [2] https://github.com/apache/incubator-groovy/pull/83 > > --- This email has been checked for viruses by Avast antivirus > software. https://www.avast.com/antivirus > > > ---------------------------------------------------------------------- > > This email message and any attachments are for the sole use of the intended recipient(s). Any unauthorized review, use, disclosure or distribution is prohibited. If you are not the intended recipient, please contact the sender by reply email and destroy all copies of the original message and any attachments. > --- This email has been checked for viruses by Avast antivirus software. https://www.avast.com/antivirus