{
  "id": "sandbox-computer-security",
  "title": "Sandbox (computer security)",
  "lang": "en",
  "source_lang": "en",
  "summary": "A sandbox is a restricted execution environment that limits software’s access to resources and contains the effects of untrusted or compromised code.",
  "category": "computer-science",
  "subcategory": "networks-security",
  "type": "concept",
  "aliases": [
    "Security sandbox",
    "sandboxed execution environment"
  ],
  "generated_at": "2026-11-05",
  "model": "pro/gpt-6.1-sol",
  "url": "https://aiwiki.page/en/sandbox-computer-security/",
  "translations": {
    "zh-Hans": {
      "url": "https://aiwiki.page/zh/sandbox-computer-security/",
      "json": "https://aiwiki.page/zh/sandbox-computer-security.json"
    }
  },
  "sections": [
    {
      "heading": "",
      "text": "A sandbox is an execution environment designed to restrict what a program can observe or change outside a defined boundary. In cybersecurity, sandboxing allows software to run with less authority than the user or system that launched it. Restrictions may cover files, network connections, devices, memory, communication with other programs, and consumption of computing resources. The purpose is to reduce the consequences of malicious behavior, software defects, or the execution of code whose trustworthiness is unknown.\n\nSandboxes are used in web browsers, mobile operating systems, cloud services, document viewers, software-testing systems, and facilities for examining malicious software. Their implementations range from restricted language runtimes to isolated processes and hardware-assisted virtual machines. These mechanisms provide different guarantees: an environment that protects host files may still permit network communication, while one that prevents persistent changes may not protect confidential information already visible inside it.\n\nA sandbox is therefore not a single technology or a guarantee that code is harmless. It is an arrangement of enforcement mechanisms, policies, and interfaces whose effectiveness depends on a stated threat model. Its central question is not merely whether a program can execute, but which effects that execution is authorized to have."
    },
    {
      "heading": "Security model and boundary design",
      "text": "The starting point for a sandbox is the distinction between untrusted computation and the resources it must not control. Untrusted code may be an entire executable, a document parser exposed to hostile input, an extension, or a small function supplied by another customer of a service. A strong design assumes that this code may behave arbitrarily within its execution environment. In particular, it does not rely on the code voluntarily avoiding forbidden operations after it has been compromised.\n\nSandbox policy is a specialized form of access control. It identifies resources and permitted operations: reading a particular directory, sending requests through a designated network service, or writing only to temporary storage. The principle of least privilege calls for granting only the authority required for the intended task. This differs from simply running a program under the current user’s account, which may expose that user’s documents, credentials, and application data even when administrative privileges are absent.\n\nA useful architectural distinction separates the policy decision from the enforcement mechanism. Policy may state that a document renderer cannot open arbitrary files; enforcement must ensure that every relevant path to file access respects that rule. The concept of a reference monitor captures three desirable properties: access checks should be unavoidable, resistant to modification by the restricted program, and sufficiently small or structured to permit analysis. The components whose correctness is necessary for the boundary form part of the trusted computing base. Depending on the design, this can include an operating-system kernel, a hypervisor, a runtime, and privileged helper services.\n\nMany practical sandboxes use a broker. The restricted process cannot perform a sensitive operation directly, but can send a request to a more privileged process through interprocess communication. The broker checks the request and performs only the authorized action. For example, it might supply a read-only handle to a file selected through a trusted file picker, rather than allowing arbitrary pathname access. This design reduces the authority permanently held by the restricted process, but makes the broker’s request parser and authorization logic security-critical.\n\nThree objectives must be distinguished. Confidentiality concerns information the sandbox must not reveal; integrity concerns objects it must not modify; availability concerns resources it must not exhaust. A policy that prevents writes does not necessarily prevent disclosure, and a process with no filesystem access may still consume excessive processor time. Sandboxing also differs from behavior detection: it can constrain a program without deciding whether that program is malicious. Conversely, detecting suspicious behavior does not itself establish an isolation boundary."
    },
    {
      "heading": "Historical development",
      "text": "Sandboxing grew from older work on protection domains, restricted execution, and the sharing of computers among mutually distrustful users. In time-sharing systems, hardware privilege levels and memory protection separated ordinary programs from supervisory software. These facilities established a basic pattern still used in modern sandboxes: less-trusted computation executes in a restricted domain and requests privileged services through controlled entry points. The resulting protection was originally organized largely around users and processes rather than individual documents or browser components.\n\nA major conceptual problem was articulated by Butler Lampson in his 1973 paper “A Note on the Confinement Problem.” Confinement asks how a service can be allowed to process confidential information without communicating that information to an unauthorized recipient. Lampson’s discussion highlighted that blocking obvious output channels is not enough: shared resources and indirect observations can also transmit information. This distinction remains important because practical sandboxes usually promise narrower restrictions than complete prevention of all information flow.\n\nThe Unix chroot facility, introduced in 1979, changed the apparent root directory used for pathname resolution. It became a useful ingredient in restricted environments, but changing a filesystem view is not equivalent to comprehensive containment. It does not by itself establish separate identities, network isolation, or broad restrictions on privileged operations. FreeBSD jails, introduced in FreeBSD 4.0 in 2000, developed a more extensive operating-system-level confinement mechanism by combining a restricted filesystem environment with additional process and networking controls.\n\nAnother line of development placed restrictions inside the execution engine. Robert Wahbe, Steven Lucco, Thomas Anderson, and Susan Graham presented software fault isolation in 1993, describing ways to confine machine-level code through validation and instrumentation. The appearance of Java in 1995 brought sandboxing to widespread attention through downloadable applets. A Java runtime could verify bytecode and mediate sensitive operations, allowing code obtained over a network to run with fewer privileges than an ordinary local application. The original model depended on the correctness of both runtime enforcement and the privileged libraries it exposed.\n\nIn the 2000s, increasingly complex network-facing software encouraged compartmentalization of native applications. Google Chrome, first released in 2008, made a sandboxed multiprocess browser architecture especially prominent. Mobile platforms established application-specific security domains, while cloud systems expanded demand for separating customer workloads. These developments did not replace earlier mechanisms with one universal design. Instead, they encouraged layered combinations of process isolation, language restrictions, operating-system policies, and virtualization, each addressing a different portion of the attack surface."
    },
    {
      "heading": "Operating-system enforcement",
      "text": "An operating system provides several building blocks for sandboxing. Ordinary processes generally have separate virtual address spaces, so one process cannot directly read or overwrite another’s memory. This separation is necessary but insufficient: processes running under the same identity may still share substantial access to files, network services, debugging interfaces, or other system facilities. A sandbox adds restrictions beyond the baseline process abstraction.\n\nOn Linux, namespaces alter the resources visible to a process. Different namespace types govern process identifiers, mount points, network stacks, hostnames, user and group identities, and other views of the system. A process in a separate network namespace can have its own interfaces and routing configuration; one in a separate mount namespace can see a deliberately limited filesystem layout. Namespaces primarily organize visibility and naming. They are commonly combined with Linux capabilities, security modules, and resource controls rather than treated as a complete security policy on their own.\n\nThe seccomp mechanism restricts interactions with the kernel through system calls. Its original mode, merged into Linux in 2005, permitted only a very small set of calls. The later seccomp filter facility allows programs to install rules expressed using classic Berkeley Packet Filter instructions. Depending on configuration and kernel support, a prohibited call can terminate the process, fail with an error, generate a trap, or be directed to a supervising mechanism. Filters can examine system-call numbers and argument values, but ordinary filtering does not safely interpret arbitrary objects referenced by user-space pointers. Consequently, filesystem policy generally needs additional mechanisms rather than pathname checks in a simple system-call filter.\n\nOther systems provide related controls through different security models. In Microsoft Windows, restricted access tokens, integrity levels, job objects, and AppContainer can contribute to sandbox construction. AppContainer, introduced with Windows 8, associates applications with restricted identities and declared capabilities. On Apple platforms, application sandboxing combines process credentials, entitlements, and system-enforced resource policies. OpenBSD’s pledge restricts the classes of operations a process may perform, while unveil restricts the filesystem paths it may access. These interfaces differ in policy expression, compatibility requirements, and the objects they protect.\n\nCorrect initialization is as important as the final restrictions. A process can inadvertently retain authority through inherited file descriptors, open network sockets, environment variables, or handles received from its parent. Restrictions must also cover subprocesses and newly created threads as intended. Resource accounting, such as control groups on Linux or job-object limits on Windows, addresses excessive memory use, processor consumption, and process creation. Because these designs normally share a host kernel, a reachable security vulnerability in that kernel can undermine the boundary even when the user-space policy is correctly configured."
    },
    {
      "heading": "Virtual machines, containers, and layered isolation",
      "text": "A virtual machine provides a software-defined computer in which a guest operating system can run. A hypervisor controls the guest’s access to processor execution, memory, and virtual devices. Hardware-assisted virtualization makes this practical by supporting controlled transitions between guest and host contexts and by separating guest memory mappings from host memory. A program confined within a guest normally encounters a guest kernel before it can affect host resources, creating a different boundary from a process sandbox that directly shares the host kernel.\n\nThis separation does not make every virtual machine an effective security sandbox. Shared folders, clipboard synchronization, device passthrough, host-management agents, and virtual networking can intentionally expose host capabilities. Device emulation and management interfaces also add privileged code that processes guest-controlled inputs. A virtual machine’s security properties therefore depend on its configuration and on which components remain reachable. A large desktop guest with extensive integration has a different exposure profile from a minimal guest running one service.\n\nAn operating-system container ordinarily isolates processes while sharing the host kernel. Containers commonly combine namespaces, resource controls, restricted credentials, and a packaged filesystem. They usually have lower startup and memory overhead than a conventional full guest, making them attractive for application deployment and cloud computing. However, packaging software in a container image does not automatically restrict it strongly. A container that has broad capabilities, access to sensitive host paths, or control over a host container-management service may possess extensive authority outside its apparent filesystem.\n\nIntermediate designs alter the trade-off. A microVM uses hardware virtualization with a deliberately reduced virtual hardware model. Firecracker, released as open-source software in 2018, is an example designed for lightweight workload isolation. Another approach, exemplified by gVisor, places a user-space implementation of much of the system-call interface between an application and the host kernel. Such designs aim to reduce direct exposure to host-kernel interfaces without requiring every workload to use an ordinary full-system guest. They differ in compatibility, performance, device support, and the size of the code that must be trusted.\n\nLayers are often combined. A service may execute inside a restricted process, inside a container, inside a virtual machine, with separate network policy outside the guest. This is an instance of defense in depth, but additional layers help only when their assumptions are understood. Two controls that depend on the same vulnerable kernel are not independent in the same way as controls enforced by distinct components. Operational features also cross boundaries: logging, image distribution, storage attachment, and orchestration may carry credentials or expose management functions. Isolation of the workload and protection of the control plane are related but separate requirements."
    },
    {
      "heading": "Language runtimes and software fault isolation",
      "text": "A language-based sandbox restricts execution through a programming language, its runtime, or an intermediate representation. Instead of allowing arbitrary native instructions and relying entirely on the operating system, it constrains which instructions, references, and operations a program can express. This can offer fine-grained isolation with relatively inexpensive transitions between components. Its effectiveness depends on enforcement surviving hostile programs, malformed input, and mistakes in privileged runtime code.\n\nMemory safety is an important foundation. A runtime that prevents out-of-bounds accesses and forged object references can stop a program from directly overwriting security metadata or obtaining arbitrary pointers. A type system and bytecode verifier can enforce structural rules before execution, while runtime checks handle properties that cannot be established in advance. Memory safety alone is not sandboxing, however. A memory-safe program with unrestricted file and network libraries may still have the full authority of its user. Security requires limiting the operations available through its libraries and host interfaces.\n\nThe historical Java sandbox combined bytecode verification, class loading rules, and checks on sensitive operations. The Security Manager supported permission decisions associated with executing code, but the design was complicated by privileged library operations and interactions among code with different permissions. Runtime defects and overly permissive interfaces could invalidate the intended restrictions. Java deprecated the Security Manager for removal in JDK 17 in 2021; it was permanently disabled in JDK 24 in 2025. Java’s managed execution model continues independently of that particular application-confinement mechanism.\n\nWebAssembly, first deployed in major browsers in 2017, illustrates a different restricted execution model. A module operates on validated instructions and, in the baseline model, accesses linear memory through bounds-checked operations. Calls to external facilities occur through imports supplied by the host. A module does not acquire arbitrary filesystem or network access merely by being valid WebAssembly; those capabilities depend on the embedding environment. The WebAssembly System Interface, or WASI, provides interfaces for non-browser environments, including designs that associate access with explicitly supplied resources. Runtime bugs and unsafe host bindings remain relevant even when the module format is well structured.\n\nSoftware fault isolation can apply related ideas to lower-level code. A compiler, binary rewriter, or validator ensures that memory accesses and control transfers remain within permitted regions. Google’s Native Client used such techniques to run native code under structural restrictions, with additional operating-system containment. Another approach is capability-based security, in which possession of an unforgeable reference grants authority to a particular object or service. These mechanisms can be complementary: a runtime preserves the integrity of references, while capability-oriented interfaces determine which resources a component can actually reach. The resulting boundary is only as narrow as the authority supplied through those references."
    },
    {
      "heading": "Browser and application sandboxes",
      "text": "A modern web browser processes large volumes of attacker-controlled input: markup, scripts, images, fonts, media, and network responses. Much of this work involves complex parsers and high-performance native code. Browser sandboxing therefore commonly assumes that a renderer may be compromised and attempts to prevent that compromise from becoming unrestricted control over the user’s machine. Rendering processes receive limited privileges, while more trusted processes coordinate windows, storage, downloads, and other sensitive operations.\n\nTwo different security boundaries coexist in a browser. The same-origin policy determines which web documents and scripts may interact, usually using a combination of scheme, host, and port. The operating-system sandbox limits the authority of the process executing that content. They are not interchangeable: a renderer confined from local files might still mishandle data belonging to another website. Site isolation addresses this problem by placing content from different sites into separate processes where required and by checking cross-process interactions. Chrome introduced broad desktop deployment of Site Isolation in 2018.\n\nBrowser privilege separation depends heavily on messages between processes. A renderer may ask a broker to open a resource, display a permission prompt, or access a device. The broker must not accept a renderer’s unsupported claim that a request comes from a particular site or reflects a user action. Sensitive state must be checked against trusted browser-side records. Graphics, media, and utility processes introduce further boundaries, often with different privileges because their tasks require different device access. Thus, “the browser sandbox” usually denotes several policies rather than one uniform enclosure.\n\nMobile systems apply related ideas to installed applications. Android ordinarily assigns applications distinct Linux user identities, separating their files and execution contexts, and combines this with application permissions and SELinux policy. iOS assigns applications sandboxed containers and uses entitlements and platform services to govern access to protected capabilities. A smartphone application may receive selected access to a photo, location data, or a device service without obtaining unrestricted access to another application’s private storage. Shared services and explicitly authorized communication remain possible, so application isolation does not mean applications are unable to cooperate.\n\nDesktop application sandboxes often use trusted selection interfaces to grant narrow access. A document portal or file picker can let an application work with a user-selected file without exposing an entire home directory. This is especially useful for viewers and editors that handle untrusted documents but legitimately need to save results. Permission prompts, however, are not an enforcement mechanism by themselves; a privileged component must translate approval into a restricted capability. Once confidential data has legitimately entered a sandbox, ordinary resource restrictions may not prevent every later disclosure, particularly if broad network communication is also authorized."
    },
    {
      "heading": "Malware analysis, testing, and hosted execution",
      "text": "In malware analysis, a sandbox is an instrumented environment used to observe suspicious software while limiting its effects. Analysts may record process creation, file changes, registry operations, network requests, and attempts to establish persistence. A full virtual machine is often useful because the sample can encounter a realistic operating system and application stack. Instrumentation can operate inside the guest, outside it, or at several layers, with different implications for visibility and resistance to interference.\n\nThe central benefit of dynamic analysis is that it reveals actions taken during an actual execution. A document may launch a child process only after being opened by a particular application; a program may decrypt additional code only after startup. Such behavior may be difficult to infer from static inspection alone. Nevertheless, an observed run is only one execution path. Lack of suspicious activity does not establish that a sample is benign, particularly when execution depends on specific inputs, remote responses, elapsed time, or environmental conditions.\n\nMalicious programs may attempt to detect analysis environments through virtual hardware characteristics, unusual process lists, lack of user activity, or timing behavior. They may delay execution or withhold later stages when expected conditions are absent. Conversely, highly realistic environments introduce more components and more possibilities for unintended interaction. Network access creates a particularly difficult trade-off: blocking it may hide behavior, while permitting it may allow harmful communication or interaction with real third-party systems. Controlled services and simulated responses can reveal some behaviors without reproducing every property of the public Internet.\n\nSandboxes also support ordinary software engineering. Automated tests can execute code in temporary environments, restrict filesystem changes, and discard state afterward. Security testing tools such as fuzzers benefit from containing crashes and other unintended effects caused by generated inputs. Hosted programming exercises, notebook services, and build systems use isolation to run code supplied by users. In build infrastructure, the execution boundary is especially important because dependency scripts and build tools may run with access to source trees, package registries, and deployment credentials.\n\nThese uses impose different policies. A malware-analysis environment prioritizes observation and controlled realism; a hosted code runner may prioritize fast startup, resource limits, and separation between customers. Execution of tools by an AI agent presents a related case: generated code can be confined from host files and credentials even if the model is induced to issue an inappropriate command. This limits execution authority but does not solve prompt injection or validate the meaning of permitted external actions. A service that allows a sandboxed program to send messages or modify a remote database must authorize those operations independently of local process containment."
    },
    {
      "heading": "Escapes, side channels, and assurance",
      "text": "A sandbox escape occurs when code crosses a boundary that was intended to constrain it. The immediate cause may be a kernel defect, an unsafe runtime operation, an error in a privileged broker, or a configuration that exposes unintended authority. An initial buffer overflow in a document parser may provide control over a restricted process, while a second vulnerability enables access outside that process’s sandbox. This is why application compromise and sandbox escape are often treated as separate stages, even though a single design defect can sometimes undermine both boundaries.\n\nNot every escape requires corruption of memory. A broker can become a confused deputy when it uses its own privileges on behalf of a requester without adequately checking that requester’s authority. Pathname checks are also vulnerable to inconsistencies between validation and use. In a race condition, a filesystem object or symbolic link may change after a check but before a privileged operation. Designs that operate on already-authorized handles can avoid some of these problems, but must still control handle transfer, duplication, and the rights attached to each handle.\n\nA side-channel attack extracts information from effects not intended as explicit communication. Shared processor caches, timing differences, memory pressure, and other resource interactions can reveal aspects of another computation. The Spectre vulnerabilities disclosed in 2018 demonstrated that speculative execution could undermine assumptions used by software isolation, including browser execution environments. Mitigations involve combinations of hardware changes, compiler transformations, reduced timer precision, and stronger separation of sensitive workloads. A policy that blocks file reads does not, by itself, establish the absence of microarchitectural information leakage.\n\nAvailability requires separate attention. A restricted process can still attempt a denial-of-service attack by consuming memory, creating excessive tasks, issuing expensive permitted requests, or filling shared storage. Limits on individual resources help, but shared services may experience effects that are difficult to attribute to one sandbox. Cleanup is another boundary condition: terminating execution does not automatically revoke credentials already disclosed, remove every external side effect, or erase data copied to an allowed destination. Snapshots and disposable filesystems restore selected state, not the entire history of interaction with outside systems.\n\nAssurance combines architectural analysis, implementation review, testing, and operational checks. Formal verification can establish particular properties of a kernel, runtime, or policy model, but the result applies to the specified system and assumptions rather than every surrounding device and service. Testing can examine whether forbidden operations fail, whether child processes inherit restrictions, and whether malformed broker messages are handled safely. Assessments also need to distinguish documented guarantees from incidental behavior: an operation that fails in one configuration is not necessarily prohibited by the security design. Small privileged interfaces, explicit authority transfer, and narrowly stated guarantees make these boundaries easier to inspect and evaluate."
    }
  ],
  "links": [
    "cybersecurity",
    "access-control",
    "least-privilege",
    "interprocess-communication",
    "time-sharing",
    "unix",
    "operating-system",
    "process-computing",
    "linux",
    "system-call",
    "microsoft-windows",
    "security-vulnerability",
    "virtual-machine",
    "virtualization",
    "cloud-computing",
    "defense-in-depth",
    "programming-language",
    "type-system",
    "compiler",
    "capability-based-security",
    "web-browser",
    "smartphone",
    "malware",
    "internet",
    "software-engineering",
    "ai-agent",
    "prompt-injection",
    "confused-deputy-problem",
    "race-condition",
    "side-channel-attack",
    "denial-of-service-attack",
    "formal-verification"
  ],
  "sources": [],
  "license": "https://creativecommons.org/licenses/by/4.0/"
}