Multi-process sandboxing
Chromium's macOS sandbox for the helper processes: how it is sealed, what it needs, and running without it.
var configuration = CefRuntime.Configuration.embedded
configuration.isSandboxEnabled = true // the default
The Minimal example runs its helpers outside the sandbox with -sandbox NO,
for comparison.
Chromium’s macOS sandbox confines the renderer, GPU, network and other
helper processes. CefSwift turns it on by default, in every preset, as
Chrome does. Turn it off only to debug a helper, or for a bundle that
cef bundle did not make:
static var runtimeConfiguration: CefRuntime.Configuration {
var configuration = CefRuntime.Configuration.chrome
configuration.isSandboxEnabled = false // development only
return configuration
}
--no-sandbox on the app’s command line turns it off for one run.
Evidence
Measured on 2026-11-13 with CEF 156.0.28 on an M3 MacBook, macOS 27.2, ad
hoc signed bundles from cef bundle:
- SelfTest passes every check with the sandbox on (491 passed, none
skipped), and
sandbox_checkreports each helper process sandboxed and the app process not. CI runs SelfTest with the sandbox (the default);SELFTEST_SANDBOX=0runs it without. - Footprint and launch time, measured with
Scripts/measure-footprint.py, are in design notes. - Not covered by SelfTest: system media decoders a sandboxed renderer cannot open, which Chromium does not use for web media.
- The Alerts helper (
<App> Helper (Alerts)), which posts system notifications, is never sandboxed, as in Chrome. It starts only when the app turns system notifications on (services.systemNotifications); by default it never runs.
How it works
Since CEF 138 the macOS sandbox ships as a library inside the framework,
Chromium Embedded Framework.framework/Libraries/libcef_sandbox.dylib.
- Browser process.
isSandboxEnabledsetscef_settings_t.no_sandboxto 0. Chromium then stops passing--no-sandboxto helper processes. - Helper processes. The helper executable links
Contents/Frameworks/libcefswift_helper_startup.dylibahead of the framework. That library’s initializer runs before any framework code. Without--no-sandboxamong the helper’s arguments, it callscef_sandbox_initialize(argc, argv)fromlibcef_sandbox.dylibto seal the process. If sealing fails, the helper prints an error and exits with status 125 rather than run unsandboxed. The library is CefSwift’scefswift_helper_startupproduct (Sources/CefHelperStartup). - This is the order CEF requires (
cef_sandbox_mac.h: initialize the sandbox before the framework loads), reached with the framework linked at launch instead of loaded withdlopenafterwards. See architecture for why.
No other code changes are needed. Bundles from cef bundle and from the
Xcode build phase contain both libraries.
libcef_sandbox and Chromium’s Aperitif helpers
Chrome 157 ships helper apps named Google Chrome Helper (Aperitif).app,
(Aperitif Renderer), (Aperitif GPU) and (Aperitif Alerts), which link
libaperitif.dylib before the framework. That library is Chromium’s
counterpart of libcef_sandbox.dylib plus CefSwift’s startup library: it
seals the seatbelt sandbox and registers PartitionAlloc’s malloc zone
before any other code runs. Chromium launches those helpers only when its
AperitifHelpers feature is on. CEF 156 ships no libaperitif.dylib and
no Aperitif helpers, leaves the feature off, and asks clients to seal the
sandbox with libcef_sandbox.dylib, which is what CefSwift does. Do not
turn AperitifHelpers on: Chromium then looks for helper apps the bundle
does not have, fails to start the GPU process, and ends the app.
Requirements
- Signing. The sandbox depends on bundle identity and on consistent
signing across the app and all five helpers, which
cef bundlegives every bundle, ad hoc ones included. Ship builds signed with a Developer ID or App Store identity, with the hardened runtime for notarization (bundling). - Bundle layout. The helper finds both libraries and the framework by
paths relative to its executable, so keep the layout that
cef bundleproduces. - Library validation. The helpers load the startup library, the
framework and
libcef_sandbox.dylibat launch by@executable_path-relative paths. Under the hardened runtime, library validation loads them only when they carry the helper’s team identifier.cef bundlesigns all of them with the app’s identity (CEF ships its libraries linker-signed ad hoc), so a team-signed bundle needs nocom.apple.security.cs.disable-library-validation. An ad hoc or self-signed bundle has no team to match, so with the hardened runtimecef bundleadds that entitlement; on macOS 27.2 such a bundle starts normally and passes SelfTest. --no-sandbox. If anything adds--no-sandboxto the browser process’s command line, Chromium passes it on and helpers skip sealing. This is the switch Chromium itself uses.- The App Sandbox (the App Store entitlement) is a separate mechanism from Chromium’s sandbox. It is not supported with official CEF builds, so both tracks refuse it (bundling); Xcode’s app template turns it on, so remove it there.
Without the sandbox
- Prefer trusted content. A view that loads your own origins carries far less risk than a general-purpose browser.
- Keep CEF current. The update workflow (automation) turns each stable CEF release, including Chromium security fixes, into a pull request that merges itself once CI passes.
- Narrow the surface. Turn off features you do not need with
disabledFeaturesorextraCommandLineSwitches. Do not setremoteDebuggingPortin shipping builds: it opens an unauthenticated control channel on localhost. - Treat bridges as attack surface.
CefBridgehandlers run with your app’s privileges; validate their input and check the caller’s origin (guide).
Sandbox
Measured on 2026-11-13 with CEF 156.0.28 on an M3 MacBook, macOS 27.2, ad
hoc signed bundles, Scripts/measure-footprint.py --kinds relaunch
(median of five runs, physical footprint of the app and every helper,
launch to the first page(_:didFinishLoadWithStatus:)). Another build
ran on the same Mac at the time, so run-to-run spread is wider than in the guide’s table.
| App | Sandbox | Launch | Memory (range) |
|---|---|---|---|
Minimal (.embedded) |
On | 322 ms | 108.6 MiB (102.7–113.0) |
Minimal (.embedded) |
Off (-sandbox NO) |
315 ms | 110.6 MiB (90.2–118.2) |
Browser (.chrome) |
On | 440 ms | 173.2 MiB (171.1–179.3) |
Browser (.chrome) |
Off (--no-sandbox) |
384 ms | 162.0 MiB (160.9–165.1) |
In an earlier pair of Minimal runs, per process: GPU 24.5 MiB sandboxed against 21.0 MiB, network service 10.9 against 7.7 MiB, the others within 1 MiB. The sandbox costs a few MiB in the GPU and network processes and some tens of milliseconds at launch; SelfTest passes every check with it on (491 checks, none skipped). It is on by default in every preset.