Changeset 194323 in webkit


Ignore:
Timestamp:
Dec 20, 2015 5:19:41 PM (8 years ago)
Author:
Michael Catanzaro
Message:

[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:
Location:
trunk/Source
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WTF/ChangeLog

    r194318 r194323  
     12015-12-20  Michael Catanzaro  <mcatanzaro@igalia.com>
     2
     3        [SOUP] Performs DNS prefetch when a proxy is configured (information leak)
     4        https://bugs.webkit.org/show_bug.cgi?id=145542
     5
     6        Reviewed by Darin Adler.
     7
     8        Specialize GUniquePtr<char*>, using g_strfreev.
     9
     10        * wtf/glib/GUniquePtr.h:
     11
    1122015-12-19  Dan Bernstein  <mitz@apple.com>
    213
  • trunk/Source/WTF/wtf/glib/GUniquePtr.h

    r185818 r194323  
    4444    macro(GDir, g_dir_close) \
    4545    macro(GTimer, g_timer_destroy) \
    46     macro(GKeyFile, g_key_file_free)
     46    macro(GKeyFile, g_key_file_free) \
     47    macro(char*, g_strfreev)
    4748
    4849#define WTF_DEFINE_GPTR_DELETER(typeName, deleterFunc) \
  • trunk/Source/WebCore/ChangeLog

    r194322 r194323  
     12015-12-20  Michael Catanzaro  <mcatanzaro@igalia.com>
     2
     3        [SOUP] Performs DNS prefetch when a proxy is configured (information leak)
     4        https://bugs.webkit.org/show_bug.cgi?id=145542
     5
     6        Reviewed by Darin Adler.
     7
     8        Perform DNS prefetch only when no proxy is configured.
     9
     10        No new tests. Test this manually with Wireshark. Run the simple-proxy example program found
     11        in libsoup's examples directory, set that as your system HTTP proxy, and see if DNS queries
     12        show up in Wireshark when refreshing a page sent over HTTP. They should appear only when the
     13        proxy is not configured.
     14
     15        * platform/network/DNSResolveQueue.cpp:
     16        (WebCore::DNSResolveQueue::DNSResolveQueue):
     17        (WebCore::DNSResolveQueue::isUsingProxy):
     18        * platform/network/DNSResolveQueue.h:
     19        * platform/network/cf/DNSCFNet.cpp:
     20        (WebCore::DNSResolveQueue::updateIsUsingProxy):
     21        (WebCore::DNSResolveQueue::platformProxyIsEnabledInSystemPreferences): Deleted.
     22        * platform/network/soup/DNSSoup.cpp:
     23        (WebCore::didResolveProxy):
     24        (WebCore::proxyResolvedForHttpUriCallback):
     25        (WebCore::proxyResolvedForHttpsUriCallback):
     26        (WebCore::DNSResolveQueue::updateIsUsingProxy):
     27        (WebCore::DNSResolveQueue::platformProxyIsEnabledInSystemPreferences): Deleted.
     28
    1292015-12-20  Dan Bernstein  <mitz@apple.com>
    230
  • trunk/Source/WebCore/platform/network/DNSResolveQueue.cpp

    r185818 r194323  
    6161    : m_timer(*this, &DNSResolveQueue::timerFired)
    6262    , m_requestsInFlight(0)
    63     , m_cachedProxyEnabledStatus(false)
     63    , m_isUsingProxy(true)
    6464    , m_lastProxyEnabledStatusCheckTime(0)
    6565{
     66    // isUsingProxy will return the initial value of m_isUsingProxy at first on
     67    // platforms that have an asynchronous implementation of updateIsUsingProxy,
     68    // so initialize it to true so we won't prefetch before we know if we are using a proxy.
    6669}
    6770
     71// Don't do DNS prefetch if proxies are involved. For many proxy types, the user agent is never
     72// exposed to the IP address during normal operation. Querying an internal DNS server may not help
     73// performance, as it doesn't necessarily look up the actual external IP. Also, if DNS returns a
     74// fake internal address, local caches may keep it even after re-connecting to another network.
    6875bool DNSResolveQueue::isUsingProxy()
    6976{
     
    7279    if (time - m_lastProxyEnabledStatusCheckTime > minimumProxyCheckDelay) {
    7380        m_lastProxyEnabledStatusCheckTime = time;
    74         m_cachedProxyEnabledStatus = platformProxyIsEnabledInSystemPreferences();
     81        updateIsUsingProxy();
    7582    }
    76     return m_cachedProxyEnabledStatus;
     83    return m_isUsingProxy;
    7784}
    7885
  • trunk/Source/WebCore/platform/network/DNSResolveQueue.h

    r185818 r194323  
    5353    bool isUsingProxy();
    5454
    55     bool platformProxyIsEnabledInSystemPreferences();
     55    void updateIsUsingProxy();
    5656    void platformResolve(const String&);
    5757
     
    6262    HashSet<String> m_names;
    6363    std::atomic<int> m_requestsInFlight;
    64     bool m_cachedProxyEnabledStatus;
     64    bool m_isUsingProxy;
    6565    double m_lastProxyEnabledStatusCheckTime;
    6666};
  • trunk/Source/WebCore/platform/network/cf/DNSCFNet.cpp

    r185818 r194323  
    4949namespace WebCore {
    5050
    51 bool DNSResolveQueue::platformProxyIsEnabledInSystemPreferences()
     51void DNSResolveQueue::updateIsUsingProxy()
    5252{
    53     // Don't do DNS prefetch if proxies are involved. For many proxy types, the user agent is never exposed
    54     // to the IP address during normal operation. Querying an internal DNS server may not help performance,
    55     // as it doesn't necessarily look up the actual external IP. Also, if DNS returns a fake internal address,
    56     // local caches may keep it even after re-connecting to another network.
    57 
    5853    RetainPtr<CFDictionaryRef> proxySettings = adoptCF(CFNetworkCopySystemProxySettings());
    59     if (!proxySettings)
    60         return false;
     54    if (!proxySettings) {
     55        m_isUsingProxy = false;
     56        return;
     57    }
    6158
    6259    RetainPtr<CFURLRef> httpCFURL = URL(ParsedURLString, "http://example.com/").createCFURL();
     
    7370        httpsProxyCount = 0;
    7471
    75     return httpProxyCount || httpsProxyCount;
     72    m_isUsingProxy = httpProxyCount || httpsProxyCount;
    7673}
    7774
  • trunk/Source/WebCore/platform/network/soup/DNSSoup.cpp

    r185819 r194323  
    3434#include <libsoup/soup.h>
    3535#include <wtf/MainThread.h>
     36#include <wtf/glib/GUniquePtr.h>
    3637#include <wtf/text/CString.h>
    3738
    3839namespace WebCore {
    3940
    40 // There is no current reliable way to know if we're behind a proxy at
    41 // this level. We'll have to implement it in
    42 // SoupSession/SoupProxyURIResolver/GProxyResolver
    43 bool DNSResolveQueue::platformProxyIsEnabledInSystemPreferences()
     41// Initially true to ensure prefetch stays disabled until we have proxy settings.
     42static bool isUsingHttpProxy = true;
     43static bool isUsingHttpsProxy = true;
     44
     45static bool didResolveProxy(char** uris)
    4446{
    45     return false;
     47    // We have a list of possible proxies to use for the URI. If the first item in the list is
     48    // direct:// (the usual case), then the user prefers not to use a proxy. This is similar to
     49    // resolving hostnames: there could be many possibilities returned in order of preference, and
     50    // if we're trying to connect we should attempt each one in order, but here we are not trying
     51    // to connect, merely to decide whether a proxy "should" be used.
     52    return uris && *uris && strcmp(*uris, "direct://");
     53}
     54
     55static void didResolveProxy(GProxyResolver* resolver, GAsyncResult* result, bool* isUsingProxyType, bool* isUsingProxy)
     56{
     57    GUniqueOutPtr<GError> error;
     58    GUniquePtr<char*> uris(g_proxy_resolver_lookup_finish(resolver, result, &error.outPtr()));
     59    if (error) {
     60        WTFLogAlways("Error determining system proxy settings: %s", error->message);
     61        return;
     62    }
     63
     64    *isUsingProxyType = didResolveProxy(uris.get());
     65    *isUsingProxy = isUsingHttpProxy || isUsingHttpsProxy;
     66}
     67
     68static void proxyResolvedForHttpUriCallback(GObject* source, GAsyncResult* result, void* userData)
     69{
     70    didResolveProxy(G_PROXY_RESOLVER(source), result, &isUsingHttpProxy, static_cast<bool*>(userData));
     71}
     72
     73static void proxyResolvedForHttpsUriCallback(GObject* source, GAsyncResult* result, void* userData)
     74{
     75    didResolveProxy(G_PROXY_RESOLVER(source), result, &isUsingHttpsProxy, static_cast<bool*>(userData));
     76}
     77
     78void DNSResolveQueue::updateIsUsingProxy()
     79{
     80    GRefPtr<GProxyResolver> resolver;
     81    g_object_get(SoupNetworkSession::defaultSession().soupSession(), "proxy-resolver", &resolver.outPtr(), nullptr);
     82    ASSERT(resolver);
     83
     84    g_proxy_resolver_lookup_async(resolver.get(), "http://example.com/", nullptr, proxyResolvedForHttpUriCallback, &m_isUsingProxy);
     85    g_proxy_resolver_lookup_async(resolver.get(), "https://example.com/", nullptr, proxyResolvedForHttpsUriCallback, &m_isUsingProxy);
    4686}
    4787
Note: See TracChangeset for help on using the changeset viewer.