Преглед изворни кода

LibWeb: Prevent http:// URLs loading scripts sourced from file:// URLs

Fixes #1616
Brendan Coles пре 5 година
родитељ
комит
6b0f47683c
1 измењених фајлова са 6 додато и 1 уклоњено
  1. 6 1
      Libraries/LibWeb/DOM/HTMLScriptElement.cpp

+ 6 - 1
Libraries/LibWeb/DOM/HTMLScriptElement.cpp

@@ -71,8 +71,13 @@ void HTMLScriptElement::inserted_into(Node& new_parent)
     if (src.is_null())
     if (src.is_null())
         return;
         return;
 
 
-    String source;
     URL src_url = document().complete_url(src);
     URL src_url = document().complete_url(src);
+    if (src_url.protocol() == "file" && document().url().protocol() != src_url.protocol()) {
+        dbg() << "HTMLScriptElement: Forbidden to load " << src_url.to_string() << " from " << document().url().to_string();
+        return;
+    }
+
+    String source;
     ResourceLoader::the().load_sync(src_url, [&](auto& data) {
     ResourceLoader::the().load_sync(src_url, [&](auto& data) {
         if (data.is_null()) {
         if (data.is_null()) {
             dbg() << "HTMLScriptElement: Failed to load " << src;
             dbg() << "HTMLScriptElement: Failed to load " << src;