Fixed: Groovy Program sandbox bypass (OFBIZ-12305)
This much increases the current security by creating SecuredUpload::isValidText and call it from ProgramExport.groovy This said I agree with thiscodecc that a better solution would be to use a Groovy sandbox, and not only in ProgramExport.groovy. I had a quick glance at a such solution. Unfortunately as Cédric Champeau reports at https://melix.github.io/blog/2015/03/sandboxing.html and unlike thiscodecc suggest there are no "mature solutions on the market". Nevertheless I'll have a deeper look at an OFBiz specific Groovy sandbox solution. Somehow related: I'll also soon extract the list of words used in SecuredUpload::isValidText in a deniedWebShellWords property in security.properties Thanks: thiscodecc for report Conflicts handled by hand framework/webtools/groovyScripts/entity/ProgramExport.groovy
This commit is contained in:
@@ -20,6 +20,7 @@ import org.apache.ofbiz.entity.Delegator
|
||||
import org.apache.ofbiz.entity.GenericValue
|
||||
import org.apache.ofbiz.entity.model.ModelEntity
|
||||
import org.apache.ofbiz.base.util.*
|
||||
|
||||
import org.w3c.dom.Document
|
||||
|
||||
import org.codehaus.groovy.control.customizers.ImportCustomizer
|
||||
@@ -31,8 +32,7 @@ String groovyProgram = null
|
||||
recordValues = []
|
||||
errMsgList = []
|
||||
|
||||
if (UtilValidate.isEmpty(parameters.groovyProgram)) {
|
||||
|
||||
if (!parameters.groovyProgram) {
|
||||
groovyProgram = '''
|
||||
// Use the List variable recordValues to fill it with GenericValue maps.
|
||||
// full groovy syntaxt is available
|
||||
@@ -73,10 +73,7 @@ def shell = new GroovyShell(loader, binding, configuration)
|
||||
|
||||
if (UtilValidate.isNotEmpty(groovyProgram)) {
|
||||
try {
|
||||
// TODO more can be added...
|
||||
if (groovyProgram.contains("new File")
|
||||
|| groovyProgram.contains(".jsp")
|
||||
|| groovyProgram.contains("<%=")) {
|
||||
if (!org.apache.ofbiz.security.SecuredUpload.isValidText(groovyProgram,["import"])) {
|
||||
request.setAttribute("_ERROR_MESSAGE_", "Not executed for security reason")
|
||||
return
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user