Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(250)

Unified Diff: ui/base/clipboard/clipboard_win.cc

Issue 792413003: Added impersonation of the anonymous token around CloseClipboard (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Reverted change to remoting, added scoper Created 6 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 {
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698