Add enum.valueOf signature to the whitelist#493
Add enum.valueOf signature to the whitelist#493dasanjan1296 wants to merge 2 commits intojenkinsci:masterfrom
Conversation
There was a problem hiding this comment.
Someone needs to think about enum behavior in the sandbox more generally before approving this. Currently each individual enum value must be approved, see for example:
This PR would effectively allow access to all enum values in the JVM. Is that a security issue? Does it make it easier to exploit other issues? I am not sure.
Personally, I would start with trying to special-case this method in SandboxInterceptor for enum classes defined in sandboxed scripts (always safe) rather than allowing it generally.
If after considering enum behavior in general, we decide that allowing access to everything is fine, then in addition to allowing Enum.valueOf we should modify SandboxInterceptor so that direct access to enum fields is always allowed and all existing enum values in generic-whitelist can be removed. There are also various special cases in groovy-sandbox related to casting that I think should be removed at the same time if that change was made.
See also some related discussion in JENKINS-71056.
This will whitelist the enum.valueOf signature. Currently, I'm having to use a workaround as follows:
instead of a simple: