From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 83653 invoked by alias); 22 Nov 2017 11:11:14 -0000 Mailing-List: contact kawa-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: kawa-owner@sourceware.org Received: (qmail 83639 invoked by uid 89); 22 Nov 2017 11:11:13 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.7 required=5.0 tests=BAYES_00,KB_WAM_FROM_NAME_SINGLEWORD,SPF_PASS,T_RP_MATCHES_RCVD autolearn=no version=3.3.2 spammy=H*Ad:U*kawa, deprecating, H*r:sk:kawa@so, utterly X-HELO: mail.io7m.com Received: from mail.io7m.com (HELO mail.io7m.com) (45.77.76.92) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 22 Nov 2017 11:11:10 +0000 Received: from copperhead.int.arc7.info (unknown [IPv6:2a02:390:7502:2:0:2:1:0]) by mail.io7m.com (Postfix) with ESMTPSA id 215D26F2A for ; Wed, 22 Nov 2017 11:11:09 +0000 (UTC) Date: Wed, 22 Nov 2017 11:11:00 -0000 From: Mark Raynsford To: kawa@sourceware.org Subject: Sandboxing Kawa Message-ID: <20171122111055.21383f32@copperhead.int.arc7.info> OpenPGP: id=8168DAE22B15D3EDC722C23D0F15B7D06FA80CB8; url=http://io7m.com/pgp/8168_DAE2_2B15_D3ED_C722_C23D_0F15_B7D0_6FA8_0CB8.key MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; boundary="Sig_/nL2HjPFFLK1aNtb=4.P6Koa"; protocol="application/pgp-signature" X-IsSubscribed: yes X-SW-Source: 2017-q4/txt/msg00035.txt.bz2 --Sig_/nL2HjPFFLK1aNtb=4.P6Koa Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: quoted-printable Content-length: 2010 Hello. I'd like to embed Kawa into a Java program, using it as a base for a custom Scheme-like (but almost certainly not R*RS compatible) language. Leaving aside resource handling issues (such as scripts exhausting all available memory, spinning at 100% cpu usage, etc), I'm trying to work out how I can expose an utterly spartan bare-minimum interpreter to the host program that can only call a few functions that I expose to it. Anyone familiar with embedding Lua into a C program (or even into a Java program via something like Rembulan [0]) will probably be familiar with the idea: The language is used just to provide the basic syntax and evaluation semantics, but the standard library is more or less completely removed and replaced with a bare minimum API relevant to the domain in question. Doing this provides a relatively safe sandbox, because the sandboxed code simply doesn't have access to any functions that can do anything dangerous. I'd like to state beforehand that I'm trying to avoid using the Java SecurityManager unless it's utterly unavoidable (due to performance and administrative concerns, along with the fact that Oracle might be deprecating it eventually). I have the following questions after playing with the Kawa API a bit: 1. Is it possible to restrict the initially available symbols in a kawa.standard.Scheme instance to a tiny core subset (such as lambda, if, define, begin, etc)? A default Scheme instance in Kawa has 807 symbols in the environment. 2. Is it possible to restrict the interpreter to only working with a single java.nio.file.FileSystem? I'd like it if any attempt to do I/O went through a given filesystem instance. I don't mind if I have to implement my own I/O library to do this. 3. Is it possible to restrict the classes that the interpreter is allowed to access or import? For example, right now nothing stops the someone from writing (java.lang.System:exit 0). [0] https://github.com/mjanicek/rembulan --=20 Mark Raynsford | http://www.io7m.com --Sig_/nL2HjPFFLK1aNtb=4.P6Koa Content-Type: application/pgp-signature Content-Description: OpenPGP digital signature Content-length: 833 -----BEGIN PGP SIGNATURE----- iQIzBAEBCgAdFiEEgWja4isV0+3HIsI9DxW30G+oDLgFAloVWz8ACgkQDxW30G+o DLi7JA//c+YtE4GEXgRP9AsX0zhRU4jR2Rk4hwW3mOmLrFraoCJ9JibJV1EqlJet dUwYd/nZl+pE+iiJ0ibx2fDu9vUyyG0rQzLCmjKEr/qx4BZR2n+/Fpl2iIzyiqFf EzfgNAunZOCpslXglGYBL7nHnkPh3nIlguvWzG5LFrhaAtxoIXEfbbLCslOBmPb3 /5Ap+zJb0rH12RnuCJsyyB/asGZWDvq+nt4wgke8jAJYNgjVJo/khXKIS540G+u6 /kMn9Zk6W1cxeH3fRJWOtdS2gG1AzwNoSaXx5gktrj6Tn1zzqostOx2TBln6+zKa aHcfQaG+3Geb/hHSdD43yu1pGtDWcpjyWnyiRGuNWUjXK+7oHjoMT6NctfLFVido lKk99NTXk2iVN7TTKR8QO4RaDboQGYS7wmS8OAepRb1KStibEHoYvTUduDsyD7OX MDwYDwoyCrYRxjoh2QZ55TcCDMWHGWgoUjQQJ7o55iSIxOhlGcIEYi3n7STq+WQr 4hGC7xL7r42JY2rl3qbOnvo7AkTVxc8K69hdfnygnLQ8NdPPbjQGYsIwPGcdPsxi jFbuoeChFSLHAPoZtA8lWzQSmC/Qd2fL+gJFM1hLTWxJYnFurW4UgAESUCm3a+c5 52aYqqgrfZy0R66nzS9pwmQZmYmqHD6z+wq68UiPKjCcoUBkwMA= =B6Cn -----END PGP SIGNATURE----- --Sig_/nL2HjPFFLK1aNtb=4.P6Koa--