Why not make clipboard context aware and have some level of smart scanning. For example someone goes to a website and copies text and then pastes that into terminal (or krunner etc). It likely should cause a warning if it also contains something like “curl”. However same text copied from terminal into terminal, likely intended.
Where this is coming from is scenario where user could enter a site that has some sort of scam. That scam might ask user to copy a script from a site and run it. It can even use browser’s clipboard api to automatically push it to the clipboard. Making next instruction seem more innocent by just pasting. And this paste operation now could detect the context being tainted as it comes from browser and contains words that execute or extract etc.
There are countless of attacks done this way (known as ClickFix or pastejacking) and systems generally just assume user is knowing what they are doing. Maybe by default we should assume they do not.
i would not be opposed to a flag of some kind that is set when certain defined and user controlled conditions are met, in order to give the user a heads up that what they are about to paste may not be right.
but i would be opposed to any extra dialogs or “are you sure” sort of second guessing popups on the part of the clipboard getting in the way of my workflow.
no amount of fool proofing is going to prevent all mistakes… that’s why backups are a thing.
If you want to detect text that could be a harmful terminal command, maybe the shell’s command handler is the best place to put it rather than adding logic to the clipboard?
In March 2026, Apple added a mitigation to macOS to prevent ClickFix style attacks. In April, a modified variant using the applescript:// URI scheme to bypass the use of the Terminal application was found.
I think this is a major difficulty. Any “smart scanning” we implement is probably not “smart” at all (well, at least when LLM is not involved (I’m not implying that LLM can make it smart enough)), and way too easy to work around by the bad guy. So all it provides is a false sense of security, probably making the user more inclined to paste random text on the web into the terminal.
The point is not to detect harmful terminal commands by itself, but rather the context matters. It’s very different thing to write rm yourself than some random website copying it to your clipboard and then telling to paste into the terminal and press enter. Terminal isn’t the important detail here, just an example. Anything that could execute the clipboard contents is in the list. Even the very clipboard manager has “invoke action”. With a shortcut to that, that’s potentially doing real nasty and I don’t think there is one by default, good.
Smart scanning (secondary bike shedding detail) would be condition for relief rather than to enforce. Kind of guilty until proven innocent. In that regard it could be considered optional and work without it at all. It’s not even the main topic here, but rather the context aware clipboard with tainted content. It’s very different scenario to copy text from a website to an text editor than it is to terminal. In same way it is different to copy from terminal to terminal or from text editor to terminal.
Taint here point to a concept where say variable contains user content and one has to untait it before you are allowed to use it. Taint checking - Wikipedia Don’t get stuck to this. Name it whatever you want.
Right now clipboard could contain anything, has no zero understanding where the data came from and is equally trusted. This trust can be exploited, while plenty of people prefer “sudo stop nagging”. And yes that is totally reasonable for advanced user. However many users do not have awareness where the website ends and where the system starts. Random (hijacked) site could suggest to just press a shortcut and another and owned, while they just wanted to order tickets.
I’m pretty sure at the point a user is ready to paste commands from a website into his cli a warning that it’s not safe is not going to stop them either way. They’ll just be annoyed, dismiss it and carry on as usual.
What’s more likely happening is that a user is entering a legit site, let’s say their local school’s sports hall site to sign their kid in. The site could have injected script in it, because it’s a small thing and who is going to spend tons of money on making it proper. Or maybe it’s scam site on purpose. Only detail that matters here is that everyone is the potential victim.
It pops up captcha style verification, are you a robot, common thing. User does check yes, now that counts as user interaction for the browser and it can have event linked to it. This allows websites, by design, to inject content into the clipboard without user ever being aware of this happening. The payload is in place. Feel free to argue in Big Browser standards committee about it, only detail that matters is that it happens.
Next the site tells user to press alt+space and then ctrl+v and press enter. 3 instructions, that are not asking anything scary looking to many people. Many other possible instructions here, use your imagination. (Maybe it’s someone over the phone providing “tech support”.)
Some weird characters are there but it’s the school asking to verify the booking for kid so this is what the parent is going to do. And then it just says thank you, they move forward and the kid is booked. They got owned, nothing hinted anything weird happening from their perspective, and they don’t even know anything bad just happened.
There are many ways to go about it, one can be more clever about it. Tho data shows that is not required.
Not everyone is some super hacker browsing dodgy hacking forums and copypasting stuff into terminal without questioning it. That’s not the threat model I would be worried about here.
I do strongly dislike how the AI boom normalized random curl install scripts, though. It makes pasting really powerful commands feel ordinary and expected, and it’s hard to tell people not to do that when everyone is doing it. It’s not helping with the threat model.
I get what you’re saying here, but it’s hard to really defend against social engineering here.
When the dodgy website (or the person on the phone) says “you’ll see this warning, just click through the screens and click “OK” at the end. What are these computers like! Those nerds can’t build something that just works without getting in your way!” - unfortunately, that’s often enough to neutralise security measures.
(See various financial scams where the scammers tell the unsuspecting victim how to get through all the security warnings.)
Indeed. So much https://trustme.br/o/itsfine.sh.
That actually is the kind of thing I had in mind when I talked about command handlers in the shell. But I agree with your response to me that there are other vectors to worry about.