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

Issue 792413003: Added impersonation of the anonymous token around CloseClipboard (Closed)

Created:
6 years ago by forshaw
Modified:
6 years ago
Reviewers:
jschuh, dcheng
CC:
chromium-reviews, chromoting-reviews_chromium.org, Wez
Base URL:
https://chromium.googlesource.com/chromium/src.git@master
Project:
chromium
Visibility:
Public.

Description

Added impersonation of the anonymous token around CloseClipboard This patch adds impersonation of the anonymous token around calls to the CloseClipboard system call. On Windows 8+ the win32k driver captures the access token of the caller and makes it available to other users on the desktop through the system call GetClipboardAccessToken. This introduces a risk of privilege escalation in sandboxed processes. By performing the impersonation then whenever Chrome writes data to the clipboard only the anonymous token is available. BUG=440693 Committed: https://crrev.com/56332e21e9930fba480556fbc96c748994b4a7b7 Cr-Commit-Position: refs/heads/master@{#308372}

Patch Set 1 #

Total comments: 2

Patch Set 2 : Added check for success on impersonation call #

Patch Set 3 : Reverted change to remoting, added scoper #

Total comments: 1

Patch Set 4 : Added DISALLOW_COPY_AND_ASSIGN to Impersonator class #

Total comments: 6
Unified diffs Side-by-side diffs Delta from patch set Stats (+22 lines, -0 lines) Patch
M ui/base/clipboard/clipboard_win.cc View 1 2 3 2 chunks +22 lines, -0 lines 6 comments Download

Messages

Total messages: 34 (11 generated)
forshaw
Please can you review this change. This to to harden token handling on Win8+ although ...
6 years ago (2014-12-11 17:09:04 UTC) #2
jschuh
Looks good with a nit... https://codereview.chromium.org/792413003/diff/1/remoting/host/clipboard_win.cc File remoting/host/clipboard_win.cc (right): https://codereview.chromium.org/792413003/diff/1/remoting/host/clipboard_win.cc#newcode35 remoting/host/clipboard_win.cc:35: ::ImpersonateAnonymousToken(GetCurrentThread()); I know the ...
6 years ago (2014-12-11 17:53:06 UTC) #3
dcheng
https://codereview.chromium.org/792413003/diff/1/remoting/host/clipboard_win.cc File remoting/host/clipboard_win.cc (right): https://codereview.chromium.org/792413003/diff/1/remoting/host/clipboard_win.cc#newcode35 remoting/host/clipboard_win.cc:35: ::ImpersonateAnonymousToken(GetCurrentThread()); On 2014/12/11 at 17:53:06, jschuh wrote: > I ...
6 years ago (2014-12-11 18:18:23 UTC) #4
jschuh
On 2014/12/11 18:18:23, dcheng wrote: > https://codereview.chromium.org/792413003/diff/1/remoting/host/clipboard_win.cc > File remoting/host/clipboard_win.cc (right): > > https://codereview.chromium.org/792413003/diff/1/remoting/host/clipboard_win.cc#newcode35 > ...
6 years ago (2014-12-11 18:33:51 UTC) #5
dcheng
On 2014/12/11 at 18:33:51, jschuh wrote: > On 2014/12/11 18:18:23, dcheng wrote: > > https://codereview.chromium.org/792413003/diff/1/remoting/host/clipboard_win.cc ...
6 years ago (2014-12-11 18:39:04 UTC) #6
Sergey Ulanov
I'm not sure you need the change in remoting host. Can you please CC me ...
6 years ago (2014-12-11 19:47:17 UTC) #8
Sergey Ulanov
On 2014/12/11 19:47:17, Sergey Ulanov wrote: > I'm not sure you need the change in ...
6 years ago (2014-12-11 20:03:59 UTC) #9
forshaw
> After looking at the but still can't tell if we need the change in ...
6 years ago (2014-12-11 22:19:26 UTC) #10
Wez
The CL description makes it sound like any app can choose to impersonate the user ...
6 years ago (2014-12-12 17:49:38 UTC) #11
jschuh
No, your read is correct. So, I think you very much want this change in ...
6 years ago (2014-12-12 17:53:08 UTC) #12
Wez
If my reading is correct then surely the patch to Chrome has little or no ...
6 years ago (2014-12-12 18:29:58 UTC) #13
forshaw
Updated the CL with scoper, could you please review.
6 years ago (2014-12-12 20:47:30 UTC) #16
jschuh
On 2014/12/12 18:29:58, Wez wrote: > If my reading is correct then surely the patch ...
6 years ago (2014-12-12 21:20:23 UTC) #17
jschuh
lgtm
6 years ago (2014-12-12 21:40:22 UTC) #18
dcheng
rs lgtm
6 years ago (2014-12-13 01:16:01 UTC) #20
dcheng
one minor nit, but otherwise, lgtm https://codereview.chromium.org/792413003/diff/40001/ui/base/clipboard/clipboard_win.cc File ui/base/clipboard/clipboard_win.cc (right): https://codereview.chromium.org/792413003/diff/40001/ui/base/clipboard/clipboard_win.cc#newcode51 ui/base/clipboard/clipboard_win.cc:51: BOOL must_revert_; Actually, ...
6 years ago (2014-12-13 01:16:51 UTC) #22
forshaw
Updated the CL, please can you just double check. Thanks.
6 years ago (2014-12-15 13:50:15 UTC) #24
dcheng
still lgtm https://codereview.chromium.org/792413003/diff/60001/ui/base/clipboard/clipboard_win.cc File ui/base/clipboard/clipboard_win.cc (right): https://codereview.chromium.org/792413003/diff/60001/ui/base/clipboard/clipboard_win.cc#newcode52 ui/base/clipboard/clipboard_win.cc:52: DISALLOW_COPY_AND_ASSIGN(AnonymousImpersonator); Note: I usually see a newline ...
6 years ago (2014-12-15 16:58:20 UTC) #26
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/patch-status/792413003/60001
6 years ago (2014-12-15 17:00:26 UTC) #28
Wez
https://codereview.chromium.org/792413003/diff/60001/ui/base/clipboard/clipboard_win.cc File ui/base/clipboard/clipboard_win.cc (right): https://codereview.chromium.org/792413003/diff/60001/ui/base/clipboard/clipboard_win.cc#newcode42 ui/base/clipboard/clipboard_win.cc:42: must_revert_ = ::ImpersonateAnonymousToken(::GetCurrentThread()); Under what circumstances can ImpersonateAnonymousToken fail? ...
6 years ago (2014-12-15 17:07:12 UTC) #30
commit-bot: I haz the power
Committed patchset #4 (id:60001)
6 years ago (2014-12-15 18:10:20 UTC) #31
commit-bot: I haz the power
Patchset 4 (id:??) landed as https://crrev.com/56332e21e9930fba480556fbc96c748994b4a7b7 Cr-Commit-Position: refs/heads/master@{#308372}
6 years ago (2014-12-15 18:10:59 UTC) #32
forshaw
6 years ago (2014-12-16 09:07:31 UTC) #34
Message was sent while issue was closed.
https://codereview.chromium.org/792413003/diff/60001/ui/base/clipboard/clipbo...
File ui/base/clipboard/clipboard_win.cc (right):

