Skip to content

Commit

Permalink
[ZEPPELIN-3725] Fix SQL injection
Browse files Browse the repository at this point in the history
  • Loading branch information
Khanh committed Oct 15, 2023
1 parent b9cb004 commit 2a908bd
Showing 1 changed file with 3 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -434,7 +434,7 @@ private List<String> getUserList(JdbcRealm obj) {
return userlist;
}

userquery = String.format("SELECT %s FROM %s", username, tablename);
userquery = String.format("SELECT ? FROM ?", username, tablename);
} catch (IllegalAccessException e) {
LOGGER.error("Error while accessing dataSource for JDBC Realm", e);
return new ArrayList<>();
Expand All @@ -443,6 +443,8 @@ private List<String> getUserList(JdbcRealm obj) {
try {
con = dataSource.getConnection();
ps = con.prepareStatement(userquery);
ps.setString(1, username);
ps.setString(2, tablename);
rs = ps.executeQuery();
while (rs.next()) {
userlist.add(rs.getString(1).trim());
Expand Down

0 comments on commit 2a908bd

Please sign in to comment.