Intent to Implement and Ship: Allow JS-triggered copy/cut with a user gesture

195 views
Skip to first unread message

Daniel Cheng

unread,
Dec 1, 2014, 3:04:49 PM12/1/14
to blink-dev
dch...@chromium.org http://dev.w3.org/2006/webapi/clipops/clipops.html#events-that-are-allowed-to-modify-the-clipboard execCommand("copy") and execCommand("cut") should be allowed to modify the system clipboard in the context of a user gesture (the spec uses the language "allowed to show a popup").
Today, execCommand("copy"/"cut"/"paste") aren't allowed on the open web, due to concerns about clobbering the clipboard and sniffing clipboard content. However, Right now, web developers already get around this restriction by using a Flash polyfill (see https://github.com/zeroclipboard/zeroclipboard for one example).
Firefox: No public signals Internet Explorer: No public signals Safari: No public signals Web developers: Positive The main compatibility risk is feature detection. According to the Editing spec, execCommand() should return false if a command is not supported or enabled.
- Internet Explorer: pops up a dialog with "Allow" and "Don't Allow". Clicking "Don't Allow" still returns true.
- Firefox: throws an exception if DOM-triggered clipboard operations aren't enabled
- Blink and WebKit both return false if execCommand() isn't supported/enabled.
None
Yes. https://crbug.com/437908
https://www.chromestatus.com/features/5223997243392000
Yes.

PhistucK

unread,
Dec 1, 2014, 3:26:16 PM12/1/14
to Daniel Cheng, blink-dev
Does Flash require a user gesture for this as well?

What about users that explicitly disable Flash for this reason (and other privacy issues, like super cookies, Flash local storage)?


PhistucK

To unsubscribe from this group and stop receiving emails from it, send an email to blink-dev+...@chromium.org.

Chris Palmer

unread,
Dec 1, 2014, 3:29:47 PM12/1/14
to Daniel Cheng, blink-dev
"It's safe because we nagged the user with a pop-up" doesn't convince
me. Nor does "We might as well because Flash."

