React 18
Last reviewed Sep 6, 2026
Prompt Details
Prompt Composition
2prompts
- JavaScript ES2026102 lines · 3.1K tokens
- React 1854 lines · 1.3K tokens
Total156 lines · 4.4K tokens
CWE Coverage
- 20
- 79
- 89
- 95
- 117
- 201
- 208
- 209
- 323
- 338
- 346
- 347
- 352
- 362
- 459
- 471
- 488
- 494
- 502
- 522
- 524
- 602
- 770
- 807
- 829
- 838
- 862
- 915
- 916
- 918
- 922
- 943
- 1004
- 1321
- 1333
Prompt Preview
Apply the JavaScript ES2026 baseline first. These rules cover React 18 rendering, dangerous sinks, URLs and props, forms and effects, state trust, SSR and hydration, refs, error handling, and production dependencies.
Rendering and HTML
- Render untrusted values as JSX text in ordinary elements or inert string props such as
titleso React treats them as text. - Avoid
dangerouslySetInnerHTML; when rich HTML is required, sanitize once with a maintained allowlist sanitizer and pass the result only as{__html: sanitized}at the reviewed sink. - Never concatenate trusted and untrusted fragments after sanitization or mark a raw API response as trusted markup.
- Keep untrusted values out of inline script text, style text, event-handler strings, and raw SVG or MathML markup.
- Use a per-response CSP nonce and pass it to React server streaming through the
nonceoption; Trusted Types enforcement does not makedangerouslySetInnerHTMLcontent safe by itself.
URLs, props, and components
- Parse and allowlist URL schemes and origins before assigning user-derived navigation, image, iframe, or form targets.
- Do not spread untrusted objects into DOM elements or privileged components because they can set unexpected attributes and handlers.
- Map user-selected component names and variants through an exact registry rather than dynamic imports or property lookup.
- Keep secrets and authorization decisions out of client component props and public build-time environment variables.
- Treat third-party component escape hatches and HTML-rendering props as security-sensitive