You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@couchdb.apache.org by Chris Keele <em...@chriskeele.com> on 2013/10/16 16:39:54 UTC
Elixir Sandbox
Hey everyone! I'm trying to develop a sandbox for Elixir, and I wanted to see how such a library might prove useful to the CouchDB dev community.
My initial goal is just to be able to run string of code in a predefined environment with configurable modules disabled, returning all output. But I'd like to design it for bigger things from the ground up, so I was wondering what sorts of requirements you might have of a sandbox library if you wanted to, say, implement a secure view processor.
I've started a discussion thread here: https://groups.google.com/forum/#!topic/elixir-lang-talk/wA1l74HCZmI, but I'm particularly interested in your opinions!
--
Chris Keele
Re: Elixir Sandbox
Posted by Benoit Chesneau <bc...@gmail.com>.
On Wed, Oct 16, 2013 at 11:58 PM, Jan Lehnardt <ja...@apache.org> wrote:
>
> On Oct 16, 2013, at 23:40 , Benoit Chesneau <bc...@gmail.com> wrote:
>
> > On Wed, Oct 16, 2013 at 11:32 PM, Klaus Trainer <klaus_trainer@posteo.de
> >wrote:
> >
> >> Hi there!
> >>
> >> You might want to check out Try Erlang (http://www.tryerlang.org/).
> >> That is, you can't check out the source code right now. However,
> >> according to the FAQ (http://www.tryerlang.org/faq) they "plan to
> >> release the whole project as Open Source very soon". I guess that
> >> nagging Roberto Aloi (who's the principal author) might speed that up ;)
> >>
> >> Regarding sandbox security: I believe that it is possible to implement a
> >> sandbox thing that provides reasonable security, as long as your
> >> whitelist is restrictive enough. That is, one has to be pretty cautious
> >> regarding the whitelist policy, especially when it comes to functions
> >> that have the ability to construct new terms, like for instance
> >> `list_to_atom/1` or `binary_to_term/1,2`. The former makes it possible
> >> fill up the Erlang VM's atom table, which makes it prone to DoS attacks.
> >> The latter has a "safe" mode (when being invoked with the `safe`
> >> option), though, but still allows to create function references, which
> >> can be exploited (see
> >>
> >>
> http://aloiroberto.wordpress.com/2010/10/14/how-they-tried-to-fool-tryerlang-org/
> >> ).
> >>
> >> Oh, I've used the term "reasonable security" above. I should explain
> >> (at least roughly) what I mean with that ;) For example, Try Erlang has
> >> been existing (and being online) for several years now, and people
> >> haven't found something exploitable, except for one time more than three
> >> years ago. Depending on your security needs, your knowledge of Erlang,
> >> your knowledge of the sandbox code, and other known facts as well as
> >> your general level of paranoia, this might be enough for you to trust
> it.
> >>
> >>
> >> Klaus
> >>
> >>
> >
> > On linux a simpler way would be launching an external command in a
> cgroup.
> > with cgexec from libcgroup or stuff like
> > https://github.com/thestinger/playpen rather than try to filter any call
> > you could then forbid some devices, the network and such...
>
> at which point you lose all the speed improvements an in-VM language gives
> you.
>
Well it depends how you use it. You may just need to start couchdb in 1
cgroup. Or launch each view server isolated in their own process added or
not to a cgroup (or resource limited).
Anyway you will also lose a lot of the performance if you filter in live
Erlang or Elixir. I don't think it's really a question of performance but
more likely of the convenience you want and the platform of course.
- benoit
Re: Elixir Sandbox
Posted by Jan Lehnardt <ja...@apache.org>.
On Oct 16, 2013, at 23:40 , Benoit Chesneau <bc...@gmail.com> wrote:
> On Wed, Oct 16, 2013 at 11:32 PM, Klaus Trainer <kl...@posteo.de>wrote:
>
>> Hi there!
>>
>> You might want to check out Try Erlang (http://www.tryerlang.org/).
>> That is, you can't check out the source code right now. However,
>> according to the FAQ (http://www.tryerlang.org/faq) they "plan to
>> release the whole project as Open Source very soon". I guess that
>> nagging Roberto Aloi (who's the principal author) might speed that up ;)
>>
>> Regarding sandbox security: I believe that it is possible to implement a
>> sandbox thing that provides reasonable security, as long as your
>> whitelist is restrictive enough. That is, one has to be pretty cautious
>> regarding the whitelist policy, especially when it comes to functions
>> that have the ability to construct new terms, like for instance
>> `list_to_atom/1` or `binary_to_term/1,2`. The former makes it possible
>> fill up the Erlang VM's atom table, which makes it prone to DoS attacks.
>> The latter has a "safe" mode (when being invoked with the `safe`
>> option), though, but still allows to create function references, which
>> can be exploited (see
>>
>> http://aloiroberto.wordpress.com/2010/10/14/how-they-tried-to-fool-tryerlang-org/
>> ).
>>
>> Oh, I've used the term "reasonable security" above. I should explain
>> (at least roughly) what I mean with that ;) For example, Try Erlang has
>> been existing (and being online) for several years now, and people
>> haven't found something exploitable, except for one time more than three
>> years ago. Depending on your security needs, your knowledge of Erlang,
>> your knowledge of the sandbox code, and other known facts as well as
>> your general level of paranoia, this might be enough for you to trust it.
>>
>>
>> Klaus
>>
>>
>
> On linux a simpler way would be launching an external command in a cgroup.
> with cgexec from libcgroup or stuff like
> https://github.com/thestinger/playpen rather than try to filter any call
> you could then forbid some devices, the network and such...
at which point you lose all the speed improvements an in-VM language gives
you.
Jan
--
>
> - benoit
>
>
>
>
>>
>> On 10/16/2013 08:48 PM, Paul Davis wrote:
>>> There have been discussions on figuring out how to sandbox Erlang. The
>>> biggest thing on that front was that we'd want it to be a whitelist as
>>> opposed to a blacklist of modules and/or module/function pairs. The
>>> second is that with dynamic invocation its not immediately apparent if
>>> that's entirely possible to do.
>>>
>>> On Wed, Oct 16, 2013 at 10:39 AM, Chris Keele <em...@chriskeele.com>
>> wrote:
>>>> Hey everyone! I'm trying to develop a sandbox for Elixir, and I wanted
>> to see how such a library might prove useful to the CouchDB dev community.
>>>>
>>>> My initial goal is just to be able to run string of code in a
>> predefined environment with configurable modules disabled, returning all
>> output. But I'd like to design it for bigger things from the ground up, so
>> I was wondering what sorts of requirements you might have of a sandbox
>> library if you wanted to, say, implement a secure view processor.
>>>>
>>>> I've started a discussion thread here:
>> https://groups.google.com/forum/#!topic/elixir-lang-talk/wA1l74HCZmI, but
>> I'm particularly interested in your opinions!
>>>> --
>>>> Chris Keele
>>>>
>>
>>
>>
Re: Elixir Sandbox
Posted by Benoit Chesneau <bc...@gmail.com>.
On Wed, Oct 16, 2013 at 11:32 PM, Klaus Trainer <kl...@posteo.de>wrote:
> Hi there!
>
> You might want to check out Try Erlang (http://www.tryerlang.org/).
> That is, you can't check out the source code right now. However,
> according to the FAQ (http://www.tryerlang.org/faq) they "plan to
> release the whole project as Open Source very soon". I guess that
> nagging Roberto Aloi (who's the principal author) might speed that up ;)
>
> Regarding sandbox security: I believe that it is possible to implement a
> sandbox thing that provides reasonable security, as long as your
> whitelist is restrictive enough. That is, one has to be pretty cautious
> regarding the whitelist policy, especially when it comes to functions
> that have the ability to construct new terms, like for instance
> `list_to_atom/1` or `binary_to_term/1,2`. The former makes it possible
> fill up the Erlang VM's atom table, which makes it prone to DoS attacks.
> The latter has a "safe" mode (when being invoked with the `safe`
> option), though, but still allows to create function references, which
> can be exploited (see
>
> http://aloiroberto.wordpress.com/2010/10/14/how-they-tried-to-fool-tryerlang-org/
> ).
>
> Oh, I've used the term "reasonable security" above. I should explain
> (at least roughly) what I mean with that ;) For example, Try Erlang has
> been existing (and being online) for several years now, and people
> haven't found something exploitable, except for one time more than three
> years ago. Depending on your security needs, your knowledge of Erlang,
> your knowledge of the sandbox code, and other known facts as well as
> your general level of paranoia, this might be enough for you to trust it.
>
>
> Klaus
>
>
On linux a simpler way would be launching an external command in a cgroup.
with cgexec from libcgroup or stuff like
https://github.com/thestinger/playpen rather than try to filter any call
you could then forbid some devices, the network and such...
- benoit
>
> On 10/16/2013 08:48 PM, Paul Davis wrote:
> > There have been discussions on figuring out how to sandbox Erlang. The
> > biggest thing on that front was that we'd want it to be a whitelist as
> > opposed to a blacklist of modules and/or module/function pairs. The
> > second is that with dynamic invocation its not immediately apparent if
> > that's entirely possible to do.
> >
> > On Wed, Oct 16, 2013 at 10:39 AM, Chris Keele <em...@chriskeele.com>
> wrote:
> >> Hey everyone! I'm trying to develop a sandbox for Elixir, and I wanted
> to see how such a library might prove useful to the CouchDB dev community.
> >>
> >> My initial goal is just to be able to run string of code in a
> predefined environment with configurable modules disabled, returning all
> output. But I'd like to design it for bigger things from the ground up, so
> I was wondering what sorts of requirements you might have of a sandbox
> library if you wanted to, say, implement a secure view processor.
> >>
> >> I've started a discussion thread here:
> https://groups.google.com/forum/#!topic/elixir-lang-talk/wA1l74HCZmI, but
> I'm particularly interested in your opinions!
> >> --
> >> Chris Keele
> >>
>
>
>
Re: Elixir Sandbox
Posted by Klaus Trainer <kl...@posteo.de>.
Hi there!
You might want to check out Try Erlang (http://www.tryerlang.org/).
That is, you can't check out the source code right now. However,
according to the FAQ (http://www.tryerlang.org/faq) they "plan to
release the whole project as Open Source very soon". I guess that
nagging Roberto Aloi (who's the principal author) might speed that up ;)
Regarding sandbox security: I believe that it is possible to implement a
sandbox thing that provides reasonable security, as long as your
whitelist is restrictive enough. That is, one has to be pretty cautious
regarding the whitelist policy, especially when it comes to functions
that have the ability to construct new terms, like for instance
`list_to_atom/1` or `binary_to_term/1,2`. The former makes it possible
fill up the Erlang VM's atom table, which makes it prone to DoS attacks.
The latter has a "safe" mode (when being invoked with the `safe`
option), though, but still allows to create function references, which
can be exploited (see
http://aloiroberto.wordpress.com/2010/10/14/how-they-tried-to-fool-tryerlang-org/).
Oh, I've used the term "reasonable security" above. I should explain
(at least roughly) what I mean with that ;) For example, Try Erlang has
been existing (and being online) for several years now, and people
haven't found something exploitable, except for one time more than three
years ago. Depending on your security needs, your knowledge of Erlang,
your knowledge of the sandbox code, and other known facts as well as
your general level of paranoia, this might be enough for you to trust it.
Klaus
On 10/16/2013 08:48 PM, Paul Davis wrote:
> There have been discussions on figuring out how to sandbox Erlang. The
> biggest thing on that front was that we'd want it to be a whitelist as
> opposed to a blacklist of modules and/or module/function pairs. The
> second is that with dynamic invocation its not immediately apparent if
> that's entirely possible to do.
>
> On Wed, Oct 16, 2013 at 10:39 AM, Chris Keele <em...@chriskeele.com> wrote:
>> Hey everyone! I'm trying to develop a sandbox for Elixir, and I wanted to see how such a library might prove useful to the CouchDB dev community.
>>
>> My initial goal is just to be able to run string of code in a predefined environment with configurable modules disabled, returning all output. But I'd like to design it for bigger things from the ground up, so I was wondering what sorts of requirements you might have of a sandbox library if you wanted to, say, implement a secure view processor.
>>
>> I've started a discussion thread here: https://groups.google.com/forum/#!topic/elixir-lang-talk/wA1l74HCZmI, but I'm particularly interested in your opinions!
>> --
>> Chris Keele
>>
Re: Elixir Sandbox
Posted by Alexei Sholik <al...@gmail.com>.
Hi Dave,
I wanted to do a quick and dirty proof of concept, so I simply compiled
some Elixir code to .beam and placed that .beam alongside other couchdb's
beams. The .beam itself does not contain any calls to Elixir stdlib, so I
assumed it would work.
I've also tried using ERL_LIBS like this:
ERL_LIBS=/usr/local/lib/couchdb/erlang/lib/couch-1.3.1 couchdb -n -A .
didn't work. Although, running erl from the same directory works:
λ ERL_LIBS=/usr/local/lib/couchdb/erlang/lib/couch-1.3.1 erl
1> 'Elixir.CouchQuery':start_link().
{ok,<0.34.0>}
I thought CouchDB may be started in embedded mode, but failed to identify
that in the start script. My question is: why can't it find the newly added
.beam?
On Tue, Nov 12, 2013 at 10:10 AM, Dave Cottlehuber <dc...@jsonified.com>wrote:
> On 12. November 2013 at 08:59:15, Alexei Sholik (alcosholik@gmail.com)
> wrote:
> >
> > > So yes, Elixir please! :) And if we get a sandbox as well, we can
> > even
> > enable it by default :)
> >
> > I tried to add a .beam produced by Elixir to my CouchDB installation
> > (I
> > didn't want to rebuild the whole project), but Couch can't find
> > it. I
> > posted a question on this ML[1]. Any hints?
> >
> > [1]:
> >
> http://mail-archives.apache.org/mod_mbox/couchdb-dev/201308.mbox/%3CCAAPY6ePTSVSTPYWvquRnnXN0pwbfWmitEE2GAWjsPhATv5iw9Q@mail.gmail.com%3E
>
> Hey Alexei!
>
> Sorry I had this email marked in “must get to, still haven’t”.
>
> How are you starting couch? you should be able to set ERL_LIBS like any
> other Erlang/Elixir project, and drop it in there. It’s picked up in
> `couchdb` script, so alternatively you can hack that directly:
>
> https://github.com/apache/couchdb/blob/master/bin/couchdb.tpl.in
>
> Also, the new plugin interface in 1.5.0 might be what you want;
> https://github.com/apache/couchdb/blob/master/src/couch_plugins/README.md
>
> A+
> Dave
>
>
--
Best regards
Alexei Sholik
Re: Elixir Sandbox
Posted by Dave Cottlehuber <dc...@jsonified.com>.
On 12. November 2013 at 08:59:15, Alexei Sholik (alcosholik@gmail.com) wrote:
>
> > So yes, Elixir please! :) And if we get a sandbox as well, we can
> even
> enable it by default :)
>
> I tried to add a .beam produced by Elixir to my CouchDB installation
> (I
> didn't want to rebuild the whole project), but Couch can't find
> it. I
> posted a question on this ML[1]. Any hints?
>
> [1]:
> http://mail-archives.apache.org/mod_mbox/couchdb-dev/201308.mbox/%3CCAAPY6ePTSVSTPYWvquRnnXN0pwbfWmitEE2GAWjsPhATv5iw9Q@mail.gmail.com%3E
Hey Alexei!
Sorry I had this email marked in “must get to, still haven’t”.
How are you starting couch? you should be able to set ERL_LIBS like any other Erlang/Elixir project, and drop it in there. It’s picked up in `couchdb` script, so alternatively you can hack that directly:
https://github.com/apache/couchdb/blob/master/bin/couchdb.tpl.in
Also, the new plugin interface in 1.5.0 might be what you want; https://github.com/apache/couchdb/blob/master/src/couch_plugins/README.md
A+
Dave
Re: Elixir Sandbox
Posted by Alexei Sholik <al...@gmail.com>.
> So yes, Elixir please! :) And if we get a sandbox as well, we can even
enable it by default :)
I tried to add a .beam produced by Elixir to my CouchDB installation (I
didn't want to rebuild the whole project), but Couch can't find it. I
posted a question on this ML[1]. Any hints?
[1]:
http://mail-archives.apache.org/mod_mbox/couchdb-dev/201308.mbox/%3CCAAPY6ePTSVSTPYWvquRnnXN0pwbfWmitEE2GAWjsPhATv5iw9Q@mail.gmail.com%3E
On Thu, Oct 17, 2013 at 12:29 AM, Jan Lehnardt <ja...@apache.org> wrote:
>
> On Oct 16, 2013, at 23:16 , Benoit Chesneau <bc...@gmail.com> wrote:
>
> > On Wed, Oct 16, 2013 at 10:54 PM, Filippo Fadda <
> > filippo.fadda@programmazione.it> wrote:
> >
> >> Sandboxing is something optional I think, you need only when you are
> >> developing a CouchApp, when you do all in JavaScript, using the _users
> >> database and running the app inside CouchDB. But if you are just using
> >> CouchDB like a database, developing a web app using PHP or Python, for
> >> example, you'll never give access to CouchDB from outside, through Futon
> >> for example, so no one will be able to store a new design doc in your
> >> database to run malicious code. I'm using PHP with the ElephantOnCouch
> >> Query Server, writing ddoc in PHP, and I really don't see why I should
> >> using runkit to sandboxing the Query Server.
> >>
> >> -Filippo
> >>
> >
> > Sandboxing is not only needed for couchapps but also views. If someone
> > using a view inspect your hd and emit the result or send your docs
> using
> > a tcp connections to an unknown remote target it can be a risk. That's
> why
> > it's needed. Even allowed users can be a possible risk.
>
> I think Filippo used “CouchApps” as a synonym for “you may receive code
> not written by you or someone your trust” in which case you absolutely
> want a sandbox.
>
> My point was just that there are equally scenarios where that trust exists
> and Filippo illustrated them a bit better than I did originally.
>
> So yes, Elixir please! :) And if we get a sandbox as well, we can even
> enable it by default :)
>
> Best
> Jan
> --
>
>
>
>
> >
> >
> >
> >>
> >> On Oct 16, 2013, at 10:27 PM, Jan Lehnardt wrote:
> >>
> >>> Another option would be to start with treating the Elexir Query Server
> >>> like the Erlang Query Server and keep it off by default and with full
> >>> access to the internals, so people could opt into it, if their
> >> environment
> >>> allows for it.
> >>>
> >>> Sandboxing could be a step on top or later.
> >>>
> >>> I for one would like to see native Elexir support for Views et.al in
> >> CouchDB :)
> >>>
> >>> Best
> >>> Jan
> >>> --
> >>>
> >>> On Oct 16, 2013, at 20:48 , Paul Davis <pa...@gmail.com>
> >> wrote:
> >>>
> >>>> There have been discussions on figuring out how to sandbox Erlang. The
> >>>> biggest thing on that front was that we'd want it to be a whitelist as
> >>>> opposed to a blacklist of modules and/or module/function pairs. The
> >>>> second is that with dynamic invocation its not immediately apparent if
> >>>> that's entirely possible to do.
> >>>>
> >>>> On Wed, Oct 16, 2013 at 10:39 AM, Chris Keele <em...@chriskeele.com>
> >> wrote:
> >>>>> Hey everyone! I'm trying to develop a sandbox for Elixir, and I
> wanted
> >> to see how such a library might prove useful to the CouchDB dev
> community.
> >>>>>
> >>>>> My initial goal is just to be able to run string of code in a
> >> predefined environment with configurable modules disabled, returning all
> >> output. But I'd like to design it for bigger things from the ground up,
> so
> >> I was wondering what sorts of requirements you might have of a sandbox
> >> library if you wanted to, say, implement a secure view processor.
> >>>>>
> >>>>> I've started a discussion thread here:
> >> https://groups.google.com/forum/#!topic/elixir-lang-talk/wA1l74HCZmI,
> but
> >> I'm particularly interested in your opinions!
> >>>>> --
> >>>>> Chris Keele
> >>>>>
> >>>
> >>
> >>
>
>
--
Best regards
Alexei Sholik
Re: Elixir Sandbox
Posted by Jan Lehnardt <ja...@apache.org>.
On Oct 16, 2013, at 23:16 , Benoit Chesneau <bc...@gmail.com> wrote:
> On Wed, Oct 16, 2013 at 10:54 PM, Filippo Fadda <
> filippo.fadda@programmazione.it> wrote:
>
>> Sandboxing is something optional I think, you need only when you are
>> developing a CouchApp, when you do all in JavaScript, using the _users
>> database and running the app inside CouchDB. But if you are just using
>> CouchDB like a database, developing a web app using PHP or Python, for
>> example, you'll never give access to CouchDB from outside, through Futon
>> for example, so no one will be able to store a new design doc in your
>> database to run malicious code. I'm using PHP with the ElephantOnCouch
>> Query Server, writing ddoc in PHP, and I really don't see why I should
>> using runkit to sandboxing the Query Server.
>>
>> -Filippo
>>
>
> Sandboxing is not only needed for couchapps but also views. If someone
> using a view inspect your hd and emit the result or send your docs using
> a tcp connections to an unknown remote target it can be a risk. That's why
> it's needed. Even allowed users can be a possible risk.
I think Filippo used “CouchApps” as a synonym for “you may receive code
not written by you or someone your trust” in which case you absolutely
want a sandbox.
My point was just that there are equally scenarios where that trust exists
and Filippo illustrated them a bit better than I did originally.
So yes, Elixir please! :) And if we get a sandbox as well, we can even
enable it by default :)
Best
Jan
--
>
>
>
>>
>> On Oct 16, 2013, at 10:27 PM, Jan Lehnardt wrote:
>>
>>> Another option would be to start with treating the Elexir Query Server
>>> like the Erlang Query Server and keep it off by default and with full
>>> access to the internals, so people could opt into it, if their
>> environment
>>> allows for it.
>>>
>>> Sandboxing could be a step on top or later.
>>>
>>> I for one would like to see native Elexir support for Views et.al in
>> CouchDB :)
>>>
>>> Best
>>> Jan
>>> --
>>>
>>> On Oct 16, 2013, at 20:48 , Paul Davis <pa...@gmail.com>
>> wrote:
>>>
>>>> There have been discussions on figuring out how to sandbox Erlang. The
>>>> biggest thing on that front was that we'd want it to be a whitelist as
>>>> opposed to a blacklist of modules and/or module/function pairs. The
>>>> second is that with dynamic invocation its not immediately apparent if
>>>> that's entirely possible to do.
>>>>
>>>> On Wed, Oct 16, 2013 at 10:39 AM, Chris Keele <em...@chriskeele.com>
>> wrote:
>>>>> Hey everyone! I'm trying to develop a sandbox for Elixir, and I wanted
>> to see how such a library might prove useful to the CouchDB dev community.
>>>>>
>>>>> My initial goal is just to be able to run string of code in a
>> predefined environment with configurable modules disabled, returning all
>> output. But I'd like to design it for bigger things from the ground up, so
>> I was wondering what sorts of requirements you might have of a sandbox
>> library if you wanted to, say, implement a secure view processor.
>>>>>
>>>>> I've started a discussion thread here:
>> https://groups.google.com/forum/#!topic/elixir-lang-talk/wA1l74HCZmI, but
>> I'm particularly interested in your opinions!
>>>>> --
>>>>> Chris Keele
>>>>>
>>>
>>
>>
Re: Elixir Sandbox
Posted by Filippo Fadda <fi...@programmazione.it>.
But you should be able to create a view and save it into a ddoc. And to do that you need the access to the database and the user credentials. If the web application is made in Python, for example, you don't even know it's using CouchDB, how can you think to create a view? This is just science fiction.
We are talking of something you can do when you leave your database "open" to the world and this is not the case of any web application, unless you are using CouchDB to run couch apps or as a service.
You can't run malicious code on my server, because you simply haven't access to CouchDB from a remote IP. If I'm using an Elixir, PHP, Ruby or Python query server, I'll never let you access to my database, because I'm developing the app in Elixir, PHP, Ruby or Python, you don't even know that I'm using CouchDB.
If you are a company selling CouchDB as a service you want be sure no one can run malicious code on it, but if you are not, you really don't need a sandbox.
I have a security question for you instead. The access to MySQL (or Oracle) can be configured per user by IP. Is this option available in CouchDB? This is really important, not the sandboxing of a query server.
-Filippo
On Oct 16, 2013, at 11:16 PM, Benoit Chesneau wrote:
> Sandboxing is not only needed for couchapps but also views. If someone
> using a view inspect your hd and emit the result or send your docs using
> a tcp connections to an unknown remote target it can be a risk. That's why
> it's needed. Even allowed users can be a possible risk.
>
> - benoit
Re: Elixir Sandbox
Posted by Benoit Chesneau <bc...@gmail.com>.
On Wed, Oct 16, 2013 at 10:54 PM, Filippo Fadda <
filippo.fadda@programmazione.it> wrote:
> Sandboxing is something optional I think, you need only when you are
> developing a CouchApp, when you do all in JavaScript, using the _users
> database and running the app inside CouchDB. But if you are just using
> CouchDB like a database, developing a web app using PHP or Python, for
> example, you'll never give access to CouchDB from outside, through Futon
> for example, so no one will be able to store a new design doc in your
> database to run malicious code. I'm using PHP with the ElephantOnCouch
> Query Server, writing ddoc in PHP, and I really don't see why I should
> using runkit to sandboxing the Query Server.
>
> -Filippo
>
Sandboxing is not only needed for couchapps but also views. If someone
using a view inspect your hd and emit the result or send your docs using
a tcp connections to an unknown remote target it can be a risk. That's why
it's needed. Even allowed users can be a possible risk.
- benoit
>
> On Oct 16, 2013, at 10:27 PM, Jan Lehnardt wrote:
>
> > Another option would be to start with treating the Elexir Query Server
> > like the Erlang Query Server and keep it off by default and with full
> > access to the internals, so people could opt into it, if their
> environment
> > allows for it.
> >
> > Sandboxing could be a step on top or later.
> >
> > I for one would like to see native Elexir support for Views et.al in
> CouchDB :)
> >
> > Best
> > Jan
> > --
> >
> > On Oct 16, 2013, at 20:48 , Paul Davis <pa...@gmail.com>
> wrote:
> >
> >> There have been discussions on figuring out how to sandbox Erlang. The
> >> biggest thing on that front was that we'd want it to be a whitelist as
> >> opposed to a blacklist of modules and/or module/function pairs. The
> >> second is that with dynamic invocation its not immediately apparent if
> >> that's entirely possible to do.
> >>
> >> On Wed, Oct 16, 2013 at 10:39 AM, Chris Keele <em...@chriskeele.com>
> wrote:
> >>> Hey everyone! I'm trying to develop a sandbox for Elixir, and I wanted
> to see how such a library might prove useful to the CouchDB dev community.
> >>>
> >>> My initial goal is just to be able to run string of code in a
> predefined environment with configurable modules disabled, returning all
> output. But I'd like to design it for bigger things from the ground up, so
> I was wondering what sorts of requirements you might have of a sandbox
> library if you wanted to, say, implement a secure view processor.
> >>>
> >>> I've started a discussion thread here:
> https://groups.google.com/forum/#!topic/elixir-lang-talk/wA1l74HCZmI, but
> I'm particularly interested in your opinions!
> >>> --
> >>> Chris Keele
> >>>
> >
>
>
Re: Elixir Sandbox
Posted by Jan Lehnardt <ja...@apache.org>.
On Oct 16, 2013, at 22:54 , Filippo Fadda <fi...@programmazione.it> wrote:
> Sandboxing is something optional I think, you need only when you are developing a CouchApp, when you do all in JavaScript, using the _users database and running the app inside CouchDB. But if you are just using CouchDB like a database, developing a web app using PHP or Python, for example, you'll never give access to CouchDB from outside, through Futon for example, so no one will be able to store a new design doc in your database to run malicious code. I'm using PHP with the ElephantOnCouch Query Server, writing ddoc in PHP, and I really don't see why I should using runkit to sandboxing the Query Server.
That was exactly my point. Thank you for making it more clear, Filippo :)
Best
Jan
--
>
> -Filippo
>
> On Oct 16, 2013, at 10:27 PM, Jan Lehnardt wrote:
>
>> Another option would be to start with treating the Elexir Query Server
>> like the Erlang Query Server and keep it off by default and with full
>> access to the internals, so people could opt into it, if their environment
>> allows for it.
>>
>> Sandboxing could be a step on top or later.
>>
>> I for one would like to see native Elexir support for Views et.al in CouchDB :)
>>
>> Best
>> Jan
>> --
>>
>> On Oct 16, 2013, at 20:48 , Paul Davis <pa...@gmail.com> wrote:
>>
>>> There have been discussions on figuring out how to sandbox Erlang. The
>>> biggest thing on that front was that we'd want it to be a whitelist as
>>> opposed to a blacklist of modules and/or module/function pairs. The
>>> second is that with dynamic invocation its not immediately apparent if
>>> that's entirely possible to do.
>>>
>>> On Wed, Oct 16, 2013 at 10:39 AM, Chris Keele <em...@chriskeele.com> wrote:
>>>> Hey everyone! I'm trying to develop a sandbox for Elixir, and I wanted to see how such a library might prove useful to the CouchDB dev community.
>>>>
>>>> My initial goal is just to be able to run string of code in a predefined environment with configurable modules disabled, returning all output. But I'd like to design it for bigger things from the ground up, so I was wondering what sorts of requirements you might have of a sandbox library if you wanted to, say, implement a secure view processor.
>>>>
>>>> I've started a discussion thread here: https://groups.google.com/forum/#!topic/elixir-lang-talk/wA1l74HCZmI, but I'm particularly interested in your opinions!
>>>> --
>>>> Chris Keele
>>>>
>>
>
Re: Elixir Sandbox
Posted by Filippo Fadda <fi...@programmazione.it>.
Sandboxing is useful when you are running applications, in a defined environment (like an OS), you can't trust, not libraries, but applications. For example in iOS all the apps are sandboxed, not the system libraries. But no one can't run an application inside CouchDB if CouchDB can't be accessed from outside. You can't do the equivalent of SQL injection in CouchDB using CouchDB as simple DBMS. An user can't insert a ddoc in it if you can connect to CouchDB just from the localhost and you don't know the admin's username and pass.
The only person able to write ddocs is the application developer, and I'm pretty sure he won't delete the root directory in a map function. When used as a pure database, CouchDB is not an environment, it's a database, something to store documents, using a client. CouchDB used to run Couch apps instead is an environment, it acts like an OS in which the applications run. In this case, maybe, you need a sandbox.
I mean, the only needs I see for sandboxing here is when you have a company selling CouchDB as a service, and running any kind of third part applications, or as I said, when you are using CouchDB as the environment in which the couch apps run.
I'm not saying sandboxing is useless, I'm saying is something optional a sys admin should enable in case of need.
-Filippo
On Oct 16, 2013, at 11:03 PM, Alexander Shorin wrote:
> Because you are running your code and you trust yourself (I hope so).
> Another user may not trust you or your code, so he have to inspect
> every bit of your code to make sure that it wouldn't make a big
> security hole in his server. Having sandboxing feature guarantees him
> that he may run third party code with no worries about.
>
> --
> ,,,^..^,,,
Re: Elixir Sandbox
Posted by Alexander Shorin <kx...@gmail.com>.
On Thu, Oct 17, 2013 at 1:13 AM, Jan Lehnardt <ja...@apache.org> wrote:
> On Oct 16, 2013, at 23:03 , Alexander Shorin <kx...@gmail.com> wrote:
>
>> On Thu, Oct 17, 2013 at 12:54 AM, Filippo Fadda
>> <fi...@programmazione.it> wrote:
>>> Sandboxing is something optional I think, you need only when you are developing a CouchApp, when you do all in JavaScript, using the _users database and running the app inside CouchDB. But if you are just using CouchDB like a database, developing a web app using PHP or Python, for example, you'll never give access to CouchDB from outside, through Futon for example, so no one will be able to store a new design doc in your database to run malicious code. I'm using PHP with the ElephantOnCouch Query Server, writing ddoc in PHP, and I really don't see why I should using runkit to sandboxing the Query Server.
>>
>> Because you are running your code and you trust yourself (I hope so).
>> Another user may not trust you or your code, so he have to inspect
>> every bit of your code to make sure that it wouldn't make a big
>> security hole in his server. Having sandboxing feature guarantees him
>> that he may run third party code with no worries about.
>
> Heh right, I think Filipo is aware of the dichotomy. I think all we want to say is that Elexir support for CouchDB is very welcome with and without a sandbox (or both :)
Agree (:
--
,,,^..^,,,
Re: Elixir Sandbox
Posted by Jan Lehnardt <ja...@apache.org>.
On Oct 16, 2013, at 23:03 , Alexander Shorin <kx...@gmail.com> wrote:
> On Thu, Oct 17, 2013 at 12:54 AM, Filippo Fadda
> <fi...@programmazione.it> wrote:
>> Sandboxing is something optional I think, you need only when you are developing a CouchApp, when you do all in JavaScript, using the _users database and running the app inside CouchDB. But if you are just using CouchDB like a database, developing a web app using PHP or Python, for example, you'll never give access to CouchDB from outside, through Futon for example, so no one will be able to store a new design doc in your database to run malicious code. I'm using PHP with the ElephantOnCouch Query Server, writing ddoc in PHP, and I really don't see why I should using runkit to sandboxing the Query Server.
>
> Because you are running your code and you trust yourself (I hope so).
> Another user may not trust you or your code, so he have to inspect
> every bit of your code to make sure that it wouldn't make a big
> security hole in his server. Having sandboxing feature guarantees him
> that he may run third party code with no worries about.
Heh right, I think Filipo is aware of the dichotomy. I think all we want to say is that Elexir support for CouchDB is very welcome with and without a sandbox (or both :)
Best
Jan
--
Re: Elixir Sandbox
Posted by Alexander Shorin <kx...@gmail.com>.
On Thu, Oct 17, 2013 at 12:54 AM, Filippo Fadda
<fi...@programmazione.it> wrote:
> Sandboxing is something optional I think, you need only when you are developing a CouchApp, when you do all in JavaScript, using the _users database and running the app inside CouchDB. But if you are just using CouchDB like a database, developing a web app using PHP or Python, for example, you'll never give access to CouchDB from outside, through Futon for example, so no one will be able to store a new design doc in your database to run malicious code. I'm using PHP with the ElephantOnCouch Query Server, writing ddoc in PHP, and I really don't see why I should using runkit to sandboxing the Query Server.
Because you are running your code and you trust yourself (I hope so).
Another user may not trust you or your code, so he have to inspect
every bit of your code to make sure that it wouldn't make a big
security hole in his server. Having sandboxing feature guarantees him
that he may run third party code with no worries about.
--
,,,^..^,,,
Re: Elixir Sandbox
Posted by Filippo Fadda <fi...@programmazione.it>.
Sandboxing is something optional I think, you need only when you are developing a CouchApp, when you do all in JavaScript, using the _users database and running the app inside CouchDB. But if you are just using CouchDB like a database, developing a web app using PHP or Python, for example, you'll never give access to CouchDB from outside, through Futon for example, so no one will be able to store a new design doc in your database to run malicious code. I'm using PHP with the ElephantOnCouch Query Server, writing ddoc in PHP, and I really don't see why I should using runkit to sandboxing the Query Server.
-Filippo
On Oct 16, 2013, at 10:27 PM, Jan Lehnardt wrote:
> Another option would be to start with treating the Elexir Query Server
> like the Erlang Query Server and keep it off by default and with full
> access to the internals, so people could opt into it, if their environment
> allows for it.
>
> Sandboxing could be a step on top or later.
>
> I for one would like to see native Elexir support for Views et.al in CouchDB :)
>
> Best
> Jan
> --
>
> On Oct 16, 2013, at 20:48 , Paul Davis <pa...@gmail.com> wrote:
>
>> There have been discussions on figuring out how to sandbox Erlang. The
>> biggest thing on that front was that we'd want it to be a whitelist as
>> opposed to a blacklist of modules and/or module/function pairs. The
>> second is that with dynamic invocation its not immediately apparent if
>> that's entirely possible to do.
>>
>> On Wed, Oct 16, 2013 at 10:39 AM, Chris Keele <em...@chriskeele.com> wrote:
>>> Hey everyone! I'm trying to develop a sandbox for Elixir, and I wanted to see how such a library might prove useful to the CouchDB dev community.
>>>
>>> My initial goal is just to be able to run string of code in a predefined environment with configurable modules disabled, returning all output. But I'd like to design it for bigger things from the ground up, so I was wondering what sorts of requirements you might have of a sandbox library if you wanted to, say, implement a secure view processor.
>>>
>>> I've started a discussion thread here: https://groups.google.com/forum/#!topic/elixir-lang-talk/wA1l74HCZmI, but I'm particularly interested in your opinions!
>>> --
>>> Chris Keele
>>>
>
Re: Elixir Sandbox
Posted by Jan Lehnardt <ja...@apache.org>.
Another option would be to start with treating the Elexir Query Server
like the Erlang Query Server and keep it off by default and with full
access to the internals, so people could opt into it, if their environment
allows for it.
Sandboxing could be a step on top or later.
I for one would like to see native Elexir support for Views et.al in CouchDB :)
Best
Jan
--
On Oct 16, 2013, at 20:48 , Paul Davis <pa...@gmail.com> wrote:
> There have been discussions on figuring out how to sandbox Erlang. The
> biggest thing on that front was that we'd want it to be a whitelist as
> opposed to a blacklist of modules and/or module/function pairs. The
> second is that with dynamic invocation its not immediately apparent if
> that's entirely possible to do.
>
> On Wed, Oct 16, 2013 at 10:39 AM, Chris Keele <em...@chriskeele.com> wrote:
>> Hey everyone! I'm trying to develop a sandbox for Elixir, and I wanted to see how such a library might prove useful to the CouchDB dev community.
>>
>> My initial goal is just to be able to run string of code in a predefined environment with configurable modules disabled, returning all output. But I'd like to design it for bigger things from the ground up, so I was wondering what sorts of requirements you might have of a sandbox library if you wanted to, say, implement a secure view processor.
>>
>> I've started a discussion thread here: https://groups.google.com/forum/#!topic/elixir-lang-talk/wA1l74HCZmI, but I'm particularly interested in your opinions!
>> --
>> Chris Keele
>>
Re: Elixir Sandbox
Posted by Paul Davis <pa...@gmail.com>.
There have been discussions on figuring out how to sandbox Erlang. The
biggest thing on that front was that we'd want it to be a whitelist as
opposed to a blacklist of modules and/or module/function pairs. The
second is that with dynamic invocation its not immediately apparent if
that's entirely possible to do.
On Wed, Oct 16, 2013 at 10:39 AM, Chris Keele <em...@chriskeele.com> wrote:
> Hey everyone! I'm trying to develop a sandbox for Elixir, and I wanted to see how such a library might prove useful to the CouchDB dev community.
>
> My initial goal is just to be able to run string of code in a predefined environment with configurable modules disabled, returning all output. But I'd like to design it for bigger things from the ground up, so I was wondering what sorts of requirements you might have of a sandbox library if you wanted to, say, implement a secure view processor.
>
> I've started a discussion thread here: https://groups.google.com/forum/#!topic/elixir-lang-talk/wA1l74HCZmI, but I'm particularly interested in your opinions!
> --
> Chris Keele
>