animovscw commented on code in PR #13382:
URL: https://github.com/apache/ignite/pull/13382#discussion_r3646727625
##########
modules/core/src/main/java/org/apache/ignite/internal/util/IgniteUtils.java:
##########
@@ -2558,10 +2566,71 @@ public static boolean mkdirs(File dir) {
public static URL resolveSpringUrl(String springCfgPath) throws
IgniteCheckedException {
A.notNull(springCfgPath, "springCfgPath");
+ String prop =
IgniteSystemProperties.IGNITE_ALLOW_REMOTE_SPRING_CFG_URL;
+
+ // Check always-blocked schemes against the raw string first, since
java.net.URL
+ // does not support ftp/ftps natively and throws MalformedURLException
before
+ // the scheme can be inspected, which would otherwise bypass this
check.
+ String lowerPath = springCfgPath.toLowerCase(Locale.ROOT);
+
+ for (String blockedScheme : ALWAYS_BLOCKED_CFG_SCHEMES) {
+ if (lowerPath.startsWith(blockedScheme + "://"))
+ throw new IgniteCheckedException(
+ "Spring configuration URLs with scheme '" + blockedScheme
+ "' are always blocked " +
+ "due to security risk. Use a local file/classpath
reference instead. " +
+ "For remote HTTP/HTTPS set system property: -D" +
+ prop + "=true."
+ );
+ }
+
URL url;
try {
url = new URL(springCfgPath);
+
+ URL cfgUrl = url;
+
+ String scheme = cfgUrl.getProtocol().toLowerCase(Locale.ROOT);
+
+ // Unwrap jar:<nested_url>!/path (potentially nested) to avoid
bypassing remote-scheme checks.
+ while ("jar".equals(scheme)) {
+ String file = cfgUrl.getFile();
+
+ int sep = file.indexOf("!/");
+
+ if (sep <= 0)
+ break;
+
+ try {
+ cfgUrl = new URL(file.substring(0, sep));
+ scheme = cfgUrl.getProtocol().toLowerCase(Locale.ROOT);
+ }
+ catch (MalformedURLException ignored) {
+ break;
+ }
+ }
+
+ if (REMOTE_CFG_SCHEMES.contains(scheme)) {
+ if (ALWAYS_BLOCKED_CFG_SCHEMES.contains(scheme))
+ throw new IgniteCheckedException(
+ "Spring configuration URLs with scheme '" + scheme +
"' are always blocked " +
+ "due to security risk. Use a local file/classpath
reference instead. " +
+ "For remote HTTP/HTTPS set system property: -D" +
Review Comment:
fixed: d1f781db36e2c191471783d742f57ac6c2630860
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]