Browser Sandboxing: the Rise of Seatbelt
Learn more about why modern browsers are becoming a major target.
Join the DZone community and get the full member experience.Join For Free
Modern browsers use a wide range of techniques to attempt to protect the underlying operating system from browser application level compromise. This, not surprisingly, is very difficult to do today.
The browser you're using to read this is essentially a virtualized computer that runs at the user level of your computer. It has networking capabilities built in via WebSockets and asynchronous processing via Web Workers. It has persistent storage. All of this is built into the browser itself, which is used to load arbitrary and provider-defined content from around the world. Seriously — open a mainstream news site like Al Jazeera or CNN with developer tooling enabled and take a look at the network traffic. Visiting that one site results in your browser firing off hundred(s) of requests to a wide range of sites. And many of those sites you've probably never heard of.
No wonder browsers are such a target!
So, browser developers have taken two basic but converging approaches to security. The first, exemplified by Edge, is exploit mitigation. The second, lead by Chrome, is sandboxing. Now, it's pretty clear you really want both, and in the future, we likely will as these approaches are converging. For now, let's take a look at sandboxing — specifically with Safari on MacOS.
So how does Safari sandbox? Well, it uses the same system any other MacOS apps can use — the app sandbox. This sandbox started its life as Seatbelt and has grown more popular and powerful over the years. Today, it's used on all *OS devices, though some devices have more stringent requirements as to when it needs to be used. The app sandbox has plenty of documentation written for a developers perspective. Seatbelt does not.
Fortunately, though, Seatbelt does have a fair amount of research that's been put together over the past couple of years, so we do have a bit of a headstart on figuring out exactly how it works. Basically, it uses access definition files, written in TinyScheme, to define acceptable application service access. The operating system will parse these configuration files and limit application access accordingly. The app sandbox extends Seatbelt and changes how it is applied to applications. The app sandbox is also dependent on code signing, while Seatbelt was not.
These policy files, today, are generated by Xcode when you build an app. The developer selects some group of entitlements, and the policy files are automatically created and distributed with the app. Safari entitlements are likely a bit more nuanced than this, as you can see by looking them over at /System/Library/Frameworks/WebKit.framework/Versions/A/Resources/*.sb. So, when Safari runs, MacOS loads these policies (and others, in fact, like /System/Library/Sandbox/Profiles/system.sb) to determine what on the operating system Safari can access. You can tell, based on the complexity of the policies, that Apple grants Safari a wide range of capabilities, likely much more than a typical app. We'll go more into the technical details of how this sandbox works next. Stay tuned!
Opinions expressed by DZone contributors are their own.