Browser Sandboxing: Always Wear Your Seatbelt!

DZone 's Guide to

Browser Sandboxing: Always Wear Your Seatbelt!

When it comes to browser security, always wear your seatbelt!

· Security Zone ·
Free Resource

To understand how modern browsers are sandboxed, we need to understand, first, how modern sandboxes work. There's a variety of them available, from chroot to the SELinux sandbox to the app sandbox on Apple products. We're looking at the app sandbox, and in order to understand how it really works, we're going to start with it's predecessor — Seatbelt.

Seatbelt was originally the codename for this sandboxing technology out of Apple. Like many catchy codenames, it stuck, and it ended up being the product name. Now, when first released, it wasn't really available to the developer community, but it was the basis for sandboxing important system software. Like Safari, it ends up.

Seatbelt was originally based on the TrustedBSD mandatory access control (MAC) framework. Which makes sense, as BSD provides the UNIX compatibility layer via Darwin in *OS. Seatbelt is more configurable than TrustedBSD's mandatory access control though. After all, MAC systems aren't built to provide user-level control over system objects. They require administrators to define policies for an entire system, as opposed to discretionary access control (DAC) systems, which allow users to determine protections. Now, seatbelt does expose this MAC framework to users, but it does so differently than DAC systems do.

DAC systems allow users to arbitrarily change object access rules. For example, you can arbitrarily change the permissions associated with a file you own on just about any computer system — this is an example of discretionary control.

MAC systems don't give you this kind of flexibility. Basically, you get the access you get, and you just have to live with it.

Seatbelt is different. You configure policies over the program, then execute the program governed by that group of policies. You can change policies on the program prior to invocation, but not after. But how does it do this?

Seatbelt uses four different components to do its thing. It has a dynamic library you can use to initialize and configure a process sandbox. This library,  libsandbox.1.dylib, exports a group of functions you can use to control a sandbox (but not, interestingly,  sandbox_init()). It also uses a mach server that deals with logging from the kernel in relation to a sandboxed programs and sandboxes. Finally, it uses two kernel extensions too — one that uses the TrustedBSD interfaces for policy enforcement, and another that provides regex matching for defined policies.

When operating, the  sandbox_init() call will take policies defined in TinyScheme into binary encodings used by the kernel. This binarized data is then passed into  mac_syscall() TrustedBSD system call, which then passes the request to the Sandbox.kext kernel extension. The  Sandbox.kext extension applies the policies.

At this point, sensitive, hooked calls are directed through the  Sandbox.kext subsystem, which then enforces defined policies on that process. Information on the state of the sandboxed process is then passed back to userspace via the mach logging server.

Next, we're going to dive into the details of the userspace configuration calls and how they work.

browser sandboxing ,browser security ,sandbox ,seatbelt ,security

Opinions expressed by DZone contributors are their own.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}