plantuml
@startuml
actor Developer
participant "Browser" as Browser
participant "API Server" as API
participant "CDN" as CDN
participant "CSP Engine" as CSP
Developer -> Browser: Request /app
Browser -> API: GET /app
API -> API: Generate nonce: 'xyz123'
API -> Browser: HTML + CSP: style-src-elem 'nonce-xyz123' 'self' https://cdn.example.com
Browser -> Browser: Parse HTML
Browser -> Browser: Find <style nonce="xyz123">
Browser -> CSP: Validate style element
CSP -> CSP: Check nonce: matches 'xyz123'
CSP -> Browser: Allow style element
Browser -> Browser: Apply inline styles
note right: Critical CSS angewendet
Browser -> Browser: Find <link rel="stylesheet" href="/app.css">
Browser -> CSP: Validate stylesheet source
CSP -> CSP: Check origin: same-origin ('self')
CSP -> Browser: Allow stylesheet load
Browser -> API: GET /app.css
API -> Browser: CSS content
Browser -> Browser: Apply external styles
Browser -> Browser: Find <link href="https://cdn.example.com/lib.css">
Browser -> CSP: Validate external stylesheet
CSP -> CSP: Check domain: cdn.example.com in whitelist
CSP -> Browser: Allow
Browser -> CDN: GET /lib.css
CDN -> Browser: CSS content
Browser -> Browser: Find <style> (kein Nonce)
Browser -> CSP: Validate style element
CSP -> CSP: No nonce, 'unsafe-inline' not set
CSP -> Browser: Block style element
Browser -> Browser: CSP violation logged
note right: Potentielle CSS-Injection verhindert
Browser -> Browser: Find <div style="...">
Browser -> CSP: Check style-src-attr (not style-src-elem)
note right: style-src-elem kontrolliert\nnur <style> und <link>
@enduml