Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clipboard API #89

Closed
mconca opened this issue May 9, 2018 · 15 comments · Fixed by #764
Closed

Clipboard API #89

mconca opened this issue May 9, 2018 · 15 comments · Fixed by #764
Labels
position: positive venue: W3C Specifications in W3C Working Groups

Comments

@mconca
Copy link

mconca commented May 9, 2018

Request for Mozilla Position on an Emerging Web Specification

Other information

In Firefox, Mozilla currently supports the Clipboards Events described in the draft specification, so this RFP is in regards to the Asynchronous Clipboard API from the spec.

Google recently implemented and shipped the text-only API as part of the April 17, 2018, Chrome M66 release. Their reasoning behind implementing the draft spec (and limiting it to text-only for now) is documented in a March 2018 developer blog post.

Mozilla also receives many requests from extension developers to expose a better clipboard interface (the execCommand method has limitations in extensions). These API could be provided, but they would be redundant with those described in the W3C draft spec. The policy of the WebExtensions API has been to not provide proprietary extension API for features that can be accomplished via standards-based API. Knowing Mozilla's position on this draft specification, therefore, is important for planning the WebExtensions API roadmap.

@martinthomson
Copy link
Member

The challenge here is in managing permissions. That is, how do we avoid sites capturing arbitrary text from the clipboard. Given the frequency with which secrets pass through clipboards, this is a pretty big security concern.

You will notice the permissions prompt is the very first thing that appears in the video in the Google developer blog post. I don't believe that asking permission is an appropriate defense, even though sites can only access events when they are in the foreground. Keep in mind that permissions persist and are easily forgotten.

I don't have a good solution for this.

@mystor
Copy link

mystor commented May 14, 2018

I intend to have my intern implement some part of this API this summer. We're dodging the challenge which @martinthomson brought up by not exposing the clipboard reading APIs to the web (they will unconditionally fail, as though the site does not have the correct permissions), and only exposing them to webextensions which already can use the execCommand("paste") API.

This will, of course, be implemented behind a pref, and we will potentially iterate on the API before we ship it.

@martinthomson
Copy link
Member

Use within a webextension is a great way to start. I certainly think that the concerns about permission are manageable in that context. @mystor, is the intent to have another permission for the webextension, or to implicitly grant all webextensions this capability? I think that we probably still want accountability on that front, as well as to apply the principle of least privilege. But that's product-related decisions only.

p.s., it's not access to "paste" that is the concern.

@mystor
Copy link

mystor commented May 15, 2018

@martinthomson We already expose the ability to copy to webextensions in the same manner as we expose it to the web. The two permissions (clipboardWrite and clipboardRead) are also present for allowing writing/reading the clipboard whenever.

I am not intending to make any changes to that established permission model.

There are some more details on the current API here: https://developer.mozilla.org/en-US/Add-ons/WebExtensions/Interact_with_the_clipboard

@mconca
Copy link
Author

mconca commented May 16, 2018

@mystor I'm very happy to hear this. Extending the clipboard API has been a high-priority request from extension developers and glad we're going to do it in a standards-based way.

@dbaron dbaron added the venue: W3C Specifications in W3C Working Groups label Aug 9, 2018
@annevk
Copy link
Contributor

annevk commented Jul 21, 2020

Related issues: w3c/clipboard-apis#101 and w3c/permissions#175.

I'm not sure what to make of this as it's clear that there are some parts that we support (and ship) and there are some parts in this specification that are clearly problematic. I guess this is a case where #249 would help.

(It's also not entirely clear how -read made it into the specification as neither Firefox nor Safari wants it.)

@marcoscaceres
Copy link
Contributor

(It's also not entirely clear how -read made it into the specification as neither Firefox nor Safari wants it.)

Old WebAppsWG process had no oversight (when this was added, before I was Chair). I've introduced a pull request template to hopefully prevent this from happening again. However, it requires Mozilla folks involved in this spec to very vigilant at not allowing things like this to happen as not all working groups have such a template. We might need better enforcement (e.g., 3 reviews, one from each browser vendor, before merge).

@hober
Copy link

hober commented Jul 23, 2020

I've introduced a pull request template to hopefully prevent this from happening again. However, it requires Mozilla folks involved in this spec to very vigilant at not allowing things like this to happen

Please let me know how we can help.

@marcoscaceres
Copy link
Contributor

@hober, the biggest help would be to have a co-Editor join from Apple. They wouldn't need to "edit" - but would be nice if they did! They would provide editorial oversight and could easily be called upon for review. That way, we share the responsibility, accountability, and pain! and, as a result, hopefully we end up with higher quality specs.

The above applies to us (Mozilla). We should be co-editing any spec we are involved in. I know it's a big investment - but something we should seriously consider.

@hsinyi
Copy link

hsinyi commented Sep 29, 2021

Related issues: w3c/clipboard-apis#101 and w3c/permissions#175.

I'm not sure what to make of this as it's clear that there are some parts that we support (and ship) and there are some parts in this specification that are clearly problematic. I guess this is a case where #249 would help.

(It's also not entirely clear how -read made it into the specification as neither Firefox nor Safari wants it.)

Several issues mentioned above were closed. Worth revisiting this?
@annevk @smaug---- @mbrodesser

@annevk
Copy link
Contributor

annevk commented Sep 29, 2021

Unfortunately there's still major problems with the specification, e.g., #525 (comment) onward.

We have made some progress on how we want to expose reading, which will largely be based on Safari. Essentially require user activation followed by showing the user a non-modal dialog in context (similar to what we use for form autofill) that says something along the lines of "Paste your clipboard contents to example.com? [Paste] [Cancel]". (We don't want permissions here as that would allow continuous monitoring of clipboard contents.)

So overall this is worth prototyping I'd say, but I'm hesitant to mark it as such given the specification is essentially a skeleton.

@EdgarChen
Copy link

Spec was improved significantly by w3c/clipboard-apis#158 which defines clearer steps and adding ClipboardItem interface.

@EdgarChen
Copy link

I suggest we resolve the issue with position positive, as we are implementing it and Chrome/Safari shipped already.

@zcorpan
Copy link
Member

zcorpan commented Mar 9, 2023

Agreed. I'd like a bit more detail for rationale that answers "do we think this is good for the web?" and how it handles security concerns, independently of implemented status, though.

@EdgarChen
Copy link

Async Clipboard API could supersede accessing clipboard via execommand which is no longer recommended. The security concerns are addressed as @annevk commented earlier, i.e. it requires user activation and an additional dialog shown to get user confirmation.

@zcorpan zcorpan added ready to add Appears ready to add to the table of positions. position: positive labels Mar 10, 2023
zcorpan added a commit that referenced this issue Mar 16, 2023
@zcorpan zcorpan removed the ready to add Appears ready to add to the table of positions. label Mar 16, 2023
tantek pushed a commit that referenced this issue Mar 20, 2023
@zcorpan zcorpan changed the title RFP: Clipboard API Clipboard API Oct 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
position: positive venue: W3C Specifications in W3C Working Groups
Projects
None yet
Development

Successfully merging a pull request may close this issue.

10 participants