Skip to content

Commit 9e277e8

Browse files
committed
feat: add benchmark script and threat model documentation
1 parent 54703d0 commit 9e277e8

2 files changed

Lines changed: 477 additions & 0 deletions

File tree

docs/threat-model.md

Lines changed: 199 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,199 @@
1+
# Threat Model
2+
3+
This document defines the security boundaries, assumptions, and limitations of Ignite's sandboxing capabilities.
4+
5+
## Security Goals
6+
7+
Ignite aims to provide **defense-in-depth** for executing untrusted JavaScript/TypeScript code:
8+
9+
| Goal | Mechanism |
10+
|------|-----------|
11+
| Prevent network exfiltration | `--network=none` in audit mode |
12+
| Prevent filesystem tampering | `--read-only` root filesystem |
13+
| Prevent privilege escalation | `--cap-drop=ALL`, `--no-new-privileges` |
14+
| Prevent resource exhaustion | Docker resource limits (planned) |
15+
| Contain malicious code | Docker container isolation |
16+
17+
## Trust Boundaries
18+
19+
```
20+
┌─────────────────────────────────────────────────────────────┐
21+
│ HOST SYSTEM │
22+
│ ┌───────────────────────────────────────────────────────┐ │
23+
│ │ DOCKER DAEMON │ │
24+
│ │ ┌─────────────────────────────────────────────────┐ │ │
25+
│ │ │ IGNITE CONTAINER │ │ │
26+
│ │ │ ┌─────────────────────────────────────────────┐│ │ │
27+
│ │ │ │ UNTRUSTED CODE ││ │ │
28+
│ │ │ │ ││ │ │
29+
│ │ │ │ This is where AI-generated or user code ││ │ │
30+
│ │ │ │ executes. Assume fully malicious. ││ │ │
31+
│ │ │ └─────────────────────────────────────────────┘│ │ │
32+
│ │ └─────────────────────────────────────────────────┘ │ │
33+
│ └───────────────────────────────────────────────────────┘ │
34+
└─────────────────────────────────────────────────────────────┘
35+
```
36+
37+
### Trusted Components
38+
- Host operating system and kernel
39+
- Docker daemon
40+
- Ignite CLI and runtime images
41+
- Container orchestration
42+
43+
### Untrusted Components
44+
- User-provided code (`index.ts`, `index.js`)
45+
- User-provided dependencies (`package.json`)
46+
- Any files in the service directory
47+
48+
## Kernel Assumptions
49+
50+
Ignite relies on Linux kernel security primitives:
51+
52+
| Primitive | Purpose | Assumption |
53+
|-----------|---------|------------|
54+
| namespaces | Process/network/mount isolation | Kernel correctly enforces namespace boundaries |
55+
| cgroups | Resource limits | Kernel correctly enforces limits |
56+
| seccomp | Syscall filtering | Kernel correctly filters syscalls |
57+
| capabilities | Privilege restriction | Kernel correctly drops capabilities |
58+
| OverlayFS | Read-only filesystem | Kernel correctly enforces read-only mounts |
59+
60+
### Kernel Version Requirements
61+
- Linux 4.x+ recommended
62+
- Docker 20.10+ for full security feature support
63+
- cgroups v2 preferred for resource limits
64+
65+
## What Ignite Protects Against
66+
67+
### In Audit Mode (`--audit`)
68+
69+
| Attack | Protection | Status |
70+
|--------|------------|--------|
71+
| Network data exfiltration | `--network=none` blocks all networking | ✅ Protected |
72+
| Writing malicious files to host | `--read-only` + bind mount restrictions | ✅ Protected |
73+
| Reading sensitive host files | No host filesystem access by default | ✅ Protected |
74+
| Privilege escalation via setuid | `--no-new-privileges` | ✅ Protected |
75+
| Capability abuse | `--cap-drop=ALL` | ✅ Protected |
76+
| Fork bombs / process exhaustion | Docker process limits | ✅ Protected |
77+
| Memory exhaustion | Docker memory limits | ⚠️ Configurable |
78+
| CPU exhaustion | Docker CPU limits | ⚠️ Configurable |
79+
| Disk exhaustion | tmpfs size limits | ⚠️ Configurable |
80+
81+
### In Normal Mode (without `--audit`)
82+
83+
| Attack | Protection | Status |
84+
|--------|------------|--------|
85+
| Container escape | Docker isolation | ✅ Protected |
86+
| Host filesystem access | No host mounts except service dir | ✅ Protected |
87+
| Network attacks | ⚠️ Network allowed | ❌ Not protected |
88+
| Writing to service directory | ⚠️ Allowed | ❌ Not protected |
89+
90+
## Explicit Non-Goals (Out of Scope)
91+
92+
Ignite does **NOT** protect against:
93+
94+
### 1. Docker Daemon Vulnerabilities
95+
If there's a container escape vulnerability in Docker itself, Ignite cannot prevent exploitation.
96+
97+
**Mitigation**: Keep Docker updated. Consider running Docker in rootless mode.
98+
99+
### 2. Kernel Vulnerabilities
100+
Kernel exploits that break namespace/cgroup isolation are outside Ignite's control.
101+
102+
**Mitigation**: Keep kernel updated. Consider gVisor or Kata Containers for defense-in-depth.
103+
104+
### 3. Side-Channel Attacks
105+
Spectre, Meltdown, and similar CPU-level attacks are not mitigated.
106+
107+
**Mitigation**: Use dedicated hardware for high-security workloads.
108+
109+
### 4. Resource Exhaustion (Without Limits)
110+
Without explicit resource limits, malicious code can consume CPU/memory.
111+
112+
**Mitigation**: Always set resource limits for production:
113+
```yaml
114+
# Future: ignite.policy.yaml
115+
resources:
116+
memory: 512M
117+
cpu: 0.5
118+
timeout: 30s
119+
```
120+
121+
### 5. Malicious Dependencies
122+
If untrusted code installs malicious npm packages, Ignite executes them.
123+
124+
**Mitigation**: Use `--audit` mode which blocks network during execution.
125+
126+
### 6. Time-of-Check to Time-of-Use (TOCTOU)
127+
Preflight checks happen before execution. Files could change between check and run.
128+
129+
**Mitigation**: Run preflight immediately before execution. Consider hash verification.
130+
131+
### 7. Cryptomining / Abuse During Execution
132+
Code can use CPU for mining during its allowed execution time.
133+
134+
**Mitigation**: Set strict CPU limits and timeouts.
135+
136+
## Threat Actors
137+
138+
| Actor | Capability | Example |
139+
|-------|------------|---------|
140+
| Naive malicious code | Basic file/network operations | `fs.writeFileSync('/etc/passwd', ...)` |
141+
| Sophisticated attacker | Kernel exploit attempts, container escapes | CVE exploitation |
142+
| AI-generated code | Unintentional dangerous operations | LLM hallucinating `rm -rf /` |
143+
| Supply chain attacker | Malicious npm packages | Typosquatting packages |
144+
145+
## Security Recommendations
146+
147+
### For Maximum Security
148+
149+
```bash
150+
# Always use audit mode for untrusted code
151+
ignite run ./untrusted-service --audit
152+
153+
# Set resource limits (when available)
154+
ignite run ./service --audit --memory=256M --timeout=10s
155+
```
156+
157+
### For Production Deployments
158+
159+
1. **Run Docker rootless** - Limits damage from container escapes
160+
2. **Use separate machines** - Don't run untrusted code on sensitive hosts
161+
3. **Enable seccomp profiles** - Additional syscall filtering
162+
4. **Monitor container behavior** - Log and alert on suspicious activity
163+
5. **Set strict timeouts** - Kill long-running code automatically
164+
165+
### Defense in Depth Stack
166+
167+
```
168+
Layer 1: Ignite audit mode (application level)
169+
Layer 2: Docker container isolation
170+
Layer 3: Linux namespaces/cgroups/seccomp
171+
Layer 4: (Optional) gVisor/Kata Containers
172+
Layer 5: Dedicated hardware / VM isolation
173+
```
174+
175+
## Future Security Enhancements
176+
177+
| Feature | Status | Description |
178+
|---------|--------|-------------|
179+
| Seccomp profiles | Planned | Block dangerous syscalls |
180+
| Resource limits | Planned | Memory, CPU, disk quotas |
181+
| gVisor support | Considered | User-space kernel for stronger isolation |
182+
| Network allowlists | Planned | Allow specific hosts only |
183+
| Read path restrictions | Planned | Block reading sensitive paths |
184+
185+
## Reporting Security Issues
186+
187+
Found a vulnerability? Please report responsibly:
188+
189+
1. **Do NOT** open a public GitHub issue
190+
2. Email security concerns to the maintainer
191+
3. Allow 90 days for fix before disclosure
192+
193+
## References
194+
195+
- [Docker Security Best Practices](https://docs.docker.com/engine/security/)
196+
- [Linux Namespaces](https://man7.org/linux/man-pages/man7/namespaces.7.html)
197+
- [Seccomp](https://man7.org/linux/man-pages/man2/seccomp.2.html)
198+
- [gVisor](https://gvisor.dev/)
199+
- [Kata Containers](https://katacontainers.io/)

0 commit comments

Comments
 (0)