Index: ui/base/clipboard/clipboard_win.cc |
diff --git a/ui/base/clipboard/clipboard_win.cc b/ui/base/clipboard/clipboard_win.cc |
index c2c2fb69f8e3f845e1ec28cedeb9a2de72bb2a9b..1044c3f1951809bef6a25abd87baa739b4a46b09 100644 |
--- a/ui/base/clipboard/clipboard_win.cc |
+++ b/ui/base/clipboard/clipboard_win.cc |
@@ -35,6 +35,22 @@ namespace ui { |
namespace { |
+// A scoper to impersonate the anonymous token and revert when leaving scope |
+class AnonymousImpersonator { |
+ public: |
+ AnonymousImpersonator() { |
+ must_revert_ = ::ImpersonateAnonymousToken(::GetCurrentThread()); |
+ } |
+ |
+ ~AnonymousImpersonator() { |
+ if (must_revert_) |
+ ::RevertToSelf(); |
+ } |
+ |
+ private: |
+ BOOL must_revert_; |
dcheng
2014/12/13 01:16:50
Actually, you probably want DISALLOW_COPY_AND_ASSI
|
+}; |
+ |
// A scoper to manage acquiring and automatically releasing the clipboard. |
class ScopedClipboard { |
public: |
@@ -84,6 +100,11 @@ class ScopedClipboard { |
void Release() { |
if (opened_) { |
+ // Impersonate the anonymous token during the call to CloseClipboard |
+ // This prevents Windows 8+ capturing the broker's access token which |
+ // could be accessed by lower-privileges chrome processes leading to |
+ // a risk of EoP |
+ AnonymousImpersonator impersonator; |
::CloseClipboard(); |
opened_ = false; |
} else { |