Reducing $SAFE
drbrain |
Ya you are correct, it won't let you change the safe level. I wonder how hard it would be to bypass it though using something like rubyinline?
—Re: $SAFE =4 safe enough? via snacktime
require 'rubygems'
require 'inline'
class DeSafe
inline do |builder|
builder.prefix "RUBY_EXTERN int ruby_safe_level;"
builder.c <<-EOC
static void
reduce() {
ruby_safe_level = 0;
}
EOC
end
end
$SAFE = ARGV.shift.to_i rescue 0
p $SAFE
DeSafe.new.reduce
p $SAFE
$ rm -fr ~/.ruby_inline/; ruby desafe.rb 4
desafe.rb:20:in `write': Insecure operation `write' at level 4 (SecurityError)
from desafe.rb:20:in `p'
from desafe.rb:20
$ rm -fr ~/.ruby_inline/; ruby desafe.rb 3
3
0
comments
Comments 
Daniel Berger said about 2 hours later
Eric Hodel said about 5 hours later
James Mead said 1 day later
Eric Hodel said 2 days later
Comments are disabled

