HTML Canvas `toDataURL()` SecurityError: Tainted canvases may not be exported
Canvas drew a cross-origin `<img>` or external `<svg>` lacking CORS headers.
Runs locally in browser
Free · No login
Independently Verified 2026-11-25
v4.1.0
Identifier: HTML Canvas `toDataURL()` SecurityError
Platform: Web
Common Root Causes:
- Canvas drew a cross-origin `<img>` or external `<svg>` lacking CORS headers.
Interactive Diagnostic Checklist
Verified Solutions:
- Serve images same-origin or with `Access-Control-Allow-Origin` + `img.crossOrigin = "anonymous"`.
Safe Diagnostic Command:
Check crossOrigin="anonymous" and Access-Control-Allow-Origin
Warning: Verify configuration changes in staging or with dry-run flags (e.g. nginx -t) before reloading production services.
Technical Explanation
Canvas drew a cross-origin `<img>` or external `<svg>` lacking CORS headers. Recommended diagnostic: `Check crossOrigin="anonymous" and Access-Control-Allow-Origin`. Remediation: Serve images same-origin or with `Access-Control-Allow-Origin` + `img.crossOrigin = "anonymous"`.
Worked Examples
- Run `Check crossOrigin="anonymous" and Access-Control-Allow-Origin` to verify root cause before applying the remediation.
Limitations & Assumptions
- Always verify configuration changes in staging or with dry-run flags (e.g. `nginx -t`) before reloading production services.
Source References & Verification
Resource ID: err-svg-external-image-blocked-canvas · Independently verified: 2026-11-25