home / skills / harborgrid-justin / lexiflow-premium / react-18-security-modeling
/frontend/.github-skills/react-18-security-modeling
This skill helps identify and mitigate XSS risks in React 18 streaming and hydration, enforcing safe HTML handling and CSP alignment.
npx playbooks add skill harborgrid-justin/lexiflow-premium --skill react-18-security-modelingReview the files below or copy the command above to add this skill to your agents.
---
name: react-18-security-modeling
description: Model and mitigate security risks that arise from advanced rendering and hydration flows.
---
# React 18 Security Modeling
## Summary
Model and mitigate security risks that arise from advanced rendering and hydration flows.
## Key Capabilities
- Identify XSS risks in streaming SSR and hydration.
- Validate safe handling of HTML and serialized data.
- Apply content security policies aligned with React 18 behavior.
## PhD-Level Challenges
- Formalize a threat model for concurrent rendering flows.
- Prove safety of serialization/deserialization pipelines.
- Evaluate CSP trade-offs for streaming responses.
## Acceptance Criteria
- Provide a React-specific threat model document.
- Demonstrate mitigation of a simulated injection attack.
- Document CSP configuration and impact analysis.
This skill models and mitigates security risks introduced by React 18’s advanced rendering and hydration flows. It focuses on identifying injection and serialization weaknesses specific to streaming SSR, concurrent rendering, and client hydration. The output is practical guidance: threat models, mitigation patterns, and CSP recommendations tailored to React 18 behavior.
The skill inspects server-rendered HTML, streamed chunks, and serialized data passed to the client to locate XSS and injection vectors. It validates code paths that embed HTML or JSON into responses and tests hydration boundaries where untrusted data may be reinterpreted by the client. Finally, it produces CSP configurations and mitigation steps to harden streaming and hydration pipelines.
Why is streaming SSR riskier than traditional SSR?
Streaming interleaves content and can introduce new parsing boundaries where unescaped data or serialized fragments are interpreted by the browser, increasing XSS and injection risk.
Can CSP fully mitigate hydration risks?
CSP reduces many script-based exploits but cannot replace proper output encoding and safe serialization; use CSP alongside strict encoding and validation.