Stay Secure with Chrome’s New ‘Paste Protection’

Roopal Jasnani
3 min readMar 2, 2024


Hello, tech enthusiasts! Today, we’ll delve into a new feature introduced in Chrome DevTools — the “Paste Protection” feature. This feature is designed to enhance security and prevent self-XSS attacks. Before jumping into this feature, let’s first understand what self-XSS implies.

What are self-XSS attacks?

Have you ever copied and pasted some code into the Chrome console, without knowing what it does? If so, you might have fallen victim to a self-XSS attack. Self-XSS stands for self-cross-site scripting, a type of web security vulnerability that allows malicious actors to trick users into executing harmful code on their own browsers.

Self-XSS attacks usually rely on social engineering techniques, such as phishing emails, fake websites, or online quizzes, that persuade users to copy and paste a snippet of code into the Chrome console. The code might promise to reveal some secret information, unlock some features, or perform some actions on behalf of the user. However, the code might also do something malicious, such as stealing the user’s cookies, session tokens, passwords, or personal data, or performing unwanted actions on the user’s behalf, such as sending spam messages, deleting accounts, or transferring money.

What is Paste Protection?

In recent versions of Google Chrome starting v120, a new experimental feature has been introduced in DevTools. If you are a new DevTools user attempting to paste code in the Sources panel’s DevTools code editor, it now shows you a dialog — “Do you trust this code?” and the Console too will display a similar warning. This feature is designed to prevent users from inadvertently executing malicious code.

The idea behind this feature is simple yet effective: Paste only the code that you understand and have reviewed yourself.

How to bypass Paste Protection?

To paste code into the console, you need to type “allow pasting” when prompted. If you don’t type “allow pasting”, no code will be pasted and nothing will happen. Once pasting has been allowed, the warning will never be shown again. This ensures that users are aware of the potential risks associated with pasting unverified code. This way, you can avoid accidentally running harmful code on your browser. This feature aims to raise the user’s awareness and prevent them from blindly executing unknown code.

“We hope that this achieves a good trade-off between usefulness and annoyance. By adding friction, we increase the likelihood of you reading the warning and therefore decrease the likelihood of a successful self-XSS attack.”

How to Enable or Disable Paste Protection?

You can easily enable or disable this feature by navigating to DevTools > Settings (top-right corner) > Experiments. Here, you can toggle the option “Show warning about Self-XSS when pasting code”. To enable Paste Protection, check this option. To disable it, uncheck the option.


Paste protection is a useful feature that can help you protect yourself from self-XSS attacks. However, it is not a foolproof solution. You should always be careful about what you copy and paste into the console, and only do so if you understand and trust the code. Remember, the console is a powerful tool that can access and modify your browser’s data and behaviour, so use it wisely and responsibly.

The introduction of the Paste Protection feature in Chrome DevTools is a significant step towards enhancing browser security. It serves as a reminder to users to exercise caution when dealing with unfamiliar code, thereby helping to prevent self-XSS attacks.

Remember, the key to safe coding is understanding what you’re pasting into your console. Stay safe, and happy coding!