Skip to main content

How to fix: Copy Event Listener Rewrites Clipboard Content

A 'copy' event listener was found that rewrites the clipboard contents via clipboardData.setData(). This is also the standard, MDN-documented technique for legitimate copy-customization features (e.g. a 'copy code snippet' button), so this alone does not confirm clipboard-hijacking.

Why it matters

If genuinely malicious (via a compromised third-party script or stored XSS), this pattern lets an attacker silently replace anything a user copies from the page, most commonly used to swap a copied cryptocurrency wallet address for the attacker's own. Confirm the listener is first-party and intentional before treating this as an incident.

Clipboard-hijacking scripts listen for the browser's 'copy' event and call setData() to overwrite what actually gets placed on the clipboard, so the user sees the text they intended to copy but pastes something else entirely. The same API is also the documented way to build legitimate copy-customization features, so a static scan cannot distinguish the two on its own.

How to fix it

  1. 1Confirm the copy listener is first-party and intentional (e.g. a 'copy code snippet' button); if not, remove it and audit for a supply-chain or XSS compromise.
  2. 2Never silently rewrite clipboard content without explicit user-visible confirmation (a 'Copied!' toast is fine; changing the value is not).
  3. 3Add a Content-Security-Policy and Subresource Integrity to reduce the chance of a third-party script being able to inject this behavior.

Code examples

Legitimate copy-to-clipboard (no silent rewrite)

JavaScript
button.addEventListener('click', () => {
  navigator.clipboard.writeText(codeSnippet);
  showToast('Copied!');
});
// Avoid overriding the native 'copy' event to swap in different content

References

Detected automatically by VulnRadar. The check id is clipboard-hijack-pattern, stable across every scan so you can filter or diff on it.

See every content check

Questions

How severe is Copy Event Listener Rewrites Clipboard Content?
VulnRadar rates this low severity in the content category. The severity is fixed per check, not scored per site, so the same finding is the same severity on every scan.
Does VulnRadar check for this automatically?
Yes. It runs as part of every scan under the check id clipboard-hijack-pattern, which stays the same between runs so you can filter, diff, or gate CI on it.

Missing a check?

The detection set is open. If you know a misconfiguration this does not catch, propose it: the issue template asks for the threat model, how to detect it, the false-positive risk, and a test fixture, which is the same thing a maintainer would have to work out anyway.

Propose a checkHow a check is built

Scan your own site for copy event listener rewrites clipboard content

VulnRadar runs this check and hundreds more against a URL in seconds. No agent to install, just paste a URL.

Or scan this site as a demoRead the docs

Copy Event Listener Rewrites Clipboard Content | VulnRadar