Overview
Course content rendered in WebView (rich text descriptions, embedded assignments, interactive HTML lessons) requires a comprehensive Content Security Policy to prevent XSS, clickjacking, and data exfiltration. Beyond the basic CSP issue (tracked separately), this enhancement establishes a reusable SecureWebView wrapper with configurable CSP levels for different content trust tiers.
Specifications
Features:
SecureWebView wraps WebView with configurable CSP injection
- Three trust tiers:
restricted (no scripts), interactive (inline scripts from allowlist), trusted (course platform content)
- CSP injected via
injectedJavaScriptBeforeContentLoaded as meta tag
- Referrer policy set to
no-referrer
- X-Frame-Options equivalent via WebView
originWhitelist
Tasks:
- Define CSP strings for each trust tier in
src/config/security.ts
SecureWebView accepts trustLevel prop ('restricted' | 'interactive' | 'trusted')
- Inject meta CSP tag before any content loads
- Set
originWhitelist to platform domains only for interactive and trusted tiers
- Add unit tests for each tier's CSP injection
Impacted Files:
src/components/common/SecureWebView.tsx (create or expand)
src/config/security.ts
Acceptance Criteria
restricted tier blocks all inline scripts
interactive tier allows scripts from defined allowlist domains only
- CSP meta tag appears before any HTML content
- Unit tests confirm correct CSP string for each trust tier
Overview
Course content rendered in WebView (rich text descriptions, embedded assignments, interactive HTML lessons) requires a comprehensive Content Security Policy to prevent XSS, clickjacking, and data exfiltration. Beyond the basic CSP issue (tracked separately), this enhancement establishes a reusable
SecureWebViewwrapper with configurable CSP levels for different content trust tiers.Specifications
Features:
SecureWebViewwrapsWebViewwith configurable CSP injectionrestricted(no scripts),interactive(inline scripts from allowlist),trusted(course platform content)injectedJavaScriptBeforeContentLoadedas meta tagno-referreroriginWhitelistTasks:
src/config/security.tsSecureWebViewacceptstrustLevelprop ('restricted' | 'interactive' | 'trusted')originWhitelistto platform domains only forinteractiveandtrustedtiersImpacted Files:
src/components/common/SecureWebView.tsx(create or expand)src/config/security.tsAcceptance Criteria
restrictedtier blocks all inline scriptsinteractivetier allows scripts from defined allowlist domains only