Commit 25d641cb authored by ma1's avatar ma1 Committed by Pier Angelo Vendrame
Browse files

Bug 8324: Prevent DNS proxy bypasses caused by Drag&Drop

Bug 41613: Skip Drang & Drop filtering for DNS-safe URLs
parent aff8a97d
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -27,6 +27,7 @@ ChromeUtils.defineESModuleGetters(lazy, {
  DoHController: "resource:///modules/DoHController.sys.mjs",
  DownloadsViewableInternally:
    "resource:///modules/DownloadsViewableInternally.sys.mjs",
  DragDropFilter: "resource://gre/modules/DragDropFilter.sys.mjs",
  E10SUtils: "resource://gre/modules/E10SUtils.sys.mjs",
  FeatureGate: "resource://featuregates/FeatureGate.sys.mjs",
  FxAccounts: "resource://gre/modules/FxAccounts.sys.mjs",
@@ -1822,6 +1823,8 @@ BrowserGlue.prototype = {

    lazy.DoHController.init();

    lazy.DragDropFilter.init();

    lazy.TorProviderBuilder.firstWindowLoaded();

    ClipboardPrivacy.startup();
+5 −1
Original line number Diff line number Diff line
@@ -1962,7 +1962,11 @@ XPCOMUtils.defineLazyGetter(PlacesUIUtils, "URI_FLAVORS", () => {
  ];
});
XPCOMUtils.defineLazyGetter(PlacesUIUtils, "SUPPORTED_FLAVORS", () => {
  return [...PlacesUIUtils.PLACES_FLAVORS, ...PlacesUIUtils.URI_FLAVORS];
  return [
    ...PlacesUIUtils.PLACES_FLAVORS,
    ...PlacesUIUtils.URI_FLAVORS,
    "application/x-torbrowser-opaque",
  ];
});

XPCOMUtils.defineLazyGetter(PlacesUIUtils, "ellipsis", function () {
+1 −0
Original line number Diff line number Diff line
@@ -1255,6 +1255,7 @@ PlacesController.prototype = {
    [
      PlacesUtils.TYPE_X_MOZ_PLACE,
      PlacesUtils.TYPE_X_MOZ_URL,
      "application/x-torbrowser-opaque",
      PlacesUtils.TYPE_PLAINTEXT,
    ].forEach(type => xferable.addDataFlavor(type));

+14 −2
Original line number Diff line number Diff line
@@ -2,6 +2,12 @@
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */

const lazy = {};

ChromeUtils.defineESModuleGetters(lazy, {
  OpaqueDrag: "resource://gre/modules/DragDropFilter.sys.mjs",
});

// This component is used for handling dragover and drop of urls.
//
// It checks to see whether a drop of a url is allowed. For instance, a url
@@ -40,10 +46,15 @@ ContentAreaDropListener.prototype = {
      }
    }

    type = "text/x-moz-url";
    if (types.contains(type)) {
    for (let type of ["text/x-moz-url", "application/x-torbrowser-opaque"]) {
      if (!types.contains(type)) {
        continue;
      }
      data = dt.mozGetDataAt(type, i);
      if (data) {
        if (type === "application/x-torbrowser-opaque") {
          ({ type, value: data = "" } = lazy.OpaqueDrag.retrieve(data));
        }
        let lines = data.split("\n");
        for (let i = 0, length = lines.length; i < length; i += 2) {
          this._addLink(links, lines[i], lines[i + 1], type);
@@ -236,6 +247,7 @@ ContentAreaDropListener.prototype = {
    if (
      !types.includes("application/x-moz-file") &&
      !types.includes("text/x-moz-url") &&
      !types.includes("application/x-torbrowser-opaque") &&
      !types.includes("text/uri-list") &&
      !types.includes("text/x-moz-text-internal") &&
      !types.includes("text/plain")
+4 −0
Original line number Diff line number Diff line
@@ -14,6 +14,7 @@ ChromeUtils.defineESModuleGetters(lazy, {
  Bookmarks: "resource://gre/modules/Bookmarks.sys.mjs",
  History: "resource://gre/modules/History.sys.mjs",
  Log: "resource://gre/modules/Log.sys.mjs",
  OpaqueDrag: "resource://gre/modules/DragDropFilter.sys.mjs",
  PlacesSyncUtils: "resource://gre/modules/PlacesSyncUtils.sys.mjs",
  Sqlite: "resource://gre/modules/Sqlite.sys.mjs",
});
@@ -1103,6 +1104,9 @@ export var PlacesUtils = {
  unwrapNodes: function PU_unwrapNodes(blob, type) {
    // We split on "\n"  because the transferable system converts "\r\n" to "\n"
    var nodes = [];
    if (type === "application/x-torbrowser-opaque") {
      ({ value: blob, type } = lazy.OpaqueDrag.retrieve(blob));
    }
    switch (type) {
      case this.TYPE_X_MOZ_PLACE:
      case this.TYPE_X_MOZ_PLACE_SEPARATOR:
Loading