One method might be to look into what Groovy offers in controlling script execution via JVM security. Perhaps these links will be helpful:
http://groovy.codehaus.org/Security http://www.chrismoos.com/2010/03/24/groovy-scripts-and-jvm-security/
As an alternative to JVM security there is also this compilation customizer:
http://groovy-sandbox.kohsuke.org/
which would allow you to write filters that will prevent a script from getting reference to objects that they are not supposed to.