README.md

sandboxR: filtering "malicious" calls

Preface

This POC R package tries to filter "malicious" calls in R expressions based on a blacklist to let shared R instances be safe from file and system calls.

If you are not the kind of person who likes to read much in the morning about a $(n+1)^{th}$ R package's theory and background, then please strike out for testdriving the package in a browser and try to hack my system with some guidance (see below)!

Please note that I am aware of Apparmor, SELinux, Tomoyo Linux and other Mandatory Access Control based filters and this package does not intend to be used instead of those implementations!

BTW you should really checkout @jeroenooms's RAppArmor package to fine-tune your Apparmor rules even inside a function. A POC example of that latter can be found in pander's RAppArmor branch.

But there are some situations when a MAC based, kernel-level (mostly path based) filter cannot secure a system from a point of view. Just think of logs and other commonly writable files, not to mention the executable/memory mappable libraries. For example you might create a web application with the really great tool of @Jeff (RApache) or @Jeroen's similarly handy Opencpu and would leave the tempdir system-wide writable to store generated images, uploaded files etc. Or you just want to forbid your users updating options or using some RCurl calls.

Questions, motivations behind this package

Is it a good practice to set some MAC based filter not to allow users to reach other files on the server besides e.g. /tmp? Would not the users mess up each others files on purpose or by chance?

Are you sure some executable files in lib would not harm your system somehow?

How do you know what kind of diabolic actions could happen to your server by installing some random package from Github with the help of devtools by some of your users? Of course MAC filter would stop all(most) of the tries, but just imagine if someone would package some nice root exploit :)

Well, this latter is rather sci-fi, but the above questions do stand in some situations. This package is and idea for those, who are interested in such environments.

Guidelines

The main idea for this little package was to behave as a wrapper in web applications - where file and system calls are not needed based on the followings:

Besides these I kept the following guidelines in my head too to make an even stricter sandbox-like environment:

Based on these I compiled a quite long list of functions that should be blacklisted.

The blacklisted functions are checked in the passed R sources:

Apologetics

Bear in mind that this package is still in development and is not (might not ever will be) ready for production!

As being a pre-alpha release you would find too much restrictions in this approach ATM, as for example the following functions are also blacklisted (for simplicity - later will be enabled for sure):

For a detailed workflow plan, please check out my TODO file!

Also as I am not sure in this package's success, only base packages (base, utils, methods, stats, graphics and grDevices) are addressed.

Testdrive!

Anyway, please feel free to try and test a live (simple) web application which was build to test sandboxR!

There I would ask you to your best at trying to hack the server, like:

Please do send me feedback if you'd succeed or you are tired of the too sharp restrictions!

Frequently asked questions

Please see in dedicated file (FAQ.md).

License

In short: this pseudo-package is licensed under AGPL.

More about this (and if I would misinterpret AGPL than this applies): please feel free to copy, use or modify/extend the sources for any open-sourced project. But: nor the sources, nor my simple ideas expressed on this site are allowed to use without my permission in any application which does not let users download its sources :)

Special thanks

I would like to express my gratitude towards:

githalytics.com alpha



Rapporter/sandboxR documentation built on May 9, 2019, 9:21 a.m.