Skip to content

Commit

Permalink
[Hotfix] Fix arbitrary file readvulnerability on mysql jdbc
Browse files Browse the repository at this point in the history
  • Loading branch information
hailin0 authored Jun 12, 2024
1 parent 4a37ebf commit fd93ddb
Showing 1 changed file with 9 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Properties;
import java.util.function.Function;
import java.util.stream.Collectors;

Expand Down Expand Up @@ -187,11 +188,15 @@ private Connection getConnection(Map<String, String> requestParams, String datab
String url =
JdbcUtils.replaceDatabase(
requestParams.get(MysqlOptionRule.URL.key()), databaseName);

Properties info = new java.util.Properties();
info.put("autoDeserialize", "false");
info.put("allowLoadLocalInfile", "false");
info.put("allowLoadLocalInfileInPath", "");
if (requestParams.containsKey(MysqlOptionRule.USER.key())) {
String username = requestParams.get(MysqlOptionRule.USER.key());
String password = requestParams.get(MysqlOptionRule.PASSWORD.key());
return DriverManager.getConnection(url, username, password);
info.put("user", requestParams.get(MysqlOptionRule.USER.key()));
info.put("password", requestParams.get(MysqlOptionRule.PASSWORD.key()));
}
return DriverManager.getConnection(url);
return DriverManager.getConnection(url, info);
}
}

0 comments on commit fd93ddb

Please sign in to comment.