From: rcoder Date: 2005-12-08T12:07:35+09:00 Subject: Re: code execution from file? There are a number of mechanisms to "lock down" the execution for a chunk of Ruby code, the most common being the built-in $SAFE global variable. Unfortunately, due to a number of recently-published vulnerabilities in the implementation of the $SAFE checks, it's generally not considered a good way to insure that your application will be protected from malignant users. The best example I've seen to date of a truly safe Ruby interpreter has to be why the lucky stiff's "Try Ruby" website (http://tryruby.hobix.com/), which lets anyone interact with a restricted IRb prompt via their browser and some slick Javascript. You might email why_ directly, and see if he'd be willing to share some tips with you (and the rest of us!). At a bare minimum, you need to make sure the following built-in classes and modules are either entirely hidden, or redefined to "safe" versions: Dir File FileStat FileUtils IO (at least methods like 'popen', 'fcntl', etc.) ObjectSpace Pathname Process GzipFile Kernel ('fork', 'at_exit', 'caller', 'load', 'require', many more) ....and probaby others, as well. Really, it's a *hard* thing to make arbitrary code execution safe, so unless you can re-use and share effort with others, I'd caution you against doing this unless absolutely necessary. Good luck, Lennon