Closed DavyLandman closed 8 years ago
This nicely summarizes our discussion. Some attack vectors we should worry about (and against which we try to defend in the above proposal) are:
Notes:
../../../../etc/RGB.txt
, and forbid moving beyond the root of a scheme.Assuming that users cannot add their own @java functions, the first two parts of the solution seem to be the same thing. I think it's much better to whitelist functions that can be used than the blacklist them -- it would be too easy for something to slip through, for instance if someone forgets to add an @unsecure annotation.
Davy Landman wrote:
Goal
For various ideas (tutor/rascal on the web, automatic judging of results) we want to have a sandbox for rascal. This page describes our proposal of creating this mode for rascal.
We aim for a low-maintenance solution with minimal impact on our current system.
Setting (attack vector)
The external user is allow to submit rascal expressions or rascal files. A timeout can be used to limit the possibility of a DOS.
Proposed solution
Our solution is threefold.
- Disable the |@java| annotations on non library functions. (eg. white list the library functions).
- Blacklist unsecure rascal functions (such as |util::ShellExec|).
Whitelist location which can be resolved for either reading or writing.
Implementation
An evaluator is either started in sandbox mode or not, from rascal this cannot be changed. The descriptions below describe the cases when an evaluator is started in sandbox mode.
Disabling |@java| annotations on non library functions
During importing of a module, we check in case of a |@java| annotation if the current module is on a white listed path (containing the library paths).
Blacklisting unsecure rascal functions
We introduce a new annotation |@unsecure| (or a better name?) which is checked during the overload resolution, and if it is called in sandbox mode, we raise a security exception.
Whitelist locations which can be resolved
The Location resolvers are extended such that when they create a |InputStream| or an |OutputStream| they call our own |SandboxInputStreams| or |SandboxOutputStream| instead. These will check if you try to read or write outside your current path or the loaded eclipse projects.
So our question to you is, are we forgetting a attack vector or is this a secure sandbox?
— Reply to this email directly or view it on GitHub https://github.com/cwi-swat/rascal/issues/19.
@jurgenvinju I agree, but since the file interaction ends up in either Input or Output stream, I thought we could check the path there (and indeed always check an absolute path)
@mahills well, now users can add their own @java
functions, so we have to disable this. The blacklisting approach seems more maintainable. I suspect the risk of adding a @unsecure
annotation is just as high as someone automatically adding a function to the whitelist.
priority.
On Wed, Nov 14, 2012 at 4:05 PM, Davy Landman notifications@github.comwrote:
@jurgenvinju https://github.com/jurgenvinju I agree, but since the file interaction ends up in either Input or Output stream, I thought we could check the path there (and indeed always check an absolute path)
@mahills https://github.com/mahills well, now users can add their own @java functions, so we have to disable this. The blacklisting approach seems more maintainable. I suspect the risk of adding a @unsecureannotation is just as high as someone automatically adding a function to the whitelist.
— Reply to this email directly or view it on GitHubhttps://github.com/cwi-swat/rascal/issues/19#issuecomment-10369093.
Jurgen Vinju
Universiteit van Amsterdam
www: http://jurgen.vinju.org, http://www.rascal-mpl.nl, http://twitter.com/jurgenvinju skype: jurgen.vinju
@jurgenvinju yes, it is always a trade-off, I'm thinking that there is only a small set of escape hatches in the current rascal, and marking them as unsafe is simpeler than frequent maintenance of the whitelist.
Apart from the way to allow/disallow methods, are their actual holes in our proposal?
I don't know. It looks quite thorough. Is there a way to find out? We should search in the Rascal code on all uses of Java I/O facilities.
On Wed, Nov 14, 2012 at 4:28 PM, Davy Landman notifications@github.comwrote:
@jurgenvinju https://github.com/jurgenvinju yes, it is always a trade-off, I'm thinking that there is only a small set of escape hatches in the current rascal, and marking them as unsafe is simpeler than frequent maintenance of the whitelist.
Apart from the way to allow/disallow methods, are their actual holes in our proposal?
— Reply to this email directly or view it on GitHubhttps://github.com/cwi-swat/rascal/issues/19#issuecomment-10370040.
Jurgen Vinju
Universiteit van Amsterdam
www: http://jurgen.vinju.org, http://www.rascal-mpl.nl, http://twitter.com/jurgenvinju skype: jurgen.vinju
@jurgenvinju I smell a type and effect system coming
@DavyLandman What is the context for when we want the sandboxing? If the desire is just that a user can submit their own expressions, then I assume they cannot also provide their own Rascal modules with backing Java class files.
The issue is that you could write a function that binds to an existing unsafe library function:
@javaClass{points.to.unsafeClass} public java int myNewFunction();
On Thu, Nov 15, 2012 at 10:59 AM, mahills notifications@github.com wrote:
@jurgenvinju https://github.com/jurgenvinju I smell a type and effect system coming
@DavyLandman https://github.com/DavyLandman What is the context for when we want the sandboxing? If the desire is just that a user can submit their own expressions, then I assume they cannot also provide their own Rascal modules with backing Java class files.
— Reply to this email directly or view it on GitHubhttps://github.com/cwi-swat/rascal/issues/19#issuecomment-10403062.
Jurgen Vinju
Universiteit van Amsterdam
www: http://jurgen.vinju.org, http://www.rascal-mpl.nl, http://twitter.com/jurgenvinju skype: jurgen.vinju
@mahills correct, the user can submit their own expressions, or even full rascal files. but they are not allowed to use @javaClass
annotations in their own modules. This is both to protect against @jurgenvinju 's point, and any other kind of java code which the user could then write.
Goal
For various ideas (tutor/rascal on the web, automatic judging of results) we want to have a sandbox for Rascal. This page describes our proposal for creating this mode for rascal.
We aim for a low-maintenance solution with minimal impact on our current system.
Setting (attack vector)
The external user is allowed to submit Rascal expressions, Rascal files or non-executable data files. A timeout can be used to limit the possibility of a DOS. Data files can be used in two ways:
Proposed solution
Our solution is threefold.
@java
annotations on non- library functions. (eg., white list the library functions).util::ShellExec
).Implementation
An evaluator is either started in sandbox mode or not, from a Rascal program this cannot be changed. The descriptions below describe the cases when an evaluator is started in sandbox mode.
Disabling
@java
annotations on non-library functionsDuring import of a module, we check in case of a
@java
annotation if the current module is on a white listed path (containing the library paths).Blacklisting insecure Rascal functions
We introduce a new annotation
@insecure
(or a better name?) which is checked during overload resolution, and if it is called in sandbox mode, we raise a security exception.Whitelist locations which can be resolved
The Location resolvers are extended such that when they create an
InputStream
or anOutputStream
they call our ownSandboxInputStreams
orSandboxOutputStream
instead. These will check if you try to read or write outside your current path or the loaded eclipse projects.So our question to you is, are we forgetting an attack vector or is this a secure sandbox?