What does `evaluate` or `GroovyShell` inside a pipeline mean for security?
AdvancedConceptScripted pipeline, Groovy & CPS
Answer
Arbitrary Groovy evaluation in an unsandboxed context (a trusted library, or an admin-approved script) runs with full controller privileges: it can read Jenkins.instance, decrypt credentials, and modify configuration. In a sandboxed Jenkinsfile, such calls are blocked and require script approval. Admins should never approve signatures like staticMethod org.codehaus.groovy.runtime.DefaultGroovyMethods execute java.lang.String or new groovy.lang.GroovyShell, because they turn any Jenkinsfile author into a controller admin.
More on Scripted pipeline, Groovy & CPS
What does a scripted pipeline look like and when would you still write one?IntermediateWhat is CPS and why does Jenkins transform pipeline Groovy?AdvancedWhy does `java.io.NotSerializableException` happen in pipelines?AdvancedWhat does `@NonCPS` do and what are its rules?AdvancedWhy do some Groovy closures behave unexpectedly in pipelines, for example `list.each { }` or `sort`?AdvancedWhat is the `script` block in declarative, and what are its limits?Beginner