React App Security Checklist: Front-End Risks That Matter

The React security issues that actually cause breaches — XSS escapes, leaked secrets, unsafe URLs, token storage and dependency risk — and how to fix them.

Yrzo AI28 November 2026 2 min read

The front end is not the security boundary

The most important rule in React security: anything in the browser can be read and changed by the user. Hiding a button is not access control. Every real check must happen on the server. With that in mind, these are the front-end issues that still matter.

1. Avoid dangerouslySetInnerHTML (or sanitise first)

React escapes text by default, which blocks most cross-site scripting. dangerouslySetInnerHTML turns that protection off. If you must render HTML from users or a CMS, sanitise it with a well-maintained library first.

2. Validate URLs before using them in href or src

React does not stop javascript: URLs in all cases. If a link or redirect target comes from user input or the query string, allow only https: and relative paths. See open redirects.

3. Keep secrets out of the bundle

Anything in your JavaScript bundle is public, including build-time environment variables. Use only publishable keys in the front end and proxy everything else through your server. See API keys exposed in JavaScript.

4. Store tokens carefully

Tokens in localStorage can be stolen by any XSS. Prefer HttpOnly, Secure, SameSite cookies managed by the server — see cookie security flags and session hijacking.

5. Never trust client-side authorisation

Is your site exposed to this?

Run a free, non-intrusive check of what attackers can see from outside. No account needed.

Routes, menus and buttons can be hidden for usability, but the API must enforce permissions. Test by calling your API directly with a different user's IDs — see broken access control.

6. Do not leak data in API responses

It is common for an API to return a full user object while the UI shows only a name. Everything returned is visible in the network tab. Return only what each screen needs.

7. Set a Content-Security-Policy

A CSP limits which scripts can run, reducing the impact of any XSS that slips through. See Content-Security-Policy explained.

8. Watch your dependencies

A typical React app pulls in hundreds of packages. Keep them updated, remove unused ones, and be wary of new packages with few downloads. See supply chain attacks.

9. Lock down third-party scripts

Analytics, chat and A/B testing scripts run with full page access. Load as few as possible and use Subresource Integrity where you can.

Test the whole app, not just the front end

Most React app vulnerabilities show up in the API behind it. Yrzo AI tests both together — see plans or start with a free scan.

Related reading: Next.js Security Best Practices: A Practical Checklist · Cookie Security Flags Explained: Secure, HttpOnly and SameSite · API Keys Exposed in JavaScript: How to Find and Fix Them

React security checklistReact app securityReact XSS preventionsecure React application
Share

Check your own website in 60 seconds

Free check, no account needed. Want the full picture? Full reports start at £149, with up to 110 checks with a 14-day money-back guarantee.

Keep reading