From 792f45773fd062fe1f57f5b1af9da9e65637ec54 Mon Sep 17 00:00:00 2001 From: Jacques Le Roux Date: Mon, 16 Nov 2020 14:07:58 +0100 Subject: [PATCH] Fixed: Prevent arbitary file write using webtools/control/EntitySQLProcessor. (OFBIZ-12057) Shuibo Ye reported a possible arbitary file write using webtools/control/EntitySQLProcessor. In the "SQL Command" part, I create a table and insert some strings and export the table to a file one sentence at a time. PoC: CREATE TABLE "test" (string VARCHAR(80)) INSERT INTO "test" (string) VALUES ('<%= system.getProperty("user.dir") %>') call SYSCS_UTIL.SYSCS_EXPORT_TABLE(null,'test','.\framework\webtools\webapp\webtools\default.jsp',null,'*',null) After executing the three sentences,I successfully write the file and its url is https://localhost:8443/webtools/default.jsp. I fixed it preventing execution on SYSCS_UTIL.SYSCS_EXPORT_TABLE and JSP, more could be added if necessary --- .../groovyScripts/entity/EntitySQLProcessor.groovy | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/framework/webtools/groovyScripts/entity/EntitySQLProcessor.groovy b/framework/webtools/groovyScripts/entity/EntitySQLProcessor.groovy index c85fed2902..b5259b74f8 100644 --- a/framework/webtools/groovyScripts/entity/EntitySQLProcessor.groovy +++ b/framework/webtools/groovyScripts/entity/EntitySQLProcessor.groovy @@ -64,6 +64,15 @@ if (sqlCommand && selGroup) { rs.close() } } else { + if (sqlCommand.toUpperCase().contains("SYSCS_UTIL.SYSCS_EXPORT_TABLE") + || sqlCommand.toUpperCase().contains("JSP")) { + context.resultMessage = "Not executed for security reason" + context.groups = groups + context.columns = columns + context.records = records + context.sqlCommand = sqlCommand + return + } du.prepareStatement(sqlCommand) numOfAffectedRows = du.executeUpdate() resultMessage = "Affected $numOfAffectedRows rows."