Commit 557f124b authored by Oskar Mansfeld's avatar Oskar Mansfeld Committed by morgan
Browse files

Bug 1914583 - Block IPAddrAny on H3 code path. r=necko-reviewers,kershaw

parent f13fc799
Loading
Loading
Loading
Loading
+17 −0
Changes for netwerk/protocol/http/HttpConnectionUDP.cpp: 17 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -19,6 +19,7 @@

#include "ASpdySession.h"
#include "mozilla/StaticPrefs_network.h"
#include "mozilla/glean/NetwerkMetrics.h"
#include "mozilla/Telemetry.h"
#include "HttpConnectionUDP.h"
#include "nsHttpHandler.h"
@@ -88,6 +89,22 @@ nsresult HttpConnectionUDP::Init(nsHttpConnectionInfo* info,
    return rv;
  }

  // We are disabling 0.0.0.0 for non-test purposes.
  // See https://github.com/whatwg/fetch/pull/1763 for context.
  if (peerAddr.IsIPAddrAny()) {
    if (StaticPrefs::network_socket_ip_addr_any_disabled()) {
      mozilla::glean::networking::http_ip_addr_any_count
          .Get("blocked_requests"_ns)
          .Add(1);
      LOG(("Connection refused because of 0.0.0.0 IP address\n"));
      return NS_ERROR_CONNECTION_REFUSED;
    }

    mozilla::glean::networking::http_ip_addr_any_count
        .Get("not_blocked_requests"_ns)
        .Add(1);
  }

  mSocket = do_CreateInstance("@mozilla.org/network/udp-socket;1", &rv);
  if (NS_FAILED(rv)) {
    return rv;