I have the following Ruby code:
Testcase.rb:
filename = "/absolute/path/to/Untrusted.rb"
thread = Thread.new do
$SAFE = 4
Kernel::load(filename, true)
end
thread.join
Untrusted.rb
#Untrusted code
puts "Untrusted!"
However, I get an error when I try to run Testcase.rb:
/Volumes/Data/Users/mike/Desktop/Testcase.rb:4:in `write': Insecure operation `write' at level 4 (SecurityError)
from /Volumes/Data/Users/mike/Desktop/Testcase.rb:7:in `join'
from /Volumes/Data/Users/mike/Desktop/Testcase.rb:7
Removing $SAFE=4
solves the issue, but I want to be able to safely run untrusted code. Any ideas about why this isn't working?