[tor-commits] [tor-browser/tor-browser-38.4.0esr-5.5-1] fixup! Bug 15646: Prevent keyboard layout fingerprinting in KeyboardEvent

gk at torproject.org gk at torproject.org
Fri Dec 11 10:54:26 UTC 2015


commit 62ad9e1b780579ad459823253bcb8b47fefdd414
Author: Arthur Edelstein <arthuredelstein at gmail.com>
Date:   Mon Sep 7 22:49:25 2015 -0700

    fixup! Bug 15646: Prevent keyboard layout fingerprinting in KeyboardEvent
---
 dom/events/KeyboardEvent.cpp |   12 +++++++-----
 dom/events/KeyboardEvent.h   |   11 +++++++++++
 2 files changed, 18 insertions(+), 5 deletions(-)

diff --git a/dom/events/KeyboardEvent.cpp b/dom/events/KeyboardEvent.cpp
index 19d4e73..3977da8 100644
--- a/dom/events/KeyboardEvent.cpp
+++ b/dom/events/KeyboardEvent.cpp
@@ -12,11 +12,6 @@
 namespace mozilla {
 namespace dom {
 
-static bool ResistFingerprinting() {
-  return nsContentUtils::ResistFingerprinting() &&
-         !nsContentUtils::ThreadsafeIsCallerChrome();
-}
-
 KeyboardEvent::KeyboardEvent(EventTarget* aOwner,
                              nsPresContext* aPresContext,
                              WidgetKeyboardEvent* aEvent)
@@ -44,6 +39,13 @@ NS_INTERFACE_MAP_BEGIN(KeyboardEvent)
 NS_INTERFACE_MAP_END_INHERITING(UIEvent)
 
 bool
+KeyboardEvent::ResistFingerprinting() {
+  return nsContentUtils::ResistFingerprinting() &&
+         nsContentUtils::GetCurrentJSContextForThread() &&
+         !nsContentUtils::ThreadsafeIsCallerChrome();
+}
+
+bool
 KeyboardEvent::AltKey()
 {
   bool altState = mEvent->AsKeyboardEvent()->IsAlt();
diff --git a/dom/events/KeyboardEvent.h b/dom/events/KeyboardEvent.h
index d5b5ae1..af95e84 100644
--- a/dom/events/KeyboardEvent.h
+++ b/dom/events/KeyboardEvent.h
@@ -53,6 +53,15 @@ public:
 
   bool GetModifierState(const nsAString& aKey)
   {
+    if (ResistFingerprinting()) {
+      if (aKey.Equals(NS_LITERAL_STRING("Alt")) ||
+          aKey.Equals(NS_LITERAL_STRING("AltGraph"))) {
+        return AltKey();
+      }
+      if (aKey.Equals(NS_LITERAL_STRING("Shift"))) {
+        return ShiftKey();
+      }
+    }
     return GetModifierStateInternal(aKey);
   }
 
@@ -85,6 +94,8 @@ protected:
                                  ErrorResult& aRv);
 
 private:
+  bool ResistFingerprinting();
+
   // True, if the instance is created with Constructor().
   bool mInitializedByCtor;
 





More information about the tor-commits mailing list