https://codereview.chromium.org/792413003/diff/60001/ui/base/clipboard/clipbo...
ui/base/clipboard/clipboard_win.cc:42: must_revert_ =
::ImpersonateAnonymousToken(::GetCurrentThread());
On 2014/12/15 17:07:11, Wez wrote:
> Under what circumstances can ImpersonateAnonymousToken fail?
> 
> Should we instead be CHECK()ing this, since if it fails, we're not
impersonating
> the anonymous token? 

It can fail if we're running under a restricted token, other than that it
shouldn't fail. However if we're in a restricted token it isn't as big an issue
if the token is captured. I don't think it needs a CHECK though as we don't want
to crash if it fails as it only makes a difference in a very limited set of
scenarios.

https://codereview.chromium.org/792413003/diff/60001/ui/base/clipboard/clipbo...
ui/base/clipboard/clipboard_win.cc:52:
DISALLOW_COPY_AND_ASSIGN(AnonymousImpersonator);
On 2014/12/15 16:58:20, dcheng wrote:
> Note: I usually see a newline between DISALLOW_COPY_AND_ASSIGN and the rest of
> the class definition.

Acknowledged.

https://codereview.chromium.org/792413003/diff/60001/ui/base/clipboard/clipbo...
ui/base/clipboard/clipboard_win.cc:107: // a risk of EoP
On 2014/12/15 17:07:11, Wez wrote:
> nit: punctuation
> 
> Impersonating the anonymous token presumably impacts the behaviour of e.g.
> putting files onto the clipboard - any application which expects to be able to
> use GetClipboardAuthToken() to ensure that it has access to the files is going
> to fail. We should document that likely impact, at least.

The only thing I think this should impact is anyone calling the
GetClipboardAccessToken system call which as far as I can tell is limited to a
few internal DLLs. It isn't documented from what I can determine or clear what
it's actual purpose is. It shouldn't affect the processing of files transferred
over the clipboard but it's always a possibility that something won't work
correctly afterwards.

Powered by Google App Engine
This is Rietveld 408576698