I came across a site which overrides copy functionality and injects current page url as paste value. I was trying to select couple of words and instead it copied the page link. Simple developer tools inspection showed event getting overridden with following function
window.addEventListener("copy", event=>{
const selection = document.getSelection();
event.clipboardData.setData("text/plain", window.location.href),
event.preventDefault()
}
While in this case, it's annoying but harmless, I'm wondering if it's good idea to allow user intentions changed without any warnings to the user. Even the test code from mdn copy event allowed me to change to random text without any warning. Basically I'm trying to copy "abcd" to clipboard and browser does copy "wxyz"
Wondering if hackers can takeover this functionality and copy their choice of links or data on clipboard especially when browsers did not seem to be warning you that text you selected and tried to copy has been modified.
I have tried this on latest versions of Firefox and Chromium available on Ubuntu 18.04 and none of the browsers warned me anything.