@@ -153,6 +153,14 @@ public class JDBCInterpreter extends KerberosInterpreter {
153153 "KerberosConfigPath" , "KerberosKeytabPath" , "KerberosCredentialCachePath" ,
154154 "extraCredentials" , "roles" , "sessionProperties" ));
155155
156+ private static final String ALLOW_LOAD_LOCAL_IN_FILE_NAME = "allowLoadLocalInfile" ;
157+
158+ private static final String AUTO_DESERIALIZE = "autoDeserialize" ;
159+
160+ private static final String ALLOW_LOCAL_IN_FILE_NAME = "allowLocalInfile" ;
161+
162+ private static final String ALLOW_URL_IN_LOCAL_IN_FILE_NAME = "allowUrlInLocalInfile" ;
163+
156164 // database --> Properties
157165 private final HashMap <String , Properties > basePropertiesMap ;
158166 // username --> User Configuration
@@ -533,6 +541,7 @@ public Connection getConnection(InterpreterContext context)
533541 String url = properties .getProperty (URL_KEY );
534542 url = appendProxyUserToURL (url , user );
535543 String connectionUrl = appendTagsToURL (url , context );
544+ validateConnectionUrl (connectionUrl );
536545
537546 String authType = getProperty ("zeppelin.jdbc.auth.type" , "SIMPLE" )
538547 .trim ().toUpperCase ();
@@ -576,6 +585,15 @@ public Connection getConnection(InterpreterContext context)
576585 return connection ;
577586 }
578587
588+ private void validateConnectionUrl (String url ) {
589+ if (containsIgnoreCase (url , ALLOW_LOAD_LOCAL_IN_FILE_NAME ) ||
590+ containsIgnoreCase (url , AUTO_DESERIALIZE ) ||
591+ containsIgnoreCase (url , ALLOW_LOCAL_IN_FILE_NAME ) ||
592+ containsIgnoreCase (url , ALLOW_URL_IN_LOCAL_IN_FILE_NAME )) {
593+ throw new IllegalArgumentException ("Connection URL contains sensitive configuration" );
594+ }
595+ }
596+
579597 private String appendProxyUserToURL (String url , String user ) {
580598 StringBuilder connectionUrl = new StringBuilder (url );
581599
@@ -749,6 +767,9 @@ private InterpreterResult executeSql(String sql,
749767
750768 try {
751769 connection = getConnection (context );
770+ } catch (IllegalArgumentException e ) {
771+ LOGGER .error ("Cannot run " + sql , e );
772+ return new InterpreterResult (Code .ERROR , "Connection URL contains improper configuration" );
752773 } catch (Exception e ) {
753774 LOGGER .error ("Fail to getConnection" , e );
754775 try {
@@ -763,7 +784,7 @@ private InterpreterResult executeSql(String sql,
763784 }
764785 }
765786 if (connection == null ) {
766- return new InterpreterResult (Code .ERROR , "User's connectin not found." );
787+ return new InterpreterResult (Code .ERROR , "User's connection not found." );
767788 }
768789
769790 try {
0 commit comments