@@ -153,6 +153,14 @@ public class JDBCInterpreter extends KerberosInterpreter {
153
153
"KerberosConfigPath" , "KerberosKeytabPath" , "KerberosCredentialCachePath" ,
154
154
"extraCredentials" , "roles" , "sessionProperties" ));
155
155
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
+
156
164
// database --> Properties
157
165
private final HashMap <String , Properties > basePropertiesMap ;
158
166
// username --> User Configuration
@@ -533,6 +541,7 @@ public Connection getConnection(InterpreterContext context)
533
541
String url = properties .getProperty (URL_KEY );
534
542
url = appendProxyUserToURL (url , user );
535
543
String connectionUrl = appendTagsToURL (url , context );
544
+ validateConnectionUrl (connectionUrl );
536
545
537
546
String authType = getProperty ("zeppelin.jdbc.auth.type" , "SIMPLE" )
538
547
.trim ().toUpperCase ();
@@ -576,6 +585,15 @@ public Connection getConnection(InterpreterContext context)
576
585
return connection ;
577
586
}
578
587
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
+
579
597
private String appendProxyUserToURL (String url , String user ) {
580
598
StringBuilder connectionUrl = new StringBuilder (url );
581
599
@@ -749,6 +767,9 @@ private InterpreterResult executeSql(String sql,
749
767
750
768
try {
751
769
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" );
752
773
} catch (Exception e ) {
753
774
LOGGER .error ("Fail to getConnection" , e );
754
775
try {
@@ -763,7 +784,7 @@ private InterpreterResult executeSql(String sql,
763
784
}
764
785
}
765
786
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." );
767
788
}
768
789
769
790
try {
0 commit comments