diff --git a/lib/SimpleSAML/Utils/XML.php b/lib/SimpleSAML/Utils/XML.php
index 4b6c3cdfbd6b90972359418c3f674e9774564eb2..28c203cd3cf083b04258aa07338b10b1b6733ef3 100644
--- a/lib/SimpleSAML/Utils/XML.php
+++ b/lib/SimpleSAML/Utils/XML.php
@@ -449,6 +449,15 @@ class XML
             $schemaPath = $config->resolvePath('schemas');
             $schemaFile = $schemaPath . '/' . $schema;
 
+            libxml_set_external_entity_loader(
+                function ($public, $system, $context) {
+                    if (filter_var($system, FILTER_VALIDATE_URL) === $system) {
+                        return null;
+                    }
+                    return $system;
+                }
+            );
+
             $res = $dom->schemaValidate($schemaFile);
             if ($res) {
                 Errors::end();