This is an automated email from the ASF dual-hosted git repository.

pjfanning pushed a commit to branch trunk
in repository https://gitbox.apache.org/repos/asf/poi-xmlbeans.git


The following commit(s) were added to refs/heads/trunk by this push:
     new 74c31495 Reject remote file: authorities in the schema-download gate 
(#103)
74c31495 is described below

commit 74c3149570723e35b6f782a2c7bf5e6c2467eb91
Author: PJ Fanning <[email protected]>
AuthorDate: Mon Aug 31 17:01:22 2026 +0100

    Reject remote file: authorities in the schema-download gate (#103)
    
    StscState.shouldDownloadURI gates schema import/include/redefine
    resolution. Remote http(s) locations are refused when downloads are
    disabled (the default), but any file: URI was accepted regardless of
    the gate and without inspecting the authority. A Windows UNC location
    such as file://attacker.example.com/share/evil.xsd in an untrusted
    schema therefore passed the gate and was fetched by StscImporter
    (new URL(absoluteURL) -> loader.parse), reaching an attacker-controlled
    host over SMB - an SSRF with attacker-controlled host and protocol -
    even though "network downloads disabled" was in effect.
    
    Accept a file: URI only when it has no remote authority (null, empty,
    or localhost). Local file includes, which have no authority, keep
    working; a UNC/remote-host file: URI is now refused like any other
    download.
    
    Co-authored-by: Claude Fable 5 <[email protected]>
---
 .../java/org/apache/xmlbeans/impl/schema/StscState.java    | 14 +++++++++++++-
 1 file changed, 13 insertions(+), 1 deletion(-)

diff --git a/src/main/java/org/apache/xmlbeans/impl/schema/StscState.java 
b/src/main/java/org/apache/xmlbeans/impl/schema/StscState.java
index 0690ec8a..c4f22f09 100644
--- a/src/main/java/org/apache/xmlbeans/impl/schema/StscState.java
+++ b/src/main/java/org/apache/xmlbeans/impl/schema/StscState.java
@@ -438,12 +438,24 @@ public class StscState {
                 int i = s.lastIndexOf('!');
                 return shouldDownloadURI(i > 0 ? s.substring(0, i) : s);
             }
-            return equalsIgnoreCase(uri.getScheme(), "file");
+            return equalsIgnoreCase(uri.getScheme(), "file") && 
isLocalFileAuthority(uri);
         } catch (Exception e) {
             return false;
         }
     }
 
+    /**
+     * True if a file: URI has no remote authority. A file: URI with a 
non-local
+     * host (e.g. a Windows UNC path file://server/share/schema.xsd) would 
otherwise
+     * be fetched even when network downloads are disabled, letting an 
untrusted
+     * schema's import/include reach an attacker-controlled host over SMB.
+     */
+    private static boolean isLocalFileAuthority(URI uri) {
+        String authority = uri.getAuthority();
+        return authority == null || authority.isEmpty() ||
+               authority.equalsIgnoreCase("localhost");
+    }
+
     /**
      * Initializer for compatMap.
      */


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to