Skip to main content

How to fix: Clipboard API Referenced

The page references navigator.clipboard or document.execCommand('copy'). This check only detects the API reference; it does not verify whether the call is gated behind user interaction. The single most common use of this API is a benign "copy to clipboard" button.

Why it matters

If genuinely ungated, reading the clipboard without user intent violates privacy since it may contain passwords, 2FA codes, or other sensitive data. Manually confirm the call site before treating this as a gesture-gating issue.

Clipboard read/write must be triggered by user gesture and clearly communicate why it needs clipboard access.

How to fix it

  1. 1Only call navigator.clipboard.readText() in response to an explicit user gesture
  2. 2Explain to users why clipboard access is needed
  3. 3Prefer clipboard.write() over read() where possible

Code examples

Request clipboard access with user gesture

JavaScript
// Always request clipboard inside a user gesture handler
document.querySelector('#copy-btn').addEventListener('click', async () => {
  try {
    await navigator.clipboard.writeText(text);
  } catch (err) {
    console.warn('Clipboard access denied:', err);
  }
});

References

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

See every content check

Questions

How severe is Clipboard API Referenced?
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-access, 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 clipboard api referenced

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

How to fix: Clipboard API Referenced | VulnRadar