CSE Roadmap

Common tier · about 3 hours · 7 parts

Part 2 of 7 · 2 min read

Sandboxes

Think of a lab that handles a dangerous sample inside a sealed glove box. The worker is skilled, but if a vial breaks, the box holds the damage. The analogy stops in one place: the glove box wall is made of glass, while a software wall is made of rules, and a gap in a rule is a gap in the wall.

In plain words: A sandbox is a set of restrictions placed on a process so that, even if an attacker controls it, the process can do little harm. It does not try to prevent the take-over. It limits what follows. The kernel offers four kinds of wall, and this page takes one section each: limits on how much a process may use (resource limits), limits on which system calls it may make (seccomp), limits on what it can see (a changed root directory, and later namespaces) and limits set by a system-wide policy (security modules). A sandbox usually combines them, because each one has gaps that another fills.

A worked example. A program that converts uploaded images must read the upload, write the result, and use memory and time. It needs no network, no new processes and no access to other users' files. A sandbox for it would allow read, write and mmap, forbid connect and execve, cap memory and time, and give it a root directory that holds only its input and output folders. If a flaw in the image library lets an attacker run code, the attacker holds a process that can read one folder and write one folder.

The key lines. A sandbox is only as strong as its smallest gap. A list of allowed acts is safer than a list of forbidden acts, because a forgotten act on an allow list stays closed.

Sandbox

A sandbox is a restricted environment in which a program runs with limited access to resources, system calls, files and the network, so that the damage from a flaw or a malicious program stays inside the environment.

Example: an image converter that may read one folder, write one folder and make no network calls.

Check yourself: 1. What does a sandbox assume about the process? 2. Name the four kinds of wall in this page. 3. Why is an allow list safer than a deny list?