add Keyboard-protection-flag, Disable-TabHoverCard-images, privacy-issues-in-password-manager

This commit is contained in:
Carmelo Messina
2023-03-14 17:15:33 +01:00
parent d39d33f1b7
commit 0c9be22a15
4 changed files with 289 additions and 0 deletions
+3
View File
@@ -296,6 +296,7 @@ Add-kill-switch-for-unsupported-clangd-flags.patch
00WIN-disable-annotate-downloads.patch
00WIN-enable-HighEfficiencyMode-by-default.patch
00WIN-enable-file-system-access-blocklist.patch
00WIN-Disable-TabHoverCard-images.patch
00WIN-Fix-windows-build.patch
00Temp-Disable-kAutomaticLazyFrameLoadingToEmbeds.patch
@@ -317,5 +318,7 @@ AudioBuffer-AnalyserNode-fp-mitigations.patch
00WIN-Enable-Network-Service-Sandbox-and-CIG.patch
00Disable-csp-reports.patch
00Fonts-fingerprinting-mitigation.patch
00Keyboard-protection-flag.patch
00Disable-privacy-issues-in-password-manager.patch
00111-temp-fix-build.patch
@@ -0,0 +1,31 @@
From: uazo <uazo@users.noreply.github.com>
Date: Tue, 14 Mar 2023 15:59:38 +0000
Subject: Disable privacy issues in password manager
---
.../password_manager/core/common/password_manager_features.cc | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/components/password_manager/core/common/password_manager_features.cc b/components/password_manager/core/common/password_manager_features.cc
--- a/components/password_manager/core/common/password_manager_features.cc
+++ b/components/password_manager/core/common/password_manager_features.cc
@@ -67,7 +67,7 @@ BASE_FEATURE(kFillingAcrossAffiliatedWebsites,
// selection, rather than autofilling on page load, with highlighting of fields.
BASE_FEATURE(kFillOnAccountSelect,
"fill-on-account-select",
- base::FEATURE_DISABLED_BY_DEFAULT);
+ base::FEATURE_ENABLED_BY_DEFAULT);
#if BUILDFLAG(IS_MAC) || BUILDFLAG(IS_LINUX)
// When enabled, initial sync will be forced during startup if the password
@@ -137,7 +137,7 @@ BASE_FEATURE(kSendPasswords,
// Enables password leak detection for unauthenticated users.
BASE_FEATURE(kLeakDetectionUnauthenticated,
"LeakDetectionUnauthenticated",
- base::FEATURE_ENABLED_BY_DEFAULT);
+ base::FEATURE_DISABLED_BY_DEFAULT);
// Enables .well-known based password change flow from leaked password dialog.
BASE_FEATURE(kPasswordChangeWellKnown,
--
2.25.1
@@ -0,0 +1,230 @@
From: uazo <uazo@users.noreply.github.com>
Date: Tue, 14 Mar 2023 15:48:21 +0000
Subject: Keyboard protection flag
Hides user preference on the system keyboard by setting the standard
eng layout and removing the layout information from the javascript
keyboard events.
---
chrome/browser/about_flags.cc | 3 ++
chrome/browser/flag_descriptions.cc | 6 +++
chrome/browser/flag_descriptions.h | 3 ++
.../renderer/core/events/keyboard_event.cc | 54 +++++++++++++++++++
.../renderer/core/events/keyboard_event.h | 3 ++
ui/base/ui_base_features.cc | 8 +++
ui/base/ui_base_features.h | 2 +
.../dom/dom_keyboard_layout_map_win.cc | 13 +++++
8 files changed, 92 insertions(+)
diff --git a/chrome/browser/about_flags.cc b/chrome/browser/about_flags.cc
--- a/chrome/browser/about_flags.cc
+++ b/chrome/browser/about_flags.cc
@@ -4450,6 +4450,9 @@ const FeatureEntry kFeatureEntries[] = {
{"system-keyboard-lock", flag_descriptions::kSystemKeyboardLockName,
flag_descriptions::kSystemKeyboardLockDescription, kOsDesktop,
FEATURE_VALUE_TYPE(features::kSystemKeyboardLock)},
+ {"system-keyboard-protection", flag_descriptions::kSystemKeyboardProtectionName,
+ flag_descriptions::kSystemKeyboardProtectionDescription, kOsAll,
+ FEATURE_VALUE_TYPE(features::kSystemKeyboardProtection)},
#if BUILDFLAG(IS_ANDROID)
{"add-to-homescreen-iph", flag_descriptions::kAddToHomescreenIPHName,
flag_descriptions::kAddToHomescreenIPHDescription, kOsAndroid,
diff --git a/chrome/browser/flag_descriptions.cc b/chrome/browser/flag_descriptions.cc
--- a/chrome/browser/flag_descriptions.cc
+++ b/chrome/browser/flag_descriptions.cc
@@ -2949,6 +2949,12 @@ const char kSystemKeyboardLockDescription[] =
"keyboard shortcuts and have the events routed directly to the website "
"when in fullscreen mode.";
+const char kSystemKeyboardProtectionName[] = "System keyboard protection";
+const char kSystemKeyboardProtectionDescription[] =
+ "Hides user preference on the system keyboard by setting the standard "
+ "eng layout and removing the layout information from the "
+ "javascript keyboard events.";
+
const char kSystemSoundsName[] = "Power Sounds";
const char kSystemSoundsDescription[] =
"Enable device charging and low battery warning sounds.";
diff --git a/chrome/browser/flag_descriptions.h b/chrome/browser/flag_descriptions.h
--- a/chrome/browser/flag_descriptions.h
+++ b/chrome/browser/flag_descriptions.h
@@ -1657,6 +1657,9 @@ extern const char kSuppressToolbarCapturesDescription[];
extern const char kSystemKeyboardLockName[];
extern const char kSystemKeyboardLockDescription[];
+extern const char kSystemKeyboardProtectionName[];
+extern const char kSystemKeyboardProtectionDescription[];
+
extern const char kSystemSoundsName[];
extern const char kSystemSoundsDescription[];
diff --git a/third_party/blink/renderer/core/events/keyboard_event.cc b/third_party/blink/renderer/core/events/keyboard_event.cc
--- a/third_party/blink/renderer/core/events/keyboard_event.cc
+++ b/third_party/blink/renderer/core/events/keyboard_event.cc
@@ -23,9 +23,12 @@
#include "third_party/blink/renderer/core/events/keyboard_event.h"
#include "build/build_config.h"
+#include "base/feature_list.h"
#include "third_party/blink/public/common/input/web_input_event.h"
#include "third_party/blink/public/platform/platform.h"
#include "third_party/blink/renderer/bindings/core/v8/v8_keyboard_event_init.h"
+#include "third_party/blink/renderer/core/dom/events/event_dispatch_result.h"
+#include "third_party/blink/renderer/core/dom/events/event_dispatcher.h"
#include "third_party/blink/renderer/core/editing/ime/input_method_controller.h"
#include "third_party/blink/renderer/core/event_interface_names.h"
#include "third_party/blink/renderer/core/frame/local_dom_window.h"
@@ -34,6 +37,7 @@
#include "third_party/blink/renderer/platform/bindings/dom_wrapper_world.h"
#include "third_party/blink/renderer/platform/bindings/script_state.h"
#include "third_party/blink/renderer/platform/windows_keyboard_codes.h"
+#include "ui/base/ui_base_features.h"
#include "ui/events/keycodes/dom/keycode_converter.h"
namespace blink {
@@ -133,6 +137,50 @@ KeyboardEvent::KeyboardEvent(const WebKeyboardEvent& key,
else
key_code_ = char_code_;
+ if (features::IsSystemKeyboardProtectionEnabled()) {
+ ui::DomKey dom_key = static_cast<ui::DomKey>(key.dom_key);
+
+ if (ui::KeycodeConverter::IsDomKeyForModifier(dom_key)) {
+ // suppress event if is ctrl/shift/alt... otherwise key_code of
+ // the next character can be stolen
+ suppress_event_ = true;
+ } else if (type() == event_type_names::kKeypress) {
+ // on keypress never send keyboard data
+ key_code_ = 0;
+ code_ = String();
+ // clear all modifiers including shift
+ modifiers_ = 0;
+ } else if (type() == event_type_names::kKeydown ||
+ type() == event_type_names::kKeyup) {
+ // on keydown/up clear keyboard data if is a character
+ // excluding:
+ // - space: as is not named
+ // - ctrl-a/c/v: select all/copy/paste
+ bool is_named = ui::KeycodeConverter::IsDomKeyNamed(dom_key);
+ bool is_control = (modifiers_ & WebInputEvent::kControlKey) == WebInputEvent::kControlKey;
+ if (!is_named && key_code_ != 32 &&
+ !(is_control &&
+ (key_code_ == 'a' || key_code_ == 'A' ||
+ key_code_ == 'c' || key_code_ == 'C' ||
+ key_code_ == 'v' || key_code_ == 'V'))) {
+ key_code_ = 0;
+ code_ = String();
+ // clear all modifiers including shift
+ modifiers_ = 0;
+ }
+ // do not leak status of numlock/capslock/scrolllock
+ // clear all modifiers excluding shift and control
+ // because is needed for shift/control + arrows to works
+ modifiers_ &= ~(WebInputEvent::kSymbolKey | WebInputEvent::kFnKey |
+ WebInputEvent::kAltGrKey | WebInputEvent::kMetaKey |
+ WebInputEvent::kAltKey | WebInputEvent::kIsKeyPad |
+ WebInputEvent::kSymbolKey | WebInputEvent::kScrollLockOn |
+ WebInputEvent::kCapsLockOn | WebInputEvent::kNumLockOn);
+ }
+ // clear location data
+ location_ = KeyboardEvent::kDomKeyLocationStandard;
+ }
+
#if BUILDFLAG(IS_ANDROID)
// FIXME: Check to see if this applies to other OS.
// If the key event belongs to IME composition then propagate to JS.
@@ -205,6 +253,12 @@ unsigned KeyboardEvent::which() const {
return (unsigned)keyCode();
}
+DispatchEventResult KeyboardEvent::DispatchEvent(EventDispatcher& dispatcher) {
+ if (suppress_event_)
+ return DispatchEventResult::kNotCanceled;
+ return dispatcher.Dispatch();
+}
+
void KeyboardEvent::InitLocationModifiers(unsigned location) {
switch (location) {
case KeyboardEvent::kDomKeyLocationNumpad:
diff --git a/third_party/blink/renderer/core/events/keyboard_event.h b/third_party/blink/renderer/core/events/keyboard_event.h
--- a/third_party/blink/renderer/core/events/keyboard_event.h
+++ b/third_party/blink/renderer/core/events/keyboard_event.h
@@ -97,6 +97,8 @@ class CORE_EXPORT KeyboardEvent final : public UIEventWithKeyState {
unsigned which() const override;
bool isComposing() const { return is_composing_; }
+ DispatchEventResult DispatchEvent(EventDispatcher&) override;
+
void Trace(Visitor*) const override;
private:
@@ -109,6 +111,7 @@ class CORE_EXPORT KeyboardEvent final : public UIEventWithKeyState {
bool is_composing_ = false;
unsigned char_code_ = 0;
unsigned key_code_ = 0;
+ bool suppress_event_ = false;
};
template <>
diff --git a/ui/base/ui_base_features.cc b/ui/base/ui_base_features.cc
--- a/ui/base/ui_base_features.cc
+++ b/ui/base/ui_base_features.cc
@@ -172,6 +172,14 @@ BASE_FEATURE(kSystemKeyboardLock,
"SystemKeyboardLock",
base::FEATURE_ENABLED_BY_DEFAULT);
+BASE_FEATURE(kSystemKeyboardProtection,
+ "SystemKeyboardProtection",
+ base::FEATURE_ENABLED_BY_DEFAULT);
+
+bool IsSystemKeyboardProtectionEnabled() {
+ return base::FeatureList::IsEnabled(kSystemKeyboardProtection);
+}
+
// Enables GPU rasterization for all UI drawing (where not blocklisted).
BASE_FEATURE(kUiGpuRasterization,
"UiGpuRasterization",
diff --git a/ui/base/ui_base_features.h b/ui/base/ui_base_features.h
--- a/ui/base/ui_base_features.h
+++ b/ui/base/ui_base_features.h
@@ -32,6 +32,8 @@ COMPONENT_EXPORT(UI_BASE_FEATURES) bool IsPercentBasedScrollingEnabled();
COMPONENT_EXPORT(UI_BASE_FEATURES) BASE_DECLARE_FEATURE(kPointerLockOptions);
COMPONENT_EXPORT(UI_BASE_FEATURES) BASE_DECLARE_FEATURE(kSystemCaptionStyle);
COMPONENT_EXPORT(UI_BASE_FEATURES) BASE_DECLARE_FEATURE(kSystemKeyboardLock);
+COMPONENT_EXPORT(UI_BASE_FEATURES) BASE_DECLARE_FEATURE(kSystemKeyboardProtection);
+COMPONENT_EXPORT(UI_BASE_FEATURES) bool IsSystemKeyboardProtectionEnabled();
COMPONENT_EXPORT(UI_BASE_FEATURES)
BASE_DECLARE_FEATURE(kUiCompositorScrollWithLayers);
diff --git a/ui/events/keycodes/dom/dom_keyboard_layout_map_win.cc b/ui/events/keycodes/dom/dom_keyboard_layout_map_win.cc
--- a/ui/events/keycodes/dom/dom_keyboard_layout_map_win.cc
+++ b/ui/events/keycodes/dom/dom_keyboard_layout_map_win.cc
@@ -13,6 +13,8 @@
#include "base/containers/flat_map.h"
#include "base/logging.h"
#include "base/ranges/algorithm.h"
+#include "base/feature_list.h"
+#include "ui/base/ui_base_features.h"
#include "ui/events/keycodes/dom/dom_code.h"
#include "ui/events/keycodes/dom/dom_key.h"
#include "ui/events/keycodes/dom/dom_keyboard_layout_map_base.h"
@@ -74,6 +76,17 @@ uint32_t DomKeyboardLayoutMapWin::GetKeyboardLayoutCount() {
iter != keyboard_layout_handles_.end())
std::iter_swap(keyboard_layout_handles_.begin(), iter);
+ if (features::IsSystemKeyboardProtectionEnabled()) {
+ HKL actual_layout = GetKeyboardLayout(0);
+
+ // get handle for en-us keyboard layout
+ keyboard_layout_handles_.clear();
+ keyboard_layout_handles_.resize(1);
+ keyboard_layout_handles_[0] = LoadKeyboardLayoutA("00000409", KLF_ACTIVATE);
+
+ // reactivate user keyboard layout
+ ActivateKeyboardLayout(actual_layout, KLF_SETFORPROCESS);
+ }
return keyboard_layout_handles_.size();
}
--
2.25.1
@@ -0,0 +1,25 @@
From: uazo <uazo@users.noreply.github.com>
Date: Tue, 14 Mar 2023 15:58:00 +0000
Subject: WIN Disable TabHoverCard images
---
chrome/browser/ui/ui_features.cc | 4 ----
1 file changed, 4 deletions(-)
diff --git a/chrome/browser/ui/ui_features.cc b/chrome/browser/ui/ui_features.cc
--- a/chrome/browser/ui/ui_features.cc
+++ b/chrome/browser/ui/ui_features.cc
@@ -183,11 +183,7 @@ const base::FeatureParam<bool> kTabGroupsSaveSyncIntegration{
// https://crbug.com/928954
BASE_FEATURE(kTabHoverCardImages,
"TabHoverCardImages",
-#if BUILDFLAG(IS_MAC)
base::FEATURE_DISABLED_BY_DEFAULT
-#else
- base::FEATURE_ENABLED_BY_DEFAULT
-#endif
);
const char kTabHoverCardImagesNotReadyDelayParameterName[] =
--
2.25.1