<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[288152] branches/safari-613.1.12.1-branch</title>
</head>
<body>

<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.webkit.org/projects/webkit/changeset/288152">288152</a></dd>
<dt>Author</dt> <dd>repstein@apple.com</dd>
<dt>Date</dt> <dd>2022-01-18 14:39:46 -0800 (Tue, 18 Jan 2022)</dd>
</dl>

<h3>Log Message</h3>
<pre>Cherry-pick <a href="http://trac.webkit.org/projects/webkit/changeset/288078">r288078</a>. rdar://problem/87736072

    database names leak cross-origin within the same browser session
    https://bugs.webkit.org/show_bug.cgi?id=233548

    Reviewed by Geoff Garen.

    Source/WebCore:

    Test: http/tests/security/getdatabases-crossorigin.html

    * Modules/indexeddb/server/IDBServer.cpp:
    (WebCore::IDBServer::IDBServer::getAllDatabaseNamesAndVersions): When iterating the set of all open
      UniqueIDBDatabases, only add them to the results list if their origins match.

    * page/ClientOrigin.h:
    (WebCore::ClientOrigin::operator!= const):

    LayoutTests:

    * http/tests/security/getdatabases-crossorigin-expected.txt: Added.
    * http/tests/security/getdatabases-crossorigin.html: Added.
    * http/tests/security/resources/getdatabases-otherframe.html: Added.
    * http/tests/security/resources/getdatabases-otherwindow.html: Added.

    git-svn-id: https://svn.webkit.org/repository/webkit/trunk@288078 268f45cc-cd09-0410-ab3c-d52691b4dbfc</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#branchessafari6131121branchLayoutTestsChangeLog">branches/safari-613.1.12.1-branch/LayoutTests/ChangeLog</a></li>
<li><a href="#branchessafari6131121branchSourceWebCoreChangeLog">branches/safari-613.1.12.1-branch/Source/WebCore/ChangeLog</a></li>
<li><a href="#branchessafari6131121branchSourceWebCoreModulesindexeddbserverIDBServercpp">branches/safari-613.1.12.1-branch/Source/WebCore/Modules/indexeddb/server/IDBServer.cpp</a></li>
<li><a href="#branchessafari6131121branchSourceWebCorepageClientOriginh">branches/safari-613.1.12.1-branch/Source/WebCore/page/ClientOrigin.h</a></li>
</ul>

