Fixed: Prevent arbitary file write using webtools/control/EntitySQLProcessor. (OFBIZ-12057)

Shuibo Ye <shuiboye@gmail.com> 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
This commit is contained in:
Jacques Le Roux
2020-11-16 14:08:53 +01:00
parent 0b26b9155f
commit 792f45773f
@@ -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."