Ticket #8 (new defect)
Security flaw in Sandbox.safe when using box.ref
| Reported by: | senotrusov | Owned by: | somebody |
|---|---|---|---|
| Priority: | major | Milestone: | |
| Component: | component1 | Version: | |
| Keywords: | Cc: |
Description
It is possible for sandbox to execute some code in a wild by modifying classes which is accessed via box.ref facility.
This can be done via:
- defining new class/instance methods is referenced classes;
- defining new singleton class/instance methods is referenced classes;
- using class_eval/instance_eval/module_eval
- and maybe with otherwise trick?
Possible workaround is to:
- disable class instantiation by raising exception in a initialize method;
1a. (not tested) freeze instantiated object in the initialize method;
- extend referenced class in the sandbox (not in the wild) with a following class methods: dup, clone, class_eval, instance_eval, module_eval - which all must raise some exception;
- freeze referenced class in the sandbox (not in the wild).
I've attach a test script for this workaround. It test SandboxDataGateway? object for possible code execution. If you comment "box.do_workaround" call and SandboxDataGateway::initialize, you will see code like
SandboxDataGateway.new.instance_eval "puts `whoami`"
can be executed from the sandbox, giving access to 'system' call and stdout.
I am not sure - is it cover all security holes or not. Maybe I am not noticed something?
It would be great if why would fix it at some deeper level - in the sandbox C internals or so.
- ruby 1.8.6 (2007-03-13 patchlevel 0)
- patch for Ruby 1.8.6 from InstallingTheSandbox
- sandbox-0.4.tgz from InstallingTheSandbox
