Content Security Policy (CSP)
Last updated
Last updated
A Content Security Policy (CSP) is a security feature that helps protect web applications from various attacks like Cross-Site Scripting (XSS), clickjacking, and data injection. By specifying allowed content sources, CSPs minimize the risk of executing malicious content on your site.
The following is a partial CSP that covers WalletConnect's libraries and services for . Note that you may need to define additional sources based on your application's requirements.
info
You may need to list the RPC endpoints used by blockchain networks you have enabled (e.g. via the ) as part of your connect-src
definition.
For a full of list of RPC sources used by wagmi/viem
, please refer to .
Run through your standard user flows in a staging environment with CSP enforcement. This may include connecting to browser extension wallets, transacting, logging out, etc. Directives may need updates after SDK upgrades. Always test your CSP again before deploying updates to production.
Use the Content-Security-Policy-Report-Only
header, which sends violation reports without enforcing policies. This helps assess the impact of CSP changes without affecting functionality.
First deploy your CSP in report-only
mode. After validation, migrate to Content-Security-Policy
for enforcement.
Configure report-uri
or report-to
to receive violation reports and set up a monitoring dashboard for review.