Skip to content

[Enhancement] Add WebView Content Security Policy header injection for all course content #669

Description

@RUKAYAT-CODER

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

Metadata

Metadata

Assignees

Labels

Stellar WaveIssues in the Stellar wave programenhancementNew feature or requestsecuritySecurity vulnerability or concern

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions