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..38d02f84ca6693c83c3d992823225f1a10562c82 100644 |
--- a/ui/base/clipboard/clipboard_win.cc |
+++ b/ui/base/clipboard/clipboard_win.cc |
@@ -35,6 +35,23 @@ namespace ui { |
namespace { |
+// A scoper to impersonate the anonymous token and revert when leaving scope |
+class AnonymousImpersonator { |
+ public: |
+ AnonymousImpersonator() { |
+ must_revert_ = ::ImpersonateAnonymousToken(::GetCurrentThread()); |
Wez
2014/12/15 17:07:11
Under what circumstances can ImpersonateAnonymousT
forshaw
2014/12/16 09:07:30
It can fail if we're running under a restricted to
|
+ } |
+ |
+ ~AnonymousImpersonator() { |
+ if (must_revert_) |
+ ::RevertToSelf(); |
+ } |
+ |
+ private: |
+ BOOL must_revert_; |
+ DISALLOW_COPY_AND_ASSIGN(AnonymousImpersonator); |
dcheng
2014/12/15 16:58:20
Note: I usually see a newline between DISALLOW_COP
forshaw
2014/12/16 09:07:30
Acknowledged.
|
+}; |
+ |
// A scoper to manage acquiring and automatically releasing the clipboard. |
class ScopedClipboard { |
public: |
@@ -84,6 +101,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 |
Wez
2014/12/15 17:07:11
nit: punctuation
Impersonating the anonymous toke
forshaw
2014/12/16 09:07:30
The only thing I think this should impact is anyon
|
+ AnonymousImpersonator impersonator; |
::CloseClipboard(); |
opened_ = false; |
} else { |