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
- 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.
- 2Never silently rewrite clipboard content without explicit user-visible confirmation (a 'Copied!' toast is fine; changing the value is not).
- 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)
button.addEventListener('click', () => {
navigator.clipboard.writeText(codeSnippet);
showToast('Copied!');
});
// Avoid overriding the native 'copy' event to swap in different contentReferences
Detected automatically by VulnRadar. The check id is clipboard-hijack-pattern, stable across every scan so you can filter or diff on it.
More content checks
- MediumPotential Open Redirect Parameters
- HighDirectory Listing Appears Enabled
- MediumSensitive File References Detected
- HighPotentially Outdated JavaScript Libraries
- Inforobots.txt Present - Review Manually
- InfoCMS / Technology Fingerprinting
- MediumPotentially Dangerous Inline JavaScript
- LowServer version disclosed in response header
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.