What are users to think of a pop-up that says, "Do you want to let
this web site do something that seems obvious and basic?" I suspect
they will be annoyed, and not understand the issue (after all, copying
and pasting is obvious and basic, so it's surely safe...). I suspect
that the gesture will not actually protect people from malicious
clipboard-sniffers.

Obvious and basic though copy/cut/paste is, this feature reverses the
power dynamic in a way that no pop-up can make obvious.

The best user gesture to assert user intent *is the one that already
exists in the operating system*.

What actual real-world application problem does this solve? I've seen
the apps that have a "click this Flash button to copy the following
text", but that's not obviously better than just letting people use
the existing and well-understood copy/paste mechanisms. Especially
since the open web could read whatever I have in my clipboard —
passwords from my password manager!, the texts of private emails, et
c. — and especially since the mitigation is basically a fig leaf, this
feature seems to create more problems than it solves.

Daniel Cheng

unread,
Dec 1, 2014, 3:32:23 PM12/1/14
to PhistucK, blink-dev
On Mon Dec 01 2014 at 12:26:14 PM PhistucK <phis...@gmail.com> wrote:
Does Flash require a user gesture for this as well?

Flash does require an explicit user gesture.

Daniel

Jochen Eisinger

unread,
Dec 1, 2014, 3:33:17 PM12/1/14
to Daniel Cheng, PhistucK, blink-dev
if you say "allowed to show a popup", do you intend to also consume the user gesture (like the popup would)?

Daniel Cheng

unread,
Dec 1, 2014, 3:39:14 PM12/1/14
to Chris Palmer, blink-dev
On Mon Dec 01 2014 at 12:29:43 PM Chris Palmer <pal...@google.com> wrote:
"It's safe because we nagged the user with a pop-up" doesn't convince
me. Nor does "We might as well because Flash."

What are users to think of a pop-up that says, "Do you want to let
this web site do something that seems obvious and basic?" I suspect
they will be annoyed, and not understand the issue (after all, copying
and pasting is obvious and basic, so it's surely safe...). I suspect
that the gesture will not actually protect people from malicious
clipboard-sniffers.

Note that the scope is limited to copy and cut. Paste is explicitly not included in this list, due to the possibility of clipboard sniffing.
 

Obvious and basic though copy/cut/paste is, this feature reverses the
power dynamic in a way that no pop-up can make obvious.

The best user gesture to assert user intent *is the one that already
exists in the operating system*.

What actual real-world application problem does this solve? I've seen
the apps that have a "click this Flash button to copy the following
text", but that's not obviously better than just letting people use
the existing and well-understood copy/paste mechanisms. Especially
since the open web could read whatever I have in my clipboard —
passwords from my password manager!, the texts of private emails, et
c. — and especially since the mitigation is basically a fig leaf, this
feature seems to create more problems than it solves.

I think it could be interesting to see what % of copy/cuts are triggered by the system shortcut as opposed to one of the Flash polyfills. It could also be interesting to count the number of execCommand("copy") and execCommand("cut") attempts that fail today, since that might be another signal for how widespread this sort of thing would be. Unfortunately, the discussion thread didn't have explicit examples, but I would expect it to be useful for:
- Generic rich text editors (I don't have stats to measure this, but at least some of them expose 'copy', 'cut', and 'paste' through toolbar icons or menu items). Clicking on that item does nothing other than show an alert that you have to press Ctrl/Cmd+C instead to copy.
- "Click here to get a URL you can copy to your clipboard" type things, e.g. when you share a link in Google Docs.

Daniel
 

Daniel Cheng

unread,
Dec 1, 2014, 3:42:45 PM12/1/14
to Jochen Eisinger, PhistucK, blink-dev
I guess the idea of consuming it for popups is to prevent multiple popups from being displayed with one user gesture? It doesn't seem like one user gesture should have to trigger than more one clipboard operation so... yes? Also, is 'consuming a user gesture' explicitly covered anywhere in the specs?

Daniel

Jochen Eisinger

unread,
Dec 1, 2014, 3:45:39 PM12/1/14
to Daniel Cheng, PhistucK, blink-dev
no, it's not mentioned in the specs. I just wanted to clarify what exactly you meant.

btw, what's the use case for copy if you can't paste? Can websites paste using flash?

Daniel Cheng

unread,
Dec 1, 2014, 3:59:35 PM12/1/14
to Jochen Eisinger, PhistucK, blink-dev
The use case is to copy stuff to your clipboard so you can paste it elsewhere--e.g. a video link (vimeo.com), a repository URL (github.com), a shortened URL (bitly.com), etc.

http://lists.w3.org/Archives/Public/public-webapps/2014JulSep/0122.html has more interesting information about one specific Flash polyfill (for example, 35k+ clicks on the polyfill on github.com / day).

Jochen Eisinger

unread,
Dec 1, 2014, 4:05:14 PM12/1/14
to Daniel Cheng, PhistucK, blink-dev
makes sense.

I think I can see an attack vector where the site copies some ads or something into your clipboard, but that's less concerning than being able to read the clipboard.

lgtm to ship

To unsubscribe from this group and stop receiving emails from it, send an email to blink-dev+unsubscribe@chromium.org.

Chris Harrelson

unread,
Dec 2, 2014, 4:15:40 PM12/2/14
to Jochen Eisinger, Daniel Cheng, PhistucK, blink-dev
LGTM

To unsubscribe from this group and stop receiving emails from it, send an email to blink-dev+...@chromium.org.

Dimitri Glazkov

unread,
Dec 9, 2014, 1:18:09 PM12/9/14
to Chris Harrelson, Jochen Eisinger, Daniel Cheng, PhistucK, blink-dev
LGTM.

Yoav Weiss

unread,
Dec 10, 2014, 8:27:02 PM12/10/14
to Dimitri Glazkov, Daniel Cheng, Jochen Eisinger, Chris Harrelson, PhistucK, blink-dev

Late to the party, but isn't the attack vector a website that'd copy "rm -rf /" or another malicious command to the user's clipboard, with hope that the user will later paste it to his shell?

Jeffrey Yasskin

unread,
Dec 10, 2014, 8:32:04 PM12/10/14
to Yoav Weiss, Dimitri Glazkov, Daniel Cheng, Jochen Eisinger, Chris Harrelson, PhistucK, blink-dev
Yes, but most users aren't pasting in a shell anymore, and almost any other target will quickly reveal that the site is malicious.

There's also http://thejh.net/misc/website-terminal-copy-paste for people who do copy to shells...

Yoav Weiss

unread,
Dec 10, 2014, 8:46:00 PM12/10/14
to Jeffrey Yasskin, Chris Harrelson, Jochen Eisinger, Daniel Cheng, Dimitri Glazkov, PhistucK, blink-dev

Yeah, I'm aware of that shell copy attack, and as a result, do not copy/paste from untrusted websites. I guess the safety of that feature depends on the obviousness of the user gesture that's be required to enable copying into the clipboard.

David Benjamin

unread,
Dec 10, 2014, 8:47:09 PM12/10/14
to Jeffrey Yasskin, Yoav Weiss, Dimitri Glazkov, Daniel Cheng, Jochen Eisinger, Chris Harrelson, PhistucK, blink-dev
Or this one: https://davidben.net/copy-test.html

There's already a copy event for you to muck about with the clipboard all you like on Ctrl-C in JS, so there's no need to play layout games.

stu...@testtrack4.com

unread,
Apr 14, 2015, 8:30:36 PM4/14/15
to blin...@chromium.org
 The UX I'd like to see around this (maybe at some point in the future, and maybe starting with CrOS) is something akin to the "Screenshot captured" pop-up seen on Android and Chrome OS, where the OS/browser notifies you when something is copied to your clipboard post-facto, with an action button the user can click to "undo".

As for pasting, maybe there should be a "Content pasted" flash generated by the browser, akin to the "example.com is now full screen" notification, so, in the event that a malicious site steals the user's clipboard whenever they scroll, at least the user is notified of it.

Of course, either (or both) of these behaviors may be added (or extended) by an extension.

PhistucK

unread,
Apr 15, 2015, 4:39:39 AM4/15/15
to Stuart Bentley, blink-dev
For copying and cutting, I think this is very reasonable.
Pasting is disallowed, so it is irrelevant at this point.


PhistucK

To unsubscribe from this group and stop receiving emails from it, send an email to blink-dev+...@chromium.org.

Lucas Garron

unread,
Apr 15, 2015, 8:37:59 PM4/15/15
to PhistucK, Stuart Bentley, blink-dev
Copy/cut is shipping to the general web in Chrome 42; this accidentally happened without a security review. (Test it on beta.)

However, pasting is probably coming soon. The plan is to ask the user to give the origin paste permissions, like other permission APIs/content settings.

A notification (e.g. "toast") would be nice, but details are to be figured out.

»Lucas
Reply all
Reply to author
Forward
0 new messages