by loxias · 3y ago · 0 comments
1) Beware! any site you visit can, via javascript, inject whatever it wants into your clipboard (write access)
2) Beware! any site you visit can, via javascript, do whatever it wants with your clipboard (READ and write access) <-- this would freak me out and require immediate opsec change on my part
3) some combination of the above.
4) something different.
I use exclusively Firefox (as opposed to any browser) and haven't touched wayland. I also only type on keyboards with a trackpoint and a middle click button, and have for the past few decades. Hence, I'm sure I make heavy use of all the various methods of accessing clipboards..
(I'm guessing it's closer to #1 than #2, I think I once saw a crypto address in my clipboard unexpectedly on a VM...)
On Linux, there's the clipboard, which is the Ctrl+C/Ctrl+V that most people are familiar with.
There's also the "primary selection", which is the currently highlighted text. That selection can be pasted into a different app or text box with middle click. So you can really quickly do highlight, middle-click, highlight, middle click.
The primary selection is stored separately from the clipboard too, so it won't overwrite the contents of such.
But, because setting the primary selection is just selecting text, if JS selects text, then it sets the primary selection. Compare with the clipboard: JS cannot normally set the clipboard except in certain contexts (the OP goes into these).
(Well, technically, it doesn't actually "inject" anything, it just changes the selection, and arguably it's "working as intended").
Usually webpages cannot read the clipboard, and instead rely on the browser/os/whatever sending them its contents when the user ctrl+v or right-click-paste. It would then be received as a javascript event.