Interview Questions/System Design/Design an Online Code Execution Sandbox
AdvancedSystem-Design
45 min

Design an Online Code Execution Sandbox

SecurityContainersSchedulingObservability
Advertisement
Interview Question

Design a judge/sandbox to safely compile and run untrusted code in multiple languages with resource limits and scaling.

Key Points to Cover
  • Isolation via containers/VMs; seccomp, cgroups, namespaces
  • Job queue, autoscaling executors, warm pools
  • Language runtimes, caching of toolchains, layer reuse
  • Resource limits (CPU/mem/time/FS) and output capture
  • Abuse prevention, quotas, and audit logs
Evaluation Rubric
Strong isolation & sandboxing30% weight
Executor scaling & warm pools25% weight
Robust resource limiting & telemetry25% weight
Abuse/threat mitigation strategy20% weight
Hints
  • 💡Consider Firecracker/MicroVMs for stronger isolation.
Common Pitfalls to Avoid
  • ⚠️Insufficiently restrictive seccomp filters, allowing critical system calls that could be exploited.
  • ⚠️Inadequate resource limits imposed by cgroups, leading to denial-of-service or resource exhaustion attacks.
  • ⚠️Sharing file system layers or secrets between different untrusted executions, creating unintended trust relationships.
  • ⚠️Lack of proper input sanitization and validation for code submissions, potentially leading to injection attacks within the execution environment.
  • ⚠️Failing to monitor or alert on unusual system call patterns or resource spikes, which could indicate security breaches or bugs in the sandbox itself.
Potential Follow-up Questions
  • How to prevent fork bombs?
  • How to cache dependencies securely?
Advertisement