<!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>[195192] releases/WebKitGTK/webkit-2.10/Source</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/195192">195192</a></dd>
<dt>Author</dt> <dd>carlosgc@webkit.org</dd>
<dt>Date</dt> <dd>2016-01-18 02:41:04 -0800 (Mon, 18 Jan 2016)</dd>
</dl>
<h3>Log Message</h3>
<pre>Merge <a href="http://trac.webkit.org/projects/webkit/changeset/194323">r194323</a> - [SOUP] Performs DNS prefetch when a proxy is configured (information leak)
https://bugs.webkit.org/show_bug.cgi?id=145542
Reviewed by Darin Adler.
Source/WebCore:
Perform DNS prefetch only when no proxy is configured.
No new tests. Test this manually with Wireshark. Run the simple-proxy example program found
in libsoup's examples directory, set that as your system HTTP proxy, and see if DNS queries
show up in Wireshark when refreshing a page sent over HTTP. They should appear only when the
proxy is not configured.
* platform/network/DNSResolveQueue.cpp:
(WebCore::DNSResolveQueue::DNSResolveQueue):
(WebCore::DNSResolveQueue::isUsingProxy):
* platform/network/DNSResolveQueue.h:
* platform/network/cf/DNSCFNet.cpp:
(WebCore::DNSResolveQueue::updateIsUsingProxy):
(WebCore::DNSResolveQueue::platformProxyIsEnabledInSystemPreferences): Deleted.
* platform/network/soup/DNSSoup.cpp:
(WebCore::didResolveProxy):
(WebCore::proxyResolvedForHttpUriCallback):
(WebCore::proxyResolvedForHttpsUriCallback):
(WebCore::DNSResolveQueue::updateIsUsingProxy):
(WebCore::DNSResolveQueue::platformProxyIsEnabledInSystemPreferences): Deleted.
Source/WTF:
Specialize GUniquePtr<char*>, using g_strfreev.
* wtf/glib/GUniquePtr.h:</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#releasesWebKitGTKwebkit210SourceWTFChangeLog">releases/WebKitGTK/webkit-2.10/Source/WTF/ChangeLog</a></li>
<li><a href="#releasesWebKitGTKwebkit210SourceWTFwtfglibGUniquePtrh">releases/WebKitGTK/webkit-2.10/Source/WTF/wtf/glib/GUniquePtr.h</a></li>
<li><a href="#releasesWebKitGTKwebkit210SourceWebCoreChangeLog">releases/WebKitGTK/webkit-2.10/Source/WebCore/ChangeLog</a></li>
<li><a href="#releasesWebKitGTKwebkit210SourceWebCoreplatformnetworkDNSResolveQueuecpp">releases/WebKitGTK/webkit-2.10/Source/WebCore/platform/network/DNSResolveQueue.cpp</a></li>
<li><a href="#releasesWebKitGTKwebkit210SourceWebCoreplatformnetworkDNSResolveQueueh">releases/WebKitGTK/webkit-2.10/Source/WebCore/platform/network/DNSResolveQueue.h</a></li>
<li><a href="#releasesWebKitGTKwebkit210SourceWebCoreplatformnetworkcfDNSCFNetcpp">releases/WebKitGTK/webkit-2.10/Source/WebCore/platform/network/cf/DNSCFNet.cpp</a></li>
<li><a href="#releasesWebKitGTKwebkit210SourceWebCoreplatformnetworksoupDNSSoupcpp">releases/WebKitGTK/webkit-2.10/Source/WebCore/platform/network/soup/DNSSoup.cpp</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="releasesWebKitGTKwebkit210SourceWTFChangeLog"></a>
<div class="modfile"><h4>Modified: releases/WebKitGTK/webkit-2.10/Source/WTF/ChangeLog (195191 => 195192)</h4>
<pre class="diff"><span>
<span class="info">--- releases/WebKitGTK/webkit-2.10/Source/WTF/ChangeLog        2016-01-18 09:50:09 UTC (rev 195191)
+++ releases/WebKitGTK/webkit-2.10/Source/WTF/ChangeLog        2016-01-18 10:41:04 UTC (rev 195192)
</span><span class="lines">@@ -1,3 +1,14 @@
</span><ins>+2015-12-20 Michael Catanzaro <mcatanzaro@igalia.com>
+
+ [SOUP] Performs DNS prefetch when a proxy is configured (information leak)
+ https://bugs.webkit.org/show_bug.cgi?id=145542
+
+ Reviewed by Darin Adler.
+
+ Specialize GUniquePtr<char*>, using g_strfreev.
+
+ * wtf/glib/GUniquePtr.h:
+
</ins><span class="cx"> 2015-12-14 David Kilzer <ddkilzer@apple.com>
</span><span class="cx">
</span><span class="cx"> REGRESSION (r162777): Remove Boost Software License from WTF
</span></span></pre></div>
<a id="releasesWebKitGTKwebkit210SourceWTFwtfglibGUniquePtrh"></a>
<div class="modfile"><h4>Modified: releases/WebKitGTK/webkit-2.10/Source/WTF/wtf/glib/GUniquePtr.h (195191 => 195192)</h4>
<pre class="diff"><span>
<span class="info">--- releases/WebKitGTK/webkit-2.10/Source/WTF/wtf/glib/GUniquePtr.h        2016-01-18 09:50:09 UTC (rev 195191)
+++ releases/WebKitGTK/webkit-2.10/Source/WTF/wtf/glib/GUniquePtr.h        2016-01-18 10:41:04 UTC (rev 195192)
</span><span class="lines">@@ -43,7 +43,8 @@
</span><span class="cx"> macro(GPatternSpec, g_pattern_spec_free) \
</span><span class="cx"> macro(GDir, g_dir_close) \
</span><span class="cx"> macro(GTimer, g_timer_destroy) \
</span><del>- macro(GKeyFile, g_key_file_free)
</del><ins>+ macro(GKeyFile, g_key_file_free) \
+ macro(char*, g_strfreev)
</ins><span class="cx">
</span><span class="cx"> #define WTF_DEFINE_GPTR_DELETER(typeName, deleterFunc) \
</span><span class="cx"> template<> struct GPtrDeleter<typeName> \
</span></span></pre></div>
<a id="releasesWebKitGTKwebkit210SourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: releases/WebKitGTK/webkit-2.10/Source/WebCore/ChangeLog (195191 => 195192)</h4>
<pre class="diff"><span>
<span class="info">--- releases/WebKitGTK/webkit-2.10/Source/WebCore/ChangeLog        2016-01-18 09:50:09 UTC (rev 195191)
+++ releases/WebKitGTK/webkit-2.10/Source/WebCore/ChangeLog        2016-01-18 10:41:04 UTC (rev 195192)
</span><span class="lines">@@ -1,3 +1,31 @@
</span><ins>+2015-12-20 Michael Catanzaro <mcatanzaro@igalia.com>
+
+ [SOUP] Performs DNS prefetch when a proxy is configured (information leak)
+ https://bugs.webkit.org/show_bug.cgi?id=145542
+
+ Reviewed by Darin Adler.
+
+ Perform DNS prefetch only when no proxy is configured.
+
+ No new tests. Test this manually with Wireshark. Run the simple-proxy example program found
+ in libsoup's examples directory, set that as your system HTTP proxy, and see if DNS queries
+ show up in Wireshark when refreshing a page sent over HTTP. They should appear only when the
+ proxy is not configured.
+
+ * platform/network/DNSResolveQueue.cpp:
+ (WebCore::DNSResolveQueue::DNSResolveQueue):
+ (WebCore::DNSResolveQueue::isUsingProxy):
+ * platform/network/DNSResolveQueue.h:
+ * platform/network/cf/DNSCFNet.cpp:
+ (WebCore::DNSResolveQueue::updateIsUsingProxy):
+ (WebCore::DNSResolveQueue::platformProxyIsEnabledInSystemPreferences): Deleted.
+ * platform/network/soup/DNSSoup.cpp:
+ (WebCore::didResolveProxy):
+ (WebCore::proxyResolvedForHttpUriCallback):
+ (WebCore::proxyResolvedForHttpsUriCallback):
+ (WebCore::DNSResolveQueue::updateIsUsingProxy):
+ (WebCore::DNSResolveQueue::platformProxyIsEnabledInSystemPreferences): Deleted.
+
</ins><span class="cx"> 2015-12-18 Brent Fulgham <bfulgham@apple.com>
</span><span class="cx">
</span><span class="cx"> Place an upper bound on canvas pixel count
</span></span></pre></div>
<a id="releasesWebKitGTKwebkit210SourceWebCoreplatformnetworkDNSResolveQueuecpp"></a>
<div class="modfile"><h4>Modified: releases/WebKitGTK/webkit-2.10/Source/WebCore/platform/network/DNSResolveQueue.cpp (195191 => 195192)</h4>
<pre class="diff"><span>
<span class="info">--- releases/WebKitGTK/webkit-2.10/Source/WebCore/platform/network/DNSResolveQueue.cpp        2016-01-18 09:50:09 UTC (rev 195191)
+++ releases/WebKitGTK/webkit-2.10/Source/WebCore/platform/network/DNSResolveQueue.cpp        2016-01-18 10:41:04 UTC (rev 195192)
</span><span class="lines">@@ -60,20 +60,27 @@
</span><span class="cx"> DNSResolveQueue::DNSResolveQueue()
</span><span class="cx"> : m_timer(*this, &DNSResolveQueue::timerFired)
</span><span class="cx"> , m_requestsInFlight(0)
</span><del>- , m_cachedProxyEnabledStatus(false)
</del><ins>+ , m_isUsingProxy(true)
</ins><span class="cx"> , m_lastProxyEnabledStatusCheckTime(0)
</span><span class="cx"> {
</span><ins>+ // isUsingProxy will return the initial value of m_isUsingProxy at first on
+ // platforms that have an asynchronous implementation of updateIsUsingProxy,
+ // so initialize it to true so we won't prefetch before we know if we are using a proxy.
</ins><span class="cx"> }
</span><span class="cx">
</span><ins>+// Don't do DNS prefetch if proxies are involved. For many proxy types, the user agent is never
+// exposed to the IP address during normal operation. Querying an internal DNS server may not help
+// performance, as it doesn't necessarily look up the actual external IP. Also, if DNS returns a
+// fake internal address, local caches may keep it even after re-connecting to another network.
</ins><span class="cx"> bool DNSResolveQueue::isUsingProxy()
</span><span class="cx"> {
</span><span class="cx"> double time = monotonicallyIncreasingTime();
</span><span class="cx"> static const double minimumProxyCheckDelay = 5;
</span><span class="cx"> if (time - m_lastProxyEnabledStatusCheckTime > minimumProxyCheckDelay) {
</span><span class="cx"> m_lastProxyEnabledStatusCheckTime = time;
</span><del>- m_cachedProxyEnabledStatus = platformProxyIsEnabledInSystemPreferences();
</del><ins>+ updateIsUsingProxy();
</ins><span class="cx"> }
</span><del>- return m_cachedProxyEnabledStatus;
</del><ins>+ return m_isUsingProxy;
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> void DNSResolveQueue::add(const String& hostname)
</span></span></pre></div>
<a id="releasesWebKitGTKwebkit210SourceWebCoreplatformnetworkDNSResolveQueueh"></a>
<div class="modfile"><h4>Modified: releases/WebKitGTK/webkit-2.10/Source/WebCore/platform/network/DNSResolveQueue.h (195191 => 195192)</h4>
<pre class="diff"><span>
<span class="info">--- releases/WebKitGTK/webkit-2.10/Source/WebCore/platform/network/DNSResolveQueue.h        2016-01-18 09:50:09 UTC (rev 195191)
+++ releases/WebKitGTK/webkit-2.10/Source/WebCore/platform/network/DNSResolveQueue.h        2016-01-18 10:41:04 UTC (rev 195192)
</span><span class="lines">@@ -52,7 +52,7 @@
</span><span class="cx">
</span><span class="cx"> bool isUsingProxy();
</span><span class="cx">
</span><del>- bool platformProxyIsEnabledInSystemPreferences();
</del><ins>+ void updateIsUsingProxy();
</ins><span class="cx"> void platformResolve(const String&);
</span><span class="cx">
</span><span class="cx"> void timerFired();
</span><span class="lines">@@ -61,7 +61,7 @@
</span><span class="cx">
</span><span class="cx"> HashSet<String> m_names;
</span><span class="cx"> std::atomic<int> m_requestsInFlight;
</span><del>- bool m_cachedProxyEnabledStatus;
</del><ins>+ bool m_isUsingProxy;
</ins><span class="cx"> double m_lastProxyEnabledStatusCheckTime;
</span><span class="cx"> };
</span><span class="cx">
</span></span></pre></div>
<a id="releasesWebKitGTKwebkit210SourceWebCoreplatformnetworkcfDNSCFNetcpp"></a>
<div class="modfile"><h4>Modified: releases/WebKitGTK/webkit-2.10/Source/WebCore/platform/network/cf/DNSCFNet.cpp (195191 => 195192)</h4>
<pre class="diff"><span>
<span class="info">--- releases/WebKitGTK/webkit-2.10/Source/WebCore/platform/network/cf/DNSCFNet.cpp        2016-01-18 09:50:09 UTC (rev 195191)
+++ releases/WebKitGTK/webkit-2.10/Source/WebCore/platform/network/cf/DNSCFNet.cpp        2016-01-18 10:41:04 UTC (rev 195192)
</span><span class="lines">@@ -48,16 +48,13 @@
</span><span class="cx">
</span><span class="cx"> namespace WebCore {
</span><span class="cx">
</span><del>-bool DNSResolveQueue::platformProxyIsEnabledInSystemPreferences()
</del><ins>+void DNSResolveQueue::updateIsUsingProxy()
</ins><span class="cx"> {
</span><del>- // Don't do DNS prefetch if proxies are involved. For many proxy types, the user agent is never exposed
- // to the IP address during normal operation. Querying an internal DNS server may not help performance,
- // as it doesn't necessarily look up the actual external IP. Also, if DNS returns a fake internal address,
- // local caches may keep it even after re-connecting to another network.
-
</del><span class="cx"> RetainPtr<CFDictionaryRef> proxySettings = adoptCF(CFNetworkCopySystemProxySettings());
</span><del>- if (!proxySettings)
- return false;
</del><ins>+ if (!proxySettings) {
+ m_isUsingProxy = false;
+ return;
+ }
</ins><span class="cx">
</span><span class="cx"> RetainPtr<CFURLRef> httpCFURL = URL(ParsedURLString, "http://example.com/").createCFURL();
</span><span class="cx"> RetainPtr<CFURLRef> httpsCFURL = URL(ParsedURLString, "https://example.com/").createCFURL();
</span><span class="lines">@@ -72,7 +69,7 @@
</span><span class="cx"> if (httpsProxyCount == 1 && CFEqual(CFDictionaryGetValue(static_cast<CFDictionaryRef>(CFArrayGetValueAtIndex(httpsProxyArray.get(), 0)), kCFProxyTypeKey), kCFProxyTypeNone))
</span><span class="cx"> httpsProxyCount = 0;
</span><span class="cx">
</span><del>- return httpProxyCount || httpsProxyCount;
</del><ins>+ m_isUsingProxy = httpProxyCount || httpsProxyCount;
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> static void clientCallback(CFHostRef theHost, CFHostInfoType, const CFStreamError*, void*)
</span></span></pre></div>
<a id="releasesWebKitGTKwebkit210SourceWebCoreplatformnetworksoupDNSSoupcpp"></a>
<div class="modfile"><h4>Modified: releases/WebKitGTK/webkit-2.10/Source/WebCore/platform/network/soup/DNSSoup.cpp (195191 => 195192)</h4>
<pre class="diff"><span>
<span class="info">--- releases/WebKitGTK/webkit-2.10/Source/WebCore/platform/network/soup/DNSSoup.cpp        2016-01-18 09:50:09 UTC (rev 195191)
+++ releases/WebKitGTK/webkit-2.10/Source/WebCore/platform/network/soup/DNSSoup.cpp        2016-01-18 10:41:04 UTC (rev 195192)
</span><span class="lines">@@ -33,18 +33,58 @@
</span><span class="cx"> #include "SoupNetworkSession.h"
</span><span class="cx"> #include <libsoup/soup.h>
</span><span class="cx"> #include <wtf/MainThread.h>
</span><ins>+#include <wtf/glib/GUniquePtr.h>
</ins><span class="cx"> #include <wtf/text/CString.h>
</span><span class="cx">
</span><span class="cx"> namespace WebCore {
</span><span class="cx">
</span><del>-// There is no current reliable way to know if we're behind a proxy at
-// this level. We'll have to implement it in
-// SoupSession/SoupProxyURIResolver/GProxyResolver
-bool DNSResolveQueue::platformProxyIsEnabledInSystemPreferences()
</del><ins>+// Initially true to ensure prefetch stays disabled until we have proxy settings.
+static bool isUsingHttpProxy = true;
+static bool isUsingHttpsProxy = true;
+
+static bool didResolveProxy(char** uris)
</ins><span class="cx"> {
</span><del>- return false;
</del><ins>+ // We have a list of possible proxies to use for the URI. If the first item in the list is
+ // direct:// (the usual case), then the user prefers not to use a proxy. This is similar to
+ // resolving hostnames: there could be many possibilities returned in order of preference, and
+ // if we're trying to connect we should attempt each one in order, but here we are not trying
+ // to connect, merely to decide whether a proxy "should" be used.
+ return uris && *uris && strcmp(*uris, "direct://");
</ins><span class="cx"> }
</span><span class="cx">
</span><ins>+static void didResolveProxy(GProxyResolver* resolver, GAsyncResult* result, bool* isUsingProxyType, bool* isUsingProxy)
+{
+ GUniqueOutPtr<GError> error;
+ GUniquePtr<char*> uris(g_proxy_resolver_lookup_finish(resolver, result, &error.outPtr()));
+ if (error) {
+ WTFLogAlways("Error determining system proxy settings: %s", error->message);
+ return;
+ }
+
+ *isUsingProxyType = didResolveProxy(uris.get());
+ *isUsingProxy = isUsingHttpProxy || isUsingHttpsProxy;
+}
+
+static void proxyResolvedForHttpUriCallback(GObject* source, GAsyncResult* result, void* userData)
+{
+ didResolveProxy(G_PROXY_RESOLVER(source), result, &isUsingHttpProxy, static_cast<bool*>(userData));
+}
+
+static void proxyResolvedForHttpsUriCallback(GObject* source, GAsyncResult* result, void* userData)
+{
+ didResolveProxy(G_PROXY_RESOLVER(source), result, &isUsingHttpsProxy, static_cast<bool*>(userData));
+}
+
+void DNSResolveQueue::updateIsUsingProxy()
+{
+ GRefPtr<GProxyResolver> resolver;
+ g_object_get(SoupNetworkSession::defaultSession().soupSession(), "proxy-resolver", &resolver.outPtr(), nullptr);
+ ASSERT(resolver);
+
+ g_proxy_resolver_lookup_async(resolver.get(), "http://example.com/", nullptr, proxyResolvedForHttpUriCallback, &m_isUsingProxy);
+ g_proxy_resolver_lookup_async(resolver.get(), "https://example.com/", nullptr, proxyResolvedForHttpsUriCallback, &m_isUsingProxy);
+}
+
</ins><span class="cx"> static void resolvedCallback(SoupAddress*, guint, void*)
</span><span class="cx"> {
</span><span class="cx"> DNSResolveQueue::singleton().decrementRequestCount();
</span></span></pre>
</div>
</div>
</body>
</html>