Skip to content

Commit 7f3bf7e

Browse files
authored
Add urlencode check for jdbc url in SecurityUtils.java and fix password leak in HiveUtils.java (#5261)
1 parent 7dec883 commit 7f3bf7e

File tree

2 files changed

+14
-1
lines changed
  • linkis-commons/linkis-common/src/main/java/org/apache/linkis/common/utils
  • linkis-public-enhancements/linkis-datasource/linkis-metadata/src/main/java/org/apache/linkis/metadata/util

2 files changed

+14
-1
lines changed

linkis-commons/linkis-common/src/main/java/org/apache/linkis/common/utils/SecurityUtils.java

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,19 @@ public static void checkJdbcConnParams(
124124

125125
// 4. Check url security, especially for the possibility of malicious characters appearing on
126126
// the host
127+
try {
128+
while (url.contains("%")) {
129+
String decodedUrl = URLDecoder.decode(url, "UTF-8");
130+
if (decodedUrl.equals(url)) {
131+
// If the decomposition is the same as the original, avoid infinite loop
132+
break;
133+
}
134+
url = decodedUrl;
135+
}
136+
} catch (UnsupportedEncodingException e) {
137+
logger.error("URL decode failed: {}", e.getMessage());
138+
throw new LinkisSecurityException(35001, "URL decode failed.");
139+
}
127140
checkUrlIsSafe(url);
128141
}
129142

linkis-public-enhancements/linkis-datasource/linkis-metadata/src/main/java/org/apache/linkis/metadata/util/HiveUtils.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ public static String decode(String str) {
4949
try {
5050
res = new String(decoder.decode(str));
5151
} catch (Throwable e) {
52-
logger.error(str + " decode failed", e);
52+
logger.error("decode failed", e);
5353
}
5454
return res;
5555
}

0 commit comments

Comments
 (0)