Navigating the Sandbox Buffet

Maxime Serrano (security engineer · Figma, Inc.)

USENIX Enigma Conference 2023 · Day 1 · Grand Ballroom

Overview

In his USENIX Enigma talk, "Navigating the Sandbox Buffet," Maxime Serrano, a security engineer at Figma, Inc., delves into the complex landscape of sandboxing and isolation technologies. The presentation addresses a prevalent challenge faced by modern SaaS companies: how to safely process untrusted user input and execute potentially dangerous code without compromising the entire system. Serrano argues that the increasing array of isolation techniques is not a sign of one being inherently superior, but rather an indication that each occupies a distinct point in the trade-off space, offering different balances of security, performance, and developer experience.

Watch on YouTube · Slides

Visual summary for Navigating the Sandbox Buffet by Maxime Serrano
Visual summary for Navigating the Sandbox Buffet by Maxime Serrano

Key moments

  1. 0:00 Introduction: The ImageTragick problem and sandboxing
  2. 3:36 Why RCE is dangerous for SaaS services
  3. 6:07 Virtualization (VMs): strong isolation, high performance cost
  4. 11:45 Process group isolation with Linux namespaces/containers
  5. 13:58 seccomp challenges: kernel attack surface, developer experience
  6. 16:35 Single process isolation using strict seccomp
  7. 19:00 Future: RLBox for function-level sandboxing

Navigating the Sandbox Buffet

Speakers: Maxime Serrano, Security Engineer, Figma, Inc.

Conference: USENIX Enigma

YouTube: https://www.youtube.com/watch?v=KXZKaz4epgg

Overview

In his USENIX Enigma talk, "Navigating the Sandbox Buffet," Maxime Serrano, a security engineer at Figma, Inc., delves into the complex landscape of sandboxing and isolation technologies. The presentation addresses a prevalent challenge faced by modern SaaS companies: how to safely process untrusted user input and execute potentially dangerous code without compromising the entire system. Serrano argues that the increasing array of isolation techniques is not a sign of one being inherently superior, but rather an indication that each occupies a distinct point in the trade-off space, offering different balances of security, performance, and developer experience.

The core premise of the talk is illustrated through a relatable scenario: a SaaS company processing user-uploaded images. What appears to be an innocuous image resizing function can quickly become a critical security vulnerability if it relies on complex, unmanaged third-party libraries like ImageMagick, which has a history of critical vulnerabilities, including the infamous ImageTragick (CVE-2016-3714). Such vulnerabilities can lead to arbitrary code execution, granting attackers unauthorized access to sensitive data or internal network resources.

Serrano's talk aims to guide security practitioners and developers through the decision-making process for choosing appropriate isolation strategies. By framing the discussion around a "security onion" with progressively deeper layers of isolation—from operating system virtualization to process group isolation and finally, single-process syscall filtering—he provides a practical framework for understanding the strengths and weaknesses of each approach. The ultimate goal is to enable the safe execution of untrusted code at scale, balancing robust security with the demanding requirements of high throughput, low latency, and a transparent, manageable developer workflow.

Background

▶ Watch: Introduction: The ImageTragick problem and sandboxing (0:00)

The necessity for robust code isolation stems from a fundamental security challenge: the execution of untrusted or "scary" code within a production environment. Scary code, as defined by Serrano, includes any software that processes complicated data formats, is written in unmanaged languages (like C/C++), calls out to untrusted sub-processes, or accepts arbitrary, complex user input. While hardening this code—through input format restrictions, rewriting in memory-safe languages, or extensive auditing—is a valid strategy, it often demands significant engineering investment that may not align with a company's core competencies or resource availability. For many SaaS companies, image resizing or video transcoding is a feature, not their primary product, making extensive hardening of third-party libraries impractical.