<h3>Added Paths</h3>
<ul>
<li><a href="#branchessafari6131121branchLayoutTestshttptestssecuritygetdatabasescrossoriginexpectedtxt">branches/safari-613.1.12.1-branch/LayoutTests/http/tests/security/getdatabases-crossorigin-expected.txt</a></li>
<li><a href="#branchessafari6131121branchLayoutTestshttptestssecuritygetdatabasescrossoriginhtml">branches/safari-613.1.12.1-branch/LayoutTests/http/tests/security/getdatabases-crossorigin.html</a></li>
<li><a href="#branchessafari6131121branchLayoutTestshttptestssecurityresourcesgetdatabasesotherframehtml">branches/safari-613.1.12.1-branch/LayoutTests/http/tests/security/resources/getdatabases-otherframe.html</a></li>
<li><a href="#branchessafari6131121branchLayoutTestshttptestssecurityresourcesgetdatabasesotherwindowhtml">branches/safari-613.1.12.1-branch/LayoutTests/http/tests/security/resources/getdatabases-otherwindow.html</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="branchessafari6131121branchLayoutTestsChangeLog"></a>
<div class="modfile"><h4>Modified: branches/safari-613.1.12.1-branch/LayoutTests/ChangeLog (288151 => 288152)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-613.1.12.1-branch/LayoutTests/ChangeLog  2022-01-18 22:38:47 UTC (rev 288151)
+++ branches/safari-613.1.12.1-branch/LayoutTests/ChangeLog     2022-01-18 22:39:46 UTC (rev 288152)
</span><span class="lines">@@ -1,3 +1,45 @@
</span><ins>+2022-01-18  Russell Epstein  <repstein@apple.com>
+
+        Cherry-pick r288078. rdar://problem/87736072
+
+    database names leak cross-origin within the same browser session
+    https://bugs.webkit.org/show_bug.cgi?id=233548
+    
+    Reviewed by Geoff Garen.
+    
+    Source/WebCore:
+    
+    Test: http/tests/security/getdatabases-crossorigin.html
+    
+    * Modules/indexeddb/server/IDBServer.cpp:
+    (WebCore::IDBServer::IDBServer::getAllDatabaseNamesAndVersions): When iterating the set of all open
+      UniqueIDBDatabases, only add them to the results list if their origins match.
+    
+    * page/ClientOrigin.h:
+    (WebCore::ClientOrigin::operator!= const):
+    
+    LayoutTests:
+    
+    * http/tests/security/getdatabases-crossorigin-expected.txt: Added.
+    * http/tests/security/getdatabases-crossorigin.html: Added.
+    * http/tests/security/resources/getdatabases-otherframe.html: Added.
+    * http/tests/security/resources/getdatabases-otherwindow.html: Added.
+    
+    
+    git-svn-id: https://svn.webkit.org/repository/webkit/trunk@288078 268f45cc-cd09-0410-ab3c-d52691b4dbfc
+
+    2022-01-16  Brady Eidson  <beidson@apple.com>
+
+            database names leak cross-origin within the same browser session
+            https://bugs.webkit.org/show_bug.cgi?id=233548
+
+            Reviewed by Geoff Garen.
+
+            * http/tests/security/getdatabases-crossorigin-expected.txt: Added.
+            * http/tests/security/getdatabases-crossorigin.html: Added.
+            * http/tests/security/resources/getdatabases-otherframe.html: Added.
+            * http/tests/security/resources/getdatabases-otherwindow.html: Added.
+
</ins><span class="cx"> 2022-01-06  Russell Epstein  <repstein@apple.com>
</span><span class="cx"> 
</span><span class="cx">         Cherry-pick r287417. rdar://problem/86841302
</span></span></pre></div>
<a id="branchessafari6131121branchLayoutTestshttptestssecuritygetdatabasescrossoriginexpectedtxt"></a>
<div class="addfile"><h4>Added: branches/safari-613.1.12.1-branch/LayoutTests/http/tests/security/getdatabases-crossorigin-expected.txt (0 => 288152)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-613.1.12.1-branch/LayoutTests/http/tests/security/getdatabases-crossorigin-expected.txt                          (rev 0)
+++ branches/safari-613.1.12.1-branch/LayoutTests/http/tests/security/getdatabases-crossorigin-expected.txt     2022-01-18 22:39:46 UTC (rev 288152)
</span><span class="lines">@@ -0,0 +1,4 @@
</span><ins>+CONSOLE MESSAGE: Message received from other context
+CONSOLE MESSAGE: Message received from other context
+CONSOLE MESSAGE: PASS
+
</ins></span></pre></div>
<a id="branchessafari6131121branchLayoutTestshttptestssecuritygetdatabasescrossoriginhtml"></a>
<div class="addfile"><h4>Added: branches/safari-613.1.12.1-branch/LayoutTests/http/tests/security/getdatabases-crossorigin.html (0 => 288152)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-613.1.12.1-branch/LayoutTests/http/tests/security/getdatabases-crossorigin.html                          (rev 0)
+++ branches/safari-613.1.12.1-branch/LayoutTests/http/tests/security/getdatabases-crossorigin.html     2022-01-18 22:39:46 UTC (rev 288152)
</span><span class="lines">@@ -0,0 +1,43 @@
</span><ins>+<!-- webkit-test-runner [ JavaScriptCanOpenWindowsAutomatically=true ] -->
+<html>
+<head>
+<script>
+
+if (window.location.hostname == "localhost")
+    console.log("FAIL: Must be run as 127.0.0.1, not localhost");
+    
+if (window.testRunner) {
+    testRunner.dumpAsText();
+    testRunner.waitUntilDone();
+}
+
+var messagesReceived = 0;
+
+window.onmessage = function(event) {
+    console.log("Message received from other context")
+    
+    if (++messagesReceived < 2)
+        return;
+
+    indexedDB.databases().then((result) => {
+        databases = result;
+        if (databases.length != 0)
+            console.log("FAIL: There are " + databases.length + " database(s) when there should be 0");
+        else
+            console.log("PASS");
+        if (testRunner)
+            testRunner.notifyDone();
+    });
+};
+
+function openOtherWindow()
+{
+    window.open("http://localhost:8000/security/resources/getdatabases-otherwindow.html")
+}
+
+</script>
+</head>
+<body onload="openOtherWindow()">
+<iframe src="http://localhost:8000/security/resources/getdatabases-otherframe.html"></iframe>
+</body>
+</html>
</ins><span class="cx">\ No newline at end of file
</span></span></pre></div>
<a id="branchessafari6131121branchLayoutTestshttptestssecurityresourcesgetdatabasesotherframehtml"></a>
<div class="addfile"><h4>Added: branches/safari-613.1.12.1-branch/LayoutTests/http/tests/security/resources/getdatabases-otherframe.html (0 => 288152)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-613.1.12.1-branch/LayoutTests/http/tests/security/resources/getdatabases-otherframe.html                         (rev 0)
+++ branches/safari-613.1.12.1-branch/LayoutTests/http/tests/security/resources/getdatabases-otherframe.html    2022-01-18 22:39:46 UTC (rev 288152)
</span><span class="lines">@@ -0,0 +1,9 @@
</span><ins>+<head>
+<script>
+indexedDB.deleteDatabase('getdatabase-otherframe').onsuccess = () => {
+    indexedDB.open('getdatabase-otherframe').onsuccess = () => {
+        window.parent.postMessage("Hi there!", "*");
+    }        
+}
+</script>
+</head>
</ins></span></pre></div>
<a id="branchessafari6131121branchLayoutTestshttptestssecurityresourcesgetdatabasesotherwindowhtml"></a>
<div class="addfile"><h4>Added: branches/safari-613.1.12.1-branch/LayoutTests/http/tests/security/resources/getdatabases-otherwindow.html (0 => 288152)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-613.1.12.1-branch/LayoutTests/http/tests/security/resources/getdatabases-otherwindow.html                                (rev 0)
+++ branches/safari-613.1.12.1-branch/LayoutTests/http/tests/security/resources/getdatabases-otherwindow.html   2022-01-18 22:39:46 UTC (rev 288152)
</span><span class="lines">@@ -0,0 +1,9 @@
</span><ins>+<head>
+<script>
+indexedDB.deleteDatabase('getdatabase-otherwindow').onsuccess = () => {
+    indexedDB.open('getdatabase-otherwindow').onsuccess = () => {
+        window.opener.postMessage("Hi there!", "*");
+    }        
+}
+</script>
+</head>
</ins></span></pre></div>
<a id="branchessafari6131121branchSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: branches/safari-613.1.12.1-branch/Source/WebCore/ChangeLog (288151 => 288152)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-613.1.12.1-branch/Source/WebCore/ChangeLog       2022-01-18 22:38:47 UTC (rev 288151)
+++ branches/safari-613.1.12.1-branch/Source/WebCore/ChangeLog  2022-01-18 22:39:46 UTC (rev 288152)
</span><span class="lines">@@ -1,3 +1,49 @@
</span><ins>+2022-01-18  Russell Epstein  <repstein@apple.com>
+
+        Cherry-pick r288078. rdar://problem/87736072
+
+    database names leak cross-origin within the same browser session
+    https://bugs.webkit.org/show_bug.cgi?id=233548
+    
+    Reviewed by Geoff Garen.
+    
+    Source/WebCore:
+    
+    Test: http/tests/security/getdatabases-crossorigin.html
+    
+    * Modules/indexeddb/server/IDBServer.cpp:
+    (WebCore::IDBServer::IDBServer::getAllDatabaseNamesAndVersions): When iterating the set of all open
+      UniqueIDBDatabases, only add them to the results list if their origins match.
+    
+    * page/ClientOrigin.h:
+    (WebCore::ClientOrigin::operator!= const):
+    
+    LayoutTests:
+    
+    * http/tests/security/getdatabases-crossorigin-expected.txt: Added.
+    * http/tests/security/getdatabases-crossorigin.html: Added.
+    * http/tests/security/resources/getdatabases-otherframe.html: Added.
+    * http/tests/security/resources/getdatabases-otherwindow.html: Added.
+    
+    
+    git-svn-id: https://svn.webkit.org/repository/webkit/trunk@288078 268f45cc-cd09-0410-ab3c-d52691b4dbfc
+
+    2022-01-16  Brady Eidson  <beidson@apple.com>
+
+            database names leak cross-origin within the same browser session
+            https://bugs.webkit.org/show_bug.cgi?id=233548
+
+            Reviewed by Geoff Garen.
+
+            Test: http/tests/security/getdatabases-crossorigin.html
+
+            * Modules/indexeddb/server/IDBServer.cpp:
+            (WebCore::IDBServer::IDBServer::getAllDatabaseNamesAndVersions): When iterating the set of all open
+              UniqueIDBDatabases, only add them to the results list if their origins match.
+
+            * page/ClientOrigin.h:
+            (WebCore::ClientOrigin::operator!= const):
+
</ins><span class="cx"> 2022-01-06  Russell Epstein  <repstein@apple.com>
</span><span class="cx"> 
</span><span class="cx">         Cherry-pick r287417. rdar://problem/86841302
</span></span></pre></div>
<a id="branchessafari6131121branchSourceWebCoreModulesindexeddbserverIDBServercpp"></a>
<div class="modfile"><h4>Modified: branches/safari-613.1.12.1-branch/Source/WebCore/Modules/indexeddb/server/IDBServer.cpp (288151 => 288152)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-613.1.12.1-branch/Source/WebCore/Modules/indexeddb/server/IDBServer.cpp  2022-01-18 22:38:47 UTC (rev 288151)
+++ branches/safari-613.1.12.1-branch/Source/WebCore/Modules/indexeddb/server/IDBServer.cpp     2022-01-18 22:39:46 UTC (rev 288152)
</span><span class="lines">@@ -530,6 +530,9 @@
</span><span class="cx">     HashSet<String> visitedDatabasePaths;
</span><span class="cx"> 
</span><span class="cx">     for (auto& database : m_uniqueIDBDatabaseMap.values()) {
</span><ins>+        if (database->identifier().origin() != origin)
+            continue;
+
</ins><span class="cx">         auto path = database->filePath();
</span><span class="cx">         if (!path.isEmpty())
</span><span class="cx">             visitedDatabasePaths.add(path);
</span></span></pre></div>
<a id="branchessafari6131121branchSourceWebCorepageClientOriginh"></a>
<div class="modfile"><h4>Modified: branches/safari-613.1.12.1-branch/Source/WebCore/page/ClientOrigin.h (288151 => 288152)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-613.1.12.1-branch/Source/WebCore/page/ClientOrigin.h     2022-01-18 22:38:47 UTC (rev 288151)
+++ branches/safari-613.1.12.1-branch/Source/WebCore/page/ClientOrigin.h        2022-01-18 22:39:46 UTC (rev 288152)
</span><span class="lines">@@ -37,6 +37,7 @@
</span><span class="cx"> 
</span><span class="cx">     unsigned hash() const;
</span><span class="cx">     bool operator==(const ClientOrigin&) const;
</span><ins>+    bool operator!=(const ClientOrigin& other) const { return !(*this == other); }
</ins><span class="cx"> 
</span><span class="cx">     template<class Encoder> void encode(Encoder&) const;
</span><span class="cx">     template<class Decoder> static std::optional<ClientOrigin> decode(Decoder&);
</span></span></pre>
</div>
</div>

</body>
</html>