> For the complete documentation index, see [llms.txt](https://ir0nstone.gitbook.io/notes/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://ir0nstone.gitbook.io/notes/binexp/memory-safety/sandboxing.md).

# Sandboxing

Sandboxing is a security mechanism for running untrusted code. The aim is to make a tightly-restricted, locked-down environment with minimal privileges, enforced by Operating System policies.

Inside the sandbox, access to sensitive resources - such as files, the network, devices, users or other processes - is restricted. This is a major part of the "[defence in depth](https://www.fortinet.com/uk/resources/cyberglossary/defense-in-depth)" philosophy, where we accept that vulnerabilities can occur despite our best efforts and we limit the potential impact of such vulnerabilities as much as possible.

## Linux

On Linux there are a handful of kernel-provided features. [Chromium](https://chromium.googlesource.com/chromium/src/+/0e94f26e8/docs/linux_sandboxing.md#user-namespaces-sandbox) uses [namespaces](https://man7.org/linux/man-pages/man7/namespaces.7.html) and [seccomp-bpf](https://www.kernel.org/doc/html/v4.19/userspace-api/seccomp_filter.html).

### Namespaces

To quote the man pages,

> A namespace wraps a global system resource in an abstraction that makes it appear to the processes within the namespace that they have their own isolated instance of the global resource. Changes to the global resource are visible to other processes that are members of the namespace, but are invisible to other processes.

In effect, namespaces are kernel-provided and prevent anything in the namespace from accessing files, processes, networks, users or anything else outside the namespace. This stops processes inside the namespace from affecting anything *outside* the namespace.

### seccomp-bpf

**Seccomp** filters system calls to only allow accepted ones, which has the effect of reducing attacker capabilities if they do get code execution.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://ir0nstone.gitbook.io/notes/binexp/memory-safety/sandboxing.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