This leads to the alternative: isolation. The talk highlights why Remote Code Execution (RCE) is particularly problematic in a server-side context, contrasting it with client-side code execution (e.g., JavaScript in a browser). On a SaaS server, arbitrary code execution grants an attacker a potent set of privileges:

  • Access to process memory: An attacker could read sensitive data from other users or internal systems. Serrano cites a past Yahoo bug where a crafted image could return another user's recently uploaded image.
  • Access to local disk: Servers often store secrets (API keys, credentials) or cached data. RCE can allow an attacker to exfiltrate this information.
  • Privileged network position: An exploited server might be able to communicate with internal services, databases, or other sensitive infrastructure that is otherwise inaccessible from the public internet, facilitating lateral movement or data exfiltration.

The objective of isolation, therefore, is to systematically revoke these dangerous privileges. However, this must be achieved within strict operational constraints. For high-volume services like video transcoding or image processing, solutions must offer high throughput and low latency. Crucially, they must also be transparent to end-users and manageable by non-specialist engineers. Security solutions that significantly increase operational costs (e.g., by reducing throughput by 5%) or introduce undue complexity for feature developers are often resisted or poorly implemented. The talk thus explores a spectrum of isolation techniques, each representing a different layer in the "security onion," attempting to balance these competing demands.

Key Findings

▶ Watch: Virtualization (VMs): strong isolation, high performance cost (6:07)

Maxime Serrano's exploration of sandboxing technologies reveals several critical insights regarding the practical application of isolation in a production SaaS environment:

  1. No Universal Solution: The most significant finding is that there is no single "best" sandboxing technology. Instead, different approaches occupy distinct points in a multi-dimensional trade-off space. The optimal choice depends heavily on the specific threat model, performance requirements, and the nature of the code being isolated.
  2. Trade-offs are Inherent: Every layer of the "security onion" — from operating system virtualization down to single-process syscall filtering — involves inherent trade-offs between security strength, performance overhead, and developer experience. Stronger isolation often comes at the cost of higher latency or reduced throughput, while performance gains might introduce greater complexity or a larger attack surface.
  3. Developer Experience is Critical: Beyond raw security and performance metrics, the ease of development, debugging, and monitoring significantly impacts the adoption and effective implementation of isolation solutions. Systems that are difficult to troubleshoot or integrate into existing workflows will likely lead to resistance, workarounds, or security gaps. The talk highlights how subtle environmental differences (e.g., vdso for syscalls) can dramatically impact developer predictability.
  4. Linux Kernel as an Attack Surface: While Linux namespaces offer significant isolation benefits for process groups, the shared kernel itself presents a large and complex attack surface. Relying solely on namespaces without additional mitigations like Seccomp BPF leaves a considerable window for sandbox escapes.
  5. Granular Control vs. Applicability: As isolation becomes more granular (e.g., strict Seccomp), performance improves dramatically, but the applicability narrows. Very strict sandboxes are ideal for specific, well-understood tasks but become impractical for complex applications relying on diverse libraries or hardware interactions (like GPU processing).
  6. Future of Isolation: The talk points to active research in even deeper layers of isolation, such as function-level sandboxing (e.g., Mozilla's RLBox), suggesting a continued trend towards more fine-grained control over untrusted code execution.

These findings underscore the need for a nuanced, analytical approach to selecting and implementing sandboxing strategies, moving beyond a simplistic "more security is better" mindset to one that carefully evaluates the specific context and requirements.

Technical Deep Dive

▶ Watch: Process group isolation with Linux namespaces/containers (11:45)

The talk systematically dissects three primary levels of code isolation, moving from the broadest to the most granular, each with its own technical underpinnings, advantages, and limitations.

1. Operating System Isolation (Virtualization)

At the outermost layer of the security onion, virtualization offers the strongest form of isolation by providing a completely separate operating system environment for each untrusted task.

  • Mechanism: When a user request (e.g., image resize) comes in, a new Virtual Machine (VM) instance is initialized. The untrusted code runs within this VM, processes the input, and returns the result. The VM is then typically destroyed or reset. This is analogous to "buying a new machine for every user request," but virtualized to be economically feasible.
  • Isolation Strength: This approach provides extremely strong isolation. Because each VM is a separate machine instance, the hypervisor can strictly control its access to the host's disk, network, and other resources. An exploit within one VM is theoretically contained to that VM and cannot affect other VMs or the host system. Developers are often familiar with this model as cloud environments extensively use VMs.
  • Performance Trade-offs: The primary drawback is performance. VM startup times can be substantial, ranging from "seconds to minutes," depending on the VM's complexity and configuration. For operations that are intrinsically fast (like resizing a small image), the runtime is dominated by startup overhead. This significantly impacts throughput and latency.
  • Developer Experience: While developers are familiar with writing code for VMs, debugging and monitoring in a highly ephemeral VM environment can be challenging. Attaching debuggers or collecting detailed logs often requires "punching holes" (e.g., running additional daemons, opening network ports) in the VM's isolation, potentially weakening security guarantees.
  • Mitigations: To address performance, strategies include pre-warming instances (freezing a VM after startup but before processing, then rapidly unfreezing it for requests) or softening isolation requirements. The latter involves processing multiple requests from the same user or organization on a single, longer-lived VM, trading some isolation for improved performance by amortizing startup costs across many tasks. This introduces a probabilistic security trade-off.

2. Process Group Isolation (Linux Namespaces and Seccomp BPF)

Moving deeper, process group isolation focuses on sandboxing a collection of related processes, typically using Linux namespaces.

  • Mechanism: Instead of a full VM, this approach leverages kernel features to give a process (or group of processes) its own isolated view of system resources. Tools like Google's nsjail are used to create these sandboxed environments. When untrusted code is executed, a new process is forked and execd within its own set of namespaces.
  • Isolation Strength: Namespaces provide isolation for various system resources:
  • PID namespace: A separate process tree, so the sandboxed process cannot see or interfere with host processes.
  • Mount namespace: A distinct view of the file system, preventing access to the host's underlying disk unless explicitly mounted.
  • Network namespace: A separate network stack, allowing strict control over network access.
  • User namespace: Can map UIDs/GIDs to different values, enhancing privilege separation.
  • Since a fork and exec creates a new process, memory reuse from the parent process is not an issue.
  • Performance: Performance is significantly better than virtualization, with startup times typically in the "milliseconds to deciseconds" range. This makes it suitable for many latency-sensitive operations.
  • Developer Experience: Standard observability tools (system logs) generally work better, as the underlying operating system is shared. Debugging tools like ptrace can be made to work with proper configuration, though application-specific logs still require careful handling.
  • Attack Surface and Mitigation: The primary security concern here is the shared Linux kernel. The kernel is a large, complex codebase written in C, presenting a substantial attack surface for sandbox escapes (e.g., through kernel vulnerabilities or unexpected interactions). To mitigate this, Seccomp BPF (Secure Computing Berkeley Packet Filter) is employed. Seccomp BPF allows administrators to define a whitelist of permitted syscalls (system calls) that a process can make to the kernel, and even restrict arguments to those syscalls. This drastically reduces the attack surface by preventing unauthorized kernel interactions.
  • Challenges with Seccomp BPF: Configuring Seccomp BPF correctly is complex and can lead to subtle bugs. Serrano recounts an incident where their initial Seccomp profile failed to whitelist syscalls for getting the "current time of day." This wasn't an issue in local development because the kernel loaded a special library called vdso (virtual dynamically linked shared object) into memory, allowing time-related calls to be faked in user space. However, in production, with a different kernel configuration, the vdso was not loaded, forcing direct syscalls that were then blocked, causing failures. Such environmental discrepancies are difficult for developers to predict.

3. Single Process Isolation (Strict Seccomp)

The deepest layer discussed involves isolating code within a single process, leveraging an extremely restrictive Seccomp profile.

  • Mechanism: This approach builds on the concept of Seccomp BPF but applies a very minimal whitelist of syscalls. For an image resizing task, this might include only syscalls for memory allocation (mmap), reading from already open file descriptors (read), writing to already open file descriptors (write), and exiting (exit). This is similar to the original Seccomp v1 specification, which only allowed read, write, exit, and sigreturn, but crucially, Seccomp v1 did not allow memory allocation, which is often required at runtime. Modern strict Seccomp implementations address this.
  • Isolation Strength: This offers extremely granular isolation, as the process can only perform the bare minimum operations required for its task. Any attempt to make an unwhitelisted syscall results in immediate termination of the process.
  • Performance: Performance is excellent. The overhead is minimal, primarily limited to process forking, executing the binary, applying the Seccomp filter, and data serialization. This makes it ideal for very high-throughput, low-latency tasks.
  • Limitations and Applicability: The major downside is its very narrow applicability. "Not all programs fit cleanly into this box." While custom-written code in unmanaged languages can sometimes be refactored to fit, complex third-party libraries (e.g., those requiring GPU access, advanced networking, or extensive file system interactions for OCR or machine learning) will almost certainly require a broader set of syscalls that cannot be safely whitelisted. Debugging failures is also challenging, as a Seccomp violation simply terminates the process, making root cause analysis difficult without extensive logging.
  • Figma's Use Case: Figma successfully deployed this approach for specific tasks like server-side rendering of files, where the processing logic is well-understood and tightly controlled.

Deeper Isolation: Function/Library Level

Serrano briefly touches upon an even deeper layer of isolation, an active research area: function or library-level isolation.

  • Mechanism: The idea is to recompile specific parts of a program (e.g., a dangerous image parsing library) such that individual functions or libraries have their privileges limited, even though they run within the same process's memory space. This prevents a compromised library from accessing other parts of the program's memory or making unauthorized syscalls.
  • Example: Mozilla, in collaboration with UCSD and the University of Texas, has developed a system called RLBox that exemplifies this approach.
  • Status: While promising, this level of isolation is highly complex to implement and manage. Figma has not yet deployed such systems in production but expresses excitement about their potential.

Demo / Proof of Concept

▶ Watch: Single process isolation using strict seccomp (16:35)

While the talk didn't feature a live demonstration of a specific exploit or a sandbox escape, it effectively used the ImageMagick vulnerability, specifically ImageTragick (CVE-2016-3714), as a foundational example to illustrate the dangers of processing untrusted input with vulnerable libraries. The narrative structure of the presentation itself served as a conceptual "proof of concept" by walking through a hypothetical SaaS company's journey of implementing progressively stronger isolation techniques.

Serrano referenced tools like nsjail (a Google tool that leverages Linux namespaces for jailing processes) and discussed the practical implementation of Seccomp BPF for syscall filtering. These are real-world tools and techniques used for sandboxing, demonstrating the practical application of the concepts discussed. The speaker's anecdotes, such as the vdso issue encountered with Seccomp BPF in production, highlight the subtle complexities and real-world challenges of implementing these security measures, serving as a form of experiential "proof" of the trade-offs involved. The talk focused more on the architectural and decision-making aspects of sandboxing rather than a direct, interactive demonstration of a specific exploit or a sandboxed environment.

Defensive Implications

▶ Watch: Future: RLBox for function-level sandboxing (19:00)

The insights from "Navigating the Sandbox Buffet" provide crucial defensive implications for organizations handling untrusted code:

  1. Tailor Isolation to Threat Model: Defenders must rigorously define their threat model and understand the specific risks posed by their "scary code." This includes identifying the input formats, languages used, and external dependencies. A one-size-fits-all approach to sandboxing is ineffective and inefficient.
  2. Embrace the Trade-off Mindset: Recognize that every isolation strategy involves a balance between security, performance, developer experience, and operational complexity. Security teams should work with engineering teams to find the optimal balance that meets business needs without compromising critical security postures. A 5% performance hit from a security layer might be acceptable for some workloads but disastrous for others.
  3. Prioritize Developer Experience: Security solutions must be transparent, debuggable, and predictable for developers. Complex configurations, opaque failures, or arduous debugging processes will lead to developer frustration and potential workarounds that undermine security. Investing in tooling and clear documentation for isolated environments is paramount.
  4. Layer Defenses (The Security Onion): While the talk presents distinct layers, a robust defense often involves combining elements. For instance, using Linux namespaces for process group isolation should almost always be complemented with Seccomp BPF to reduce the kernel's attack surface.
  5. Rigorously Test Seccomp Profiles: The vdso anecdote highlights the critical need to test Seccomp BPF profiles across all environments – development, staging, and production. Subtle differences in kernel configuration, library versions, or system setup can lead to unexpected syscall behavior and runtime failures. Automated testing that covers various execution paths within the sandboxed code is essential.
  6. Consider Virtualization for Highest Risk/Lowest Throughput: For extremely sensitive workloads or those with lower throughput requirements, virtualization (e.g., per-request ephemeral VMs) offers the strongest isolation and should be considered, despite its performance overhead. Techniques like VM pre-warming can mitigate some latency issues.
  7. Leverage Strict Seccomp for Specific Tasks: For highly controlled, self-contained processing tasks where the exact syscall requirements are known and minimal (e.g., Figma's server-side rendering), strict Seccomp can provide excellent performance and strong isolation. However, its limited applicability means it's not a general-purpose solution.
  8. Monitor Emerging Technologies: Keep an eye on active research in deeper isolation techniques like function-level sandboxing (e.g., RLBox). As these technologies mature, they could offer even more granular control and a better balance of security and performance for complex applications.
  9. Don't Forget the Basics: While focusing on advanced isolation, fundamental security practices like input validation, least privilege, and regular patching of underlying systems (including the Linux kernel) remain crucial. Sandboxing is a powerful defense-in-depth mechanism, not a silver bullet.

Key Takeaways

  • Isolation is Essential: Safely processing untrusted user input and executing potentially dangerous code requires robust isolation mechanisms to prevent Remote Code Execution (RCE) and unauthorized data access.
  • No One-Size-Fits-All Solution: The choice of sandboxing technology depends on a nuanced evaluation of security requirements, performance goals (throughput, latency), and developer experience. Each approach has distinct trade-offs.
  • Virtualization for Strongest Isolation: Full VM-based isolation offers the highest security guarantees but comes with significant performance overhead due to high startup times (seconds to minutes), best suited for less latency-sensitive or extremely high-risk tasks.
  • Namespaces + Seccomp BPF for Balance: Linux namespaces provide good process group isolation with better performance (milliseconds to deciseconds startup). However, the shared Linux kernel presents a large attack surface, necessitating Seccomp BPF to whitelist syscalls and enhance security.
  • Strict Seccomp for High Performance, Limited Scope: Applying very restrictive Seccomp profiles offers excellent performance by allowing only minimal syscalls. This is ideal for simple, custom-written, well-understood tasks (like server-side rendering) but has limited applicability for complex programs or third-party libraries.
  • Developer Experience is Paramount: The practicality and success of any isolation strategy hinge on its transparency, debuggability, and predictability for developers. Hidden complexities, like the vdso example with Seccomp, can undermine effective deployment.

About the Speaker(s)

Maxime Serrano is a security engineer at Figma, Inc. His work involves securing Figma's products and infrastructure, with a particular focus on addressing challenges related to processing untrusted data and ensuring code integrity in a large-scale SaaS environment.

Reviews

Dr. Zero (Offensive Security Researcher) — SOLID

A competent but foundational walk through the standard SaaS isolation playbook. If you've built sandboxes in the last decade, you already know the trade-offs between VMs, namespaces, and strict seccomp. Still, it's honest engineering work without the vendor bullshit.

Heather Calloway (CISO) — SOLID

A clear, unsentimental look at the architectural trade-offs required to safely process untrusted user uploads. It gives security leadership a practical framework for negotiating isolation requirements with engineering without destroying platform performance or developer velocity.

→ Top-rated talks at USENIX Enigma Conference 2023

All talks from USENIX Enigma Conference 2023