| name | stackblitz-security-basics |
| description | Secure WebContainer deployments: CSP headers, sandbox isolation, input validation.
Use when working with WebContainers or StackBlitz SDK.
Trigger: "stackblitz security".
|
| allowed-tools | Read, Write, Grep |
| version | 1.5.0 |
| license | MIT |
| author | Jeremy Longshore <jeremy@intentsolutions.io> |
| tags | ["saas","ide","webcontainers","stackblitz"] |
| compatibility | Designed for Claude Code |
StackBlitz Security Basics
Overview
Secure WebContainer deployments: CSP headers, sandbox isolation, input validation.
Instructions
Step 1: WebContainer Security Model
WebContainers run in the browser sandbox -- no access to host filesystem, network is limited to HTTP, and all code runs in the user's browser tab. Key security points:
Step 2: Validate User Input
function sanitizeFileTree(tree: FileSystemTree): FileSystemTree {
const sanitized: FileSystemTree = {};
for (const [name, entry] of Object.entries(tree)) {
if (name.includes('..') || name.startsWith('/')) continue;
if (name === '.env' || name.endsWith('.key')) continue;
sanitized[name] = entry;
}
return sanitized;
}
Step 3: Content Security Policy
Content-Security-Policy: default-src 'self'; script-src 'self' 'wasm-unsafe-eval'; frame-src https://*.webcontainer.io;
Security Checklist
Resources
Next Steps
For production, see stackblitz-prod-checklist.