Security/Sandbox: Difference between revisions

From MozillaWiki
Jump to navigation Jump to search
(→‎Status: Wipe the years-old Linux/B2G status/planning info and replace with notes from the now-frozen etherpad)
(Remove Flash information and outdated Console.app details.)
 
(328 intermediate revisions by 11 users not shown)
Line 1: Line 1:
[[File:Foxinabox.png|thumb||alt=The fox cannot escape the box.|The fox is safe in the sandbox. The fox cannot escape.]]
= Overview =
= Sandboxing Firefox =
This page tracks and explain how sandboxing is being worked on for Firefox (OS, Desktop, etc.)


[[File:550px-Sandboxing_basic_architecture.png|frameless|550px]]


Sandboxes use the process as the security boundary. The process model, i.e. how we split Firefox into processes and how the processes interact between each other is common to all platforms.
Security Sandboxing makes use of [https://en.wikipedia.org/wiki/Child_process child processes] as a security boundary. The process model, i.e. how Firefox is split into various processes and how these processes interact between each other is common to all platforms. For more information see the [[Electrolysis]] wiki page, and its sucessor, [[Project Fission]]. The security aspects of a sandboxed child process are implemented on a per-platform basis. See the Platform Specifics section below for more information.


The implementation of the sandbox mechanism is independent, per platform. Firefox OS and Linux desktop Firefox use the same implementation.
== Technical Docs ==


[[File:Sandboxing_basic_architecture.png|frameless|550px]]
* [https://wiki.mozilla.org/Security/Sandbox/Specifics Platform Specifics]
* [https://wiki.mozilla.org/Security/Sandbox/Deny_Filesystem_Access File Restrictions Bug Research]
* [https://wiki.mozilla.org/Security/Sandbox/Hardening Hardening Research]
* [https://wiki.mozilla.org/Security/Sandbox/Process_model Process Model]


== Documentation ==
= Current Status =
* How to I make my code work safely in the sandbox?
** [[Security/B2G/FirefoxOSCommsHardening]]
* How does the Linux and B2G (seccomp-bpf) sandbox work?
** [https://developer.mozilla.org/en-US/Firefox_OS/Security/System_security B2G details]
** [[Security/Sandbox/Seccomp]]
** See [[#Linux Sandbox Overview]] below.
* How does the Windows sandbox work?


== Windows Sandbox overview ==
{| class="wikitable"
|-
!Sandbox
!colspan="2"|Trunk
!colspan="2"|Beta
!colspan="2"|Release
|-
!
!colspan="2"|Level
!colspan="1"|Level
!colspan="1"|Version
!colspan="1"|Level
!colspan="1"|Version
|-
|colspan="1"|[https://dxr.mozilla.org/mozilla-central/search?q=SandboxBroker%3A%3ASetSecurityLevelForContentProcess&redirect=true&case=true Windows (content)]
|style='text-align:center;' colspan="2"|Level 6
|style='text-align:center;' colspan="1"|Level 6
|style='text-align:center;' colspan="1"|Fx76
|style='text-align:center;' colspan="1"|Level 6
|style='text-align:center;' colspan="1"|Fx76
|-
|colspan="1"| [https://dxr.mozilla.org/mozilla-central/search?q=SetSecurityLevelForGPUProcess&redirect=true Windows (compositor)]
|style='text-align:center;' colspan="2"|Level 1
|style='text-align:center;' colspan="1"|Level 1
|style='text-align:center;' colspan="1"|
|style='text-align:center;' colspan="1"|Level 1
|style='text-align:center;' colspan="1"|
|-
| [https://dxr.mozilla.org/mozilla-central/search?q=SandboxBroker%3A%3ASetSecurityLevelForGMPlugin&redirect=true&case=true Windows (GMP)]
|style='text-align:center;' colspan="2"|enabled
|style='text-align:center;' colspan="2"|enabled
|style='text-align:center;' colspan="2"|enabled
|-
|colspan="1"|[https://searchfox.org/mozilla-central/search?q=symbol:_ZN7mozilla21AbstractSandboxBroker32SetSecurityLevelForSocketProcessEv&redirect=false Windows (Socket)]
|style='text-align:center;' colspan="2"|Level 1
|style='text-align:center;' colspan="1"|Level 1
|style='text-align:center;' colspan="1"|Fx75
|style='text-align:center;' colspan="1"|Level 1
|style='text-align:center;' colspan="1"|Fx75
|-
| [https://searchfox.org/mozilla-central/source/security/sandbox/mac/SandboxPolicyContent.h OSX (content)]
|style='text-align:center;' colspan="2"|Level 3
|style='text-align:center;' colspan="1"|Level 3
|style='text-align:center;' colspan="1"|Fx56
|style='text-align:center;' colspan="1"|Level 3
|style='text-align:center;' colspan="1"|Fx56
|-
| [https://searchfox.org/mozilla-central/source/security/sandbox/mac/SandboxPolicyGMP.h OSX (GMP)]
|style='text-align:center;' colspan="2"|enabled
|style='text-align:center;' colspan="2"|enabled
|style='text-align:center;' colspan="2"|enabled
|-
| [https://searchfox.org/mozilla-central/source/security/sandbox/mac/SandboxPolicyUtility.h OSX (RDD)]
|style='text-align:center;' colspan="2"|enabled
|style='text-align:center;' colspan="2"|enabled
|style='text-align:center;' colspan="2"|enabled
|-
| [https://searchfox.org/mozilla-central/source/security/sandbox/mac/SandboxPolicySocket.h OSX (Socket)]
|style='text-align:center;' colspan="2"|enabled
|style='text-align:center;' colspan="2"|disabled
|style='text-align:center;' colspan="2"|disabled
|-
| [https://dxr.mozilla.org/mozilla-central/search?q=class+ContentSandboxPolicy&redirect=true&case=true Linux (content)]
|style='text-align:center;' colspan="2"|Level 4
|style='text-align:center;' colspan="1"|Level 4
|style='text-align:center;' colspan="1"| Fx60
|style='text-align:center;' colspan="1"|Level 4
|style='text-align:center;' colspan="1"| Fx60
|-
| [https://dxr.mozilla.org/mozilla-central/search?q=class+GMPSandboxPolicy&redirect=true&case=true Linux (GMP)]
|style='text-align:center;' colspan="2"|enabled
|style='text-align:center;' colspan="2"|enabled
|style='text-align:center;' colspan="2"|enabled
|}
 
A 'level' value reflects unique sandbox security settings for each platform and process. Most processes only have two "active" levels, the current setting and a lower (previous released) setting. Level settings other than these two values carry no guarantee of altering security behavior, level settings are primarily a release rollout debugging feature.
 
== Windows ==
 
=== Content ===
 
Sandbox security related setting are grouped together and associated with a security level. Lower level values indicate a less restrictive sandbox.
 
{| class="wikitable"
|-
! Sandbox Feature !! Level 5 !! Level 6 (default)
|-
| Job Level || JOB_LOCKDOWN || JOB_LOCKDOWN
|-
| Access Token Level || USER_LIMITED || USER_LIMITED
|-
| Alternate Desktop || YES || YES
|-
| Alternate Windows Station || YES || YES
|-
| Initial Integrity Level || INTEGRITY_LEVEL_LOW || INTEGRITY_LEVEL_LOW
|-
| Delayed Integrity Level || INTEGRITY_LEVEL_LOW || INTEGRITY_LEVEL_LOW
|-
| Mitigations
||
MITIGATION_BOTTOM_UP_ASLR<br>
MITIGATION_HEAP_TERMINATE<br>
MITIGATION_SEHOP<br>
MITIGATION_DEP_NO_ATL_THUNK<br>
MITIGATION_DEP<br>
MITIGATION_EXTENSION_POINT_DISABLE<br>
MITIGATION_IMAGE_LOAD_NO_REMOTE<br>
MITIGATION_IMAGE_LOAD_NO_LOW_LABEL<br>
MITIGATION_IMAGE_LOAD_PREFER_SYS32<br>
MITIGATION_CONTROL_FLOW_GUARD_DISABLE<br>
MITIGATION_WIN32K_DISABLE
||
MITIGATION_BOTTOM_UP_ASLR<br>
MITIGATION_HEAP_TERMINATE<br>
MITIGATION_SEHOP<br>
MITIGATION_DEP_NO_ATL_THUNK<br>
MITIGATION_DEP<br>
MITIGATION_EXTENSION_POINT_DISABLE<br>
MITIGATION_IMAGE_LOAD_NO_REMOTE<br>
MITIGATION_IMAGE_LOAD_NO_LOW_LABEL<br>
MITIGATION_IMAGE_LOAD_PREFER_SYS32<br>
MITIGATION_CONTROL_FLOW_GUARD_DISABLE<br>
MITIGATION_WIN32K_DISABLE<br>
Locked Down Default DACL
|-
| Delayed Mitigations
||
MITIGATION_STRICT_HANDLE_CHECKS<br>
MITIGATION_DLL_SEARCH_ORDER
||
MITIGATION_STRICT_HANDLE_CHECKS<br>
MITIGATION_DLL_SEARCH_ORDER
|}
 
[http://mxr.mozilla.org/mozilla-central/source/security/sandbox/chromium/sandbox/win/src/security_level.h Windows Feature Header]
 
=== Gecko Media Plugin (GMP) ===
 
{| class="wikitable"
|-
! Sandbox Feature !! Level
|-
| Job Level || JOB_LOCKDOWN
|-
| Access Token Level || USER_LOCKDOWN, USER_RESTRICTED[1]
|-
| Initial Integrity Level || INTEGRITY_LEVEL_LOW
|-
| Delayed Integrity Level || INTEGRITY_LEVEL_UNTRUSTED
|-
| Alternate desktop || yes
|-
| Mitigations
||
MITIGATION_BOTTOM_UP_ASLR<br>
MITIGATION_HEAP_TERMINATE<br>
MITIGATION_SEHOP<br>
MITIGATION_EXTENSION_POINT_DISABLE<br>
MITIGATION_DEP_NO_ATL_THUNK<br>
MITIGATION_DEP<br>
MITIGATION_NONSYSTEM_FONT_DISABLE<br>
MITIGATION_IMAGE_LOAD_NO_REMOTE<br>
MITIGATION_IMAGE_LOAD_NO_LOW_LABEL<br>
MITIGATION_CET_COMPAT_MODE<br>
Locked Down Default DACL
|-
| Delayed Mitigations
||
MITIGATION_STRICT_HANDLE_CHECKS<br>
MITIGATION_DLL_SEARCH_ORDER
|}
 
[1] depends on the media plugin
 
=== Remote Data Decoder (RDD) ===
 
{| class="wikitable"
|-
! Sandbox Feature !! Level
|-
| Job Level || JOB_LOCKDOWN
|-
| Access Token Level || USER_LIMITED
|-
| Initial Integrity Level || INTEGRITY_LEVEL_LOW
|-
| Delayed Integrity Level || INTEGRITY_LEVEL_LOW
|-
| Alternate desktop || yes
|-
| Mitigations
||
MITIGATION_BOTTOM_UP_ASLR<br>
MITIGATION_HEAP_TERMINATE<br>
MITIGATION_SEHOP<br>
MITIGATION_EXTENSION_POINT_DISABLE<br>
MITIGATION_DEP_NO_ATL_THUNK<br>
MITIGATION_DEP<br>
MITIGATION_NONSYSTEM_FONT_DISABLE<br>
MITIGATION_IMAGE_LOAD_NO_REMOTE<br>
MITIGATION_IMAGE_LOAD_NO_LOW_LABEL<br>
MITIGATION_IMAGE_LOAD_PREFER_SYS32<br>
MITIGATION_CET_COMPAT_MODE<br>
Locked Down Default DACL
|-
| Delayed Mitigations
||
MITIGATION_STRICT_HANDLE_CHECKS<br>
MITIGATION_DYNAMIC_CODE_DISABLE<br>
MITIGATION_DLL_SEARCH_ORDER<br>
MITIGATION_FORCE_MS_SIGNED_BINS
|}
 
* [[Firefox/win64]] Wiki Page
* [https://blog.mozilla.org/futurereleases/2015/12/15/firefox-64-bit-for-windows-available/ Release Announcement]
* [https://www.mozilla.org/en-US/firefox/all/ Windows 64-bit builds]
 
== OSX ==
 
=== Content Levels for Web and File Content Processes ===
 
Mac content processes use sandbox level 3. File content processes (for file:/// origins) also use level 3 with additional rules to allow read access to the filesystem. Levels 1 and 2 can still be enabled in about:config, but they are not supported and using them is not recommended. Different sandbox levels were used for testing and debugging during rollout of Mac sandboxing features, but they now are planned to be removed. Mac sandboxing uses a white list policy for all process types. Each policy begins with a statement to deny all access to system resources and then specifies the allowed resources. The level 3 sandbox allows file system read metadata access with full read access for specific system directories and some user directories, access to the microphone, access to various system services, windowserver, named sysctls and iokit properties, and other miscellaneous items. Work is ongoing to remove access to the microphone, windowserver, and other system services where possible. The sandbox blocks write access to all of the file system, read access to the profile directory (apart from the chrome and extensions subdirectories, read access to the home directory, inbound/outbound network I/O, exec, fork, printing, video input devices such as cameras. Older sandbox levels 1 and 2 are less restrictive. Mainly, level 2 allows file-read access to all of the filesystem except the ~/Library directory. Level 1 allows all file-read access. Level 1 restrictions are a subset of level 2. Level 2 restrictions are a subset of level 3.
 
The web and file content policy is defined in [https://searchfox.org/mozilla-central/source/security/sandbox/mac/SandboxPolicyContent.h SandboxPolicyContent.h]
 
=== Gecko Media Plugin Processes ===
 
The Gecko Media Plugins (GMP) policy is defined in [https://searchfox.org/mozilla-central/source/security/sandbox/mac/SandboxPolicyGMP.h SandboxPolicyGMP.h].
 
=== Remote Data Decoder Processes ===
 
The Remote Data Decoder (RDD) policy is defined in [https://searchfox.org/mozilla-central/source/security/sandbox/mac/SandboxPolicyUtility.h SandboxPolicyUtility.h].
 
=== Socket Process ===
 
The socket process policy is defined in [https://searchfox.org/mozilla-central/source/security/sandbox/mac/SandboxPolicySocket.h SandboxPolicySocket.h]. At this time (May 2020), the socket process sandbox is only used on the Nightly channel and only for WebRTC networking.
 
== Linux ==
 
=== Content Levels ===


=== Source code overview ===
{| class="wikitable"
|-
! Job Level !! What's Blocked by the Sandbox?
|-
| Level 1 ||
* Many syscalls, including process creation
|-
| Level 2 ||
* Everything from level 1
* Write access to the filesystem
** Excludes shared memory, tempdir, video hardware
|-
| Level 3 ||
* Everything from level 1-2
* Read access to most of the filesystem
** Excludes themes/GTK configuration, fonts, shared data and libraries
|-
| Level 4 ||
* Everything from level 1-3
* Network access including local sockets
** Excludes X11 socket
* System V IPC
** Unless fgxlrx or VirtualGL is in use
* Uses chroot jail
* Uses Unprivileged User Namespaces (if available)
|}


Relative to the root of mozilla-central, the sandbox exists at:
=== Content Rules ===
./security/sandbox


Linux related sandbox is inside the linux subfolder.
[https://dxr.mozilla.org/mozilla-central/source/security/sandbox/linux/SandboxFilter.cpp?q=ContentSandboxPolicy Filter ruleset]


The core of the Windows sandbox is Google's chromium sandbox.
[https://dxr.mozilla.org/mozilla-central/source/security/sandbox/linux/broker/SandboxBrokerPolicyFactory.cpp#203 Filesystem access policy]


The chromium sandbox is based on the chromium base libraries (Gogole's code) which are located at:
=== Gecko Media Plugin ===
./security/sandbox/chromium (excluding ./security/sandbox/chromium/base/shim/ which overrides some functionality to make it compatible with our SDK build settings, which is Mozilla code)
The chromiums Windows sandbox itself (Google's code) is inside ./security/sandbox/win/src (excluding ./security/sandbox/win/src/sandboxbroker and ./security/sandbox/win/src/sandboxtarget subfolders, which is Mozilla code)


There are 2 processes when dealing with a sandboxed application:
[https://dxr.mozilla.org/mozilla-central/search?q=class+GMPSandboxPolicy Filter ruleset]


# The broker: The parent process that starts sandboxed children
=== Customization Settings ===
# The target: The child process that is sandboxed


Both processes make use of the chromium sandbox library, but they make use of it indirectly through 2 libraries (Mozilla code).
The Linux sandbox allows some amount of control over the sandbox policy through various about:config settings. These are meant to allow more non-standard configurations and exotic distributions to stay working - without compiling custom versions of Firefox - even if they can't be directly supported by the default configuration.
This indirect use of the library is due to header conflicts with the ipc layer where it has a different, much older, non compatible, copy of the chromium base library:


# For the broker, ./security/sandbox/win/src/sandboxbroker
See [[Security/Sandbox#Linux_specific|Activity Logging]] for information on how to debug these scenarios.
# For the target, ./security/sandbox/win/src/sandboxtarget


=== Build settings ===
security.sandbox.content.level
* See [[Security/Sandbox#Content_Levels_2|Content Levels]] above. Reducing this can help identify sandboxing as the cause of a problem, but you're better of trying the more fine grained permissions below.


To enable e10s you can use a normal mozilla-central build but you should enable this pref:
security.sandbox.content.read_path_whitelist<br/>
browser.tabs.remote.autostart
security.sandbox.content.write_path_whitelist
It's recommended to use a different profile for dev if you don't want to trash your existing profile.
* Comma-separated list of additional paths that the content process is allowed to read from or write to, respectively. To allow access to an entire directory tree (rather than just the directory itself), include a trailing <tt>/</tt> character.


The sandbox is in use by our e10s code when you build with this in your mozconfig:
security.sandbox.content.syscall_whitelist
ac_add_options --enable-content-sandbox
* Comma-seperated list of additional system call numbers that should be allowed in the content process. These affect the seccomp-bpf filter.


=== Environment variables ===
= Preferences =


{|
{| class="wikitable"
|Disable content process sandbox
|-
|MOZ_DISABLE_CONTENT_SANDBOX
! Process Type !! Preference Type !! Preference
|-
| Content || numerical || security.sandbox.content.level
|-
| Windows NPAPI Plugin || numerical || dom.ipc.plugins.sandbox-level.default<br>dom.ipc.plugins.sandbox-level.<plugintype>
|-
| Compositor || numerical || security.sandbox.gpu.level
|-
|-
|Disable media plugin sandbox
| Media || Embedded || N/A
|MOZ_DISABLE_GMP_SANDBOX
|}
|}


=== Key source code locations ===
<strong>Note - Levels greater than the current default for a particular process type are not implemented.</strong>


The sandboxed target process lowers its own privliges after initialization via this call:
= File System Restrictions =
http://dxr.mozilla.org/mozilla-central/source/ipc/app/MozillaRuntimeMain.cpp#78


The call that starts the sandboxed process in Firefox is:
Sandboxing enforces file system write and read restrictions for XUL based add-on content (frame and process) scripts. To avoid issues as sandboxing features roll out add-on authors should update their legacy add-on code today such that content scripts no longer attempt to read or write from restricted locations. Note these restrictions do not affect [https://developer.mozilla.org/en-US/Add-ons/WebExtensions/Content_scripts WebExtension content script] or XUL add-on script running in the browser process.  
http://dxr.mozilla.org/mozilla-central/source/ipc/glue/GeckoChildProcessHost.cpp#784


All of the code that sets policies can be found here:
File system access rules for content processes, reverse precedence:
http://dxr.mozilla.org/mozilla-central/source/security/sandbox/win/src/sandboxbroker/sandboxBroker.cpp


== Linux/B2G Sandbox Overview ==
{| class="wikitable"
|-
! Location !! Access Type !! Restriction
|-
| file system || read/write || deny by default
|-
| install location || write || deny
|-
| install location || read || allow
|-
| system library locations  || write || deny
|-
| system library locations  || read || allow
|-
| profile/* || read/write || deny by default
|-
| profile/extensions || write || deny
|-
| profile/extensions || read || allow
|}


B2G has always been “sandboxed” to some extent; every app/tab gets its own content process, which uses the Android security model: a separate uid per process, no group memberships, and kernel patches that require group membership for things like network access.  But privilege escalation via kernel vulnerabilities is relatively common, so we also use [[the seccomp-bpf system call filter|Security/Sandbox/Seccomp]] to try to reduce the attack surface that a compromised content process can directly access.  (TODO: also point to the SELinux work.)
= Debugging Features =


Desktop Linux is similar but more complicated; most systems have seccomp-bpf, but for limitations that apply to the semantics of system calls (e.g., “can this process access the filesystem”, not “can this process use system call #83”) we require unprivileged user namespaces, which a large minority of desktop Firefoxes don't yet have.  (TODO: link to bugs with discussion/rationale.)  Specifically: <tt>chroot()</tt>ing into a deleted directory to revoke FS access, and namespace unsharing for networking, SysV IPC if possible, and process IDs.  (TODO: link to more info / code, and maybe make this a sub-page like seccomp.)
== Activity Logging ==


= Roadmap (high-level) =
The following prefs control sandbox logging. On Windows, output is sent to the Browser Console when available, and to a developer console attached to the running browser process. On OSX, once enabled, violation log entries are visible in the Console.app (/Applications/Utilities/Console.app). On Linux, once enabled, violation log entries are logged on the command line console.<br/>
This roadmap may evolve over time.


# Land core sandboxing code
security.sandbox.logging.enabled (boolean)<br/>
## {{done|B2G}}
security.sandbox.windows.log.stackTraceDepth (integer, Windows specific)<br/>
## {{done|Linux}} (except pid namespaces)
## {{done|Windows}}
## {{done|MacOS X}}
# Sandbox GeckoMediaPlugins
## {{invalid|B2G}}
## {{done|Linux}}
## {{done|Windows}}
## {{done|MacOS X}}
# Minimal non-breaking “sandbox” for content
## {{done|B2G}}
## {{done|MacOS X}}
## {{done|Windows}}
## {{inprogress|Linux}} {{bug|742434}}
# Content sandbox milestones
## File write access
### {{inprogress|B2G}} {{bug|1214947}}
### {{inprogress|Desktop}} — printing is main blocker
## File read access
### {{inprogress|B2G}} {{bug|1214947}}
### {{new|Desktop}} — see dependencies of {{bug|sandbox-fs}}
## Network access
### {{done|B2G}} (since 1.0)
### {{new|Linux}}
### {{done|MacOS X}}
### Windows status unknown; FIXME
## Others (maybe platform specific)
### {{new|X11 (Linux)}}
### {{new|SysV SHM (Linux)}}
# Auditing/Hardening (future goals)
## Attack surface of MesssageManager protocols
## Attack surface of IPDL protocols
## CPOWs
## Improve understanding of rationale/implications of sandbox policy rules
## Where can we rearrange child/parent division to reduce total attack surface?


= Status =
The following environment variables also triggers sandbox logging output: <br/>


* Tracking bug for desktop Firefox: {{bug|925570}}.
MOZ_SANDBOX_LOGGING=1
* Tracking bug for Firefox OS: {{bug|790923}}.


=== Firefox OS / B2G ===
=== OSX Specific Sandbox Logging ===
* {{done|Android permissions}} — content processes treated like separate no-permissions Android apps
* {{done|seccomp-bpf}} — syscall filtering for kernel attack surface reduction
* {{inprogress|chroot}} — {{bug|1151632}}, and depends on filesystem brokering
* {{inprogress|filesystem brokering}}
** {{done|emulator}} — {{bug|930258}}
** {{new|other devices}} — {{bug|1214947}}
* {{inprogress|SELinux}} — {{bug|1186103}}
* {{new|filesystem whitelist reduction}} — {{bug|1121295}} tracks all whitelist entries, but some are more feasible targets than others.
* {{new|restrict ioctl()}} — bug needs to be filed; could help with driver attack surface


=== Desktop Firefox (cross-platform) ===
On Mac, sandbox violation logging is disabled by default. To enable logging,
* {{bug|sandbox-fs}} tracks blockers for restricting filesystem access
* {{inprogress|printing}}, {{bug|1090454}}; print-to-PDF and similar need file write access
* Reading files:
** {{new|resource URIs}}, {{bug|1109293}} (also moz-extension://), probably the least difficult of these
** {{new|chrome URIs}}, {{bug|1136836}}, more special-case logic than resource:// but basically the same problem
** {{new|file URIs}}: {{bug|922481}} would remote it but we'd need an allow-all policy, which isn't much help; maybe the [[FirefoxOS/New_security_model]] isolation machinery can help us compartmentalize file:/// in its own content process.
** {{new|NPAPI stuff}}, because parts of the “plugin host” are in the content process; {{bug|1202910}}, but we're sunsetting NPAPI so this may not matter in practice
* {{done|camera access}}, {{bug|1104616}}
* {{new|audio device access}}, {{bug|1104619}}


=== Linux Firefox ===
# Launch the OS X Console app (/Applications/Utilities/Console.app) and filter on "plugin-container".
* Shares most core code with B2G, but much more difficult to deploy without breaking things.
# Either set the pref '''security.sandbox.logging.enabled=true''' and restart the browser OR launch the browser with the '''MOZ_SANDBOX_LOGGING''' environment variable set.
* {{new|apply permissive seccomp-bpf policy}}, {{bug|742434}}, blocked by:
** {{new|glib signal blocking}}, {{bug|1176099}}
** {{new|mailcap reader}}, {{bug|579388}} (forks/execs shell commands)
* {{new|deal with PulseAudio}}, which does file/socket I/O on user-configurable paths, chmod()s files, does kill(0) to other processes, etc.. See {{bug|1104619}} above, or maybe there's some way to configure/monkey-patch it into a manageable state that's not just as hard.
* {{new|pid namespace isolation}}, {{bug|1151624}}; would be usable immediately for GeckoMediaPlugins, not just for content in the future
* {{new|X11 security or lack thereof}}, {{bug|1129492}}
* {{new|filesystem/network access restriction}}, tracked by {{bug|942698}}


=== Windows Firefox ===
=== Linux specific Sandbox Logging ===
* {{done|Land [http://www.chromium.org/developers/design-documents/sandbox Library]}} {{bug|922756}}
* {{done|Start using library to sandbox e10s processes unrestricted}} {{bug|925571}}
* {{new|List and prioritize permissions to shut off}}
* {{new|Burn down permission list}}


Permission List:
The following environment variable triggers extra sandbox debugging output: <br/>
* {{done|Use a separate Windows Desktop within the same Windows Station}} - {{bug|928061}}
MOZ_SANDBOX_LOGGING=1
* {{ok|Use a separate Windows Station + Desktop}} - {{bug|928055}}
* {{ok|Set low integrity on content processes for Windows sandboxing policy}} - {{bug|928062}}
* more not yet posted


=== MacOS X Firefox ===
== Environment variables ==
* {{new|Land Library}} -- {{bug|387248}}
* {{new|List and prioritize permissions to shut off}}
* {{new|Burn down permission list}}


Permission List:
{| class="wikitable"
{|  
|-
|TBD
! ENVIRONMENT VARIABLE !! DESCRIPTION || PLATFORM
|-
|MOZ_DISABLE_CONTENT_SANDBOX
|Disables content process sandboxing for debugging purposes.
|All
|-
|MOZ_DISABLE_GMP_SANDBOX
|Disable media plugin sandbox for debugging purposes
|All
|-
|MOZ_DISABLE_NPAPI_SANDBOX
|Disable 64-bit NPAPI process sandbox
|Windows and Mac
|-
|MOZ_DISABLE_GPU_SANDBOX
|Disable GPU process sandbox
|Windows
|-
|MOZ_DISABLE_RDD_SANDBOX
|Disable Data Decoder process sandbox
|All
|-
|MOZ_DISABLE_SOCKET_PROCESS_SANDBOX
|Disable Socket Process process sandbox
|All
|}
|}


= Future work =
=== Setting a custom environment in Windows ===
These are some things that we need to attack next (after a basic sandbox).


* Process Model
1) Close Firefox <br/>
** Parent process as enforcing + ACL check only?
2) Browser to the location of your Firefox install using Explorer <br/>
* Resource limits
3) Shift + Right-click in the folder window where firefox.exe is located, select "Open command window here" <br/>
* (Desktop) DevTools support
4) Add the environment variable(s) you wish to set to your command window -  <br/> <br/>
* (Desktop) Accessibility support
<code>set MOZ_DISABLE_NPAPI_SANDBOX=1</code>(return) <br/> <br/>
5) enter firefox.exe and press enter to launch Firefox with your custom environment <br/>


= Modules =
== Local Build Options ==
Modules per widget:
* [[Modules/Core#Sandboxing_-_Windows|Windows]]: Owner: Tim Abraldes; Peers: Bob Owen, Aaron Klotz, Brian Bondy
* [[Modules/Core#Sandboxing_-_OSX|OSX]]: Owner: Steven Michaud; Peers: Andre Reinald
* [[Modules/Core#Sandboxing_-_Linux_.26_B2G|Linux/B2G]]: Owner: Jed Davis; Peers: Guillaume Destuynder


= Contact =
To disable building the sandbox completely build with this in your mozconfig:
* Mailing list: [mailto:boxing@lists.mozilla.org boxing@lists.mozilla.org]
* IRC: [irc://irc.mozilla.org irc.mozilla.org] #boxing and #security


See also [[#Modules|module owners/peers]].
<code>ac_add_options --disable-sandbox</code>


MoCo managers of related groups:
To disable just the content sandbox parts:
* pauljt, Firefox OS security
* blassey, [[Electrolysis]]
* kang, [[Security/OpSec]]


Some folks from the [[SecurityEngineering]] team:
<code>ac_add_options --disable-content-sandbox</code>
* keeler, ckerschb, sid, and bbondy.


= Meeting Notes =
= Bug Lists =


Create a new weekly agenda from the [[Security/Sandbox/0-0-0|template]]:
== Priorities ==
<createbox>
* [https://bugzilla.mozilla.org/buglist.cgi?priority=P1&f1=keywords&o1=notsubstring&resolution=---&status_whiteboard_type=allwordssubstr&query_format=advanced&status_whiteboard=sb%2B&v1=meta&list_id=13711690 P1]
align=left
* [https://bugzilla.mozilla.org/buglist.cgi?list_id=13711673&o1=notsubstring&status_whiteboard_type=allwordssubstr&status_whiteboard=sb%2B&v1=meta&priority=P2&f1=keywords&resolution=---&query_format=advanced P2]
type=create
* [https://bugzilla.mozilla.org/buglist.cgi?priority=P3&f1=keywords&list_id=13711682&o1=notsubstring&resolution=---&status_whiteboard_type=allwordssubstr&query_format=advanced&status_whiteboard=sb%2B&v1=meta P3]
preload=Security/Sandbox/0-0-0
default={{#time: Y-m-d | thursday}}
prefix=Security/Sandbox/
</createbox>


==== 2015 ====
== Security/Process Sandboxing Lists ==
{| class="toccolours" style="width: 100%"
* [https://bugzilla.mozilla.org/buglist.cgi?product=Core&component=Security%3A%20Process%20Sandboxing&resolution=---&list_id=13711685 Full bug list]
|{{Special:PrefixIndex/Security/Sandbox/2015}}
* [https://bugzilla.mozilla.org/buglist.cgi?priority=--&f1=keywords&list_id=13711696&o1=notsubstring&resolution=---&query_format=advanced&v1=meta&component=Security%3A%20Process%20Sandboxing&product=Core No priority set]
* [https://bugzilla.mozilla.org/buglist.cgi?keywords=meta&keywords_type=allwords&resolution=---&query_format=advanced&component=Security%3A%20Process%20Sandboxing&product=Core&list_id=13711689 Metas]
 
== Triage Lists ==
* Sandboxing Triage List: https://is.gd/ghRoW8
** Lists sandboxing component bugs that are not tracked by a milestone
** Ignores previously triaged into either sb- or sb+
** Ignores meta bugs and bugs with needinfos
* Global [https://bugzilla.mozilla.org/buglist.cgi?f1=flagtypes.name&o3=notsubstring&list_id=13952603&v3=meta&o1=notsubstring&resolution=---&status_whiteboard_type=substring&query_format=advanced&f3=keywords&status_whiteboard=sb%3F&v1=needinfo Triage List]
** Lists any bug in the database with sb?
** Ignores bugs with needinfos
* sb+ [https://mzl.la/2CSaniE triage list]
** Previously triaged bugs that have no milestone and no priority set
* sb? needinfos: http://is.gd/dnSyBs
* webrtc specific sandboxing bugs: https://is.gd/c5bAe6
** sb tracking + 'webrtc'
 
= Roadmap =
 
==2020 H1 - Main work focus==
* [https://bugzilla.mozilla.org/show_bug.cgi?id=1464032 Remote Canvas Drawing operations],
** Prerequisite for win32k.sys lockdown.
* [https://bugzilla.mozilla.org/show_bug.cgi?id=1381938 Remote Form widget drawing],
** Prerequisite for win32k.sys lockdown.
** Follow-ups in [https://bugzilla.mozilla.org/show_bug.cgi?id=1615105 Bug for defaulting it on]
* [https://bugzilla.mozilla.org/show_bug.cgi?id=1642621 Remote WebGL drawing],
** See also [https://bugzilla.mozilla.org/show_bug.cgi?id=1632249 Out-of-process WebGL compositing].
** Follow-ups in [https://bugzilla.mozilla.org/show_bug.cgi?id=1642621 Make it shippable bug].
* [https://bugzilla.mozilla.org/show_bug.cgi?id=1347710 Sandbox the GPU Process].
** Stalled on non-reproducible [https://bugzilla.mozilla.org/show_bug.cgi?id=1630860 field issues].
* [https://bugzilla.mozilla.org/show_bug.cgi?id=1400317 Remote Look and Feel + Theming].
** Prerequisite for win32k.sys lockdown.
* [https://bugzilla.mozilla.org/show_bug.cgi?id=1550900 Shared memory with read-only and read/write mode].
** Security and memory usage win.
* [https://bugzilla.mozilla.org/show_bug.cgi?id=1440203 Use memfd_create for shared memory].
** Performance win and would solve many issues with people running into problems with the default docker/kubernetes configurations that only give a tiny amount of shared memory.
* [https://bugzilla.mozilla.org/show_bug.cgi?id=1620118 Enable further telemetry for third-party process injection].
 
==2020 H2 - Main work focus==
* Carry-over of win32k.sys lockdown prerequisites from 2020 H1.
* Carry-over of stalled GPU sandboxing work.
* [https://bugzilla.mozilla.org/show_bug.cgi?id=1381019 Remaining win32k.sys blockers].
* [https://bugzilla.mozilla.org/show_bug.cgi?id=1620114 Enable CIG in RDD].
** Investigate/experiment with feasibility of shipping CIG in content.
 
= Communication =
 
{| class="wikitable fullwidth-table"
| Weekly Team Meeting
|| Thursday at 8:00am PT
* Zoom: By invitation, ask gcp@mozilla.com
* [https://wiki.mozilla.org/Security/Sandbox/Meeting_Notes Meeting Notes Archive]
|-
| Matrix
||
* Server: chat.mozilla.org
* Channel: [https://chat.mozilla.org/#/room/#hardening:mozilla.org #hardening]
|-
|}
|}


==== 2014 ====
= People =
{| class="toccolours" style="width: 100%"
 
|{{Special:PrefixIndex/Security/Sandbox/2014}}
{| class="wikitable fullwidth-table"
| Engineering Management
||
* Gian-Carlo Pascutto (gcp)
|-
| Project Management
||
* N/A
|-
| QA
||
* N/A
|-
| Development Team
||
* Haik Aftandilian (haik)
* Jed Davis (jld)
* Chris Martin (cmartin)
* Bob Owen (bobowen)
* David Parks (handyman)
* Stephen Pohl (spohl)
* Gian-Carlo Pascutto (gcp)
|}
|}


= Additional resources =
= Repo Module Ownership =
== Sandboxing ==
* [[Modules/Core#Sandboxing_-_Windows|Windows]]
* [[Features/Security/Low_rights_Firefox]] -- {{bug|730956}}
* [[Modules/Core#Sandboxing_-_OSX|OSX]]
* [https://intranet.mozilla.org/User:Imelven@mozilla.com/Sandboxing Ian's sandboxing page]
* [[Modules/Core#Sandboxing_-_Linux|Linux]]
* [https://github.com/mozilla/servo/wiki Servo]
 
= Links =
 
* [[Electrolysis]] Wiki Page (lot of additional resource links)
* [[Security/Sandbox/macOS_Release]] - description of what to do when a new macOS release comes out in order to find out what updates they made to the sandbox.
* [http://www.chromium.org/developers/design-documents/sandbox Chromium Sandbox]
* [http://www.chromium.org/developers/design-documents/sandbox Chromium Sandbox]
* [[B2G/Architecture/System_Security/Seccomp|seccomp sandboxing on b2g]]
* [http://reverse.put.as/wp-content/uploads/2011/09/Apple-Sandbox-Guide-v1.0.pdf Apple's Sandbox guide]
* [http://reverse.put.as/wp-content/uploads/2011/09/Apple-Sandbox-Guide-v1.0.pdf Apple's Sandbox guide]
* [https://developer.mozilla.org/en-US/docs/IPDL/Tutorial IPDL Tutorial]
* [http://blog.cr0.org/2012/09/introducing-chromes-next-generation.html "Introducing Chrome's next-generation Linux sandbox"] (seccomp-bpf related)
* [https://developer.mozilla.org/en-US/docs/DocShell DocShell]
* [http://en.wikipedia.org/wiki/Google_Native_Client Native Client on Wikipedia] (Links to papers on Native Client's design and use of SFI, as well as papers on SFI itself.)
* [http://blog.cr0.org/2012/09/introducing-chromes-next-generation.html "Introducing Chrome's next-generation Linux sandbox" — useful blog post about seccomp-bpf]
* [https://msdn.microsoft.com/en-us/library/windows/desktop/ff966517%28v=vs.85%29.aspx?f=255&MSPPError=-2147217396 Features of Protected Mode in Internet Explorer]


=== Not up to date/Archived ===
== B2G Archive ==
* [https://docs.google.com/document/d/1opnXiB9qSEtqQKABx3A3gQmuzbUjCkxcVqYaRUYF-8I/edit?usp=sharing One page overview]
* [https://developer.mozilla.org/en-US/Firefox_OS/Security/System_security Firefox OS System Security page on MDN]
* [https://docs.google.com/document/d/1q8ZK1eDHOHXB7-chKKdK1cyUl56hTmN7XDUe6pE10hI/edit?usp=sharing FAQ]
* [https://wiki.mozilla.org/Security/Sandbox/Seccomp Sandboxing on b2g overview]
* [https://docs.google.com/a/mozilla.com/document/d/1qS4Q1goehqy-55hIQEsEA_XY3lF4xfFColNKQm37KSg/edit?usp=sharing Standing meeting notes]
* [[B2G/Architecture/System_Security/Seccomp|seccomp b2g filter perf data]]
* [https://docs.google.com/a/mozilla.com/document/d/14E5ERudaZrx-qcOLttXGkV6DgHIyp3h9IZoqnhuO7X8/edit Process Model]
* [https://docs.google.com/a/mozilla.com/document/d/1xkRd6xs_QQtBWdo0IIwjdDOnhTvQTDsyt-t_qR7Sw64/edit Addon Strategy]
* [[FoxInABox/ThingsThatShouldWork]]


== Related projects ==
B2G has always been “sandboxed” to some extent; every app/tab gets its own content process, which uses the Android security model: a separate uid per process, no group memberships, and kernel patches that require group membership for things like network access. But privilege escalation via kernel vulnerabilities is relatively common, so we also use the seccomp-bpf system call filter to reduce the attack surface that a compromised content process can directly access.
* [[Electrolysis]]
* [http://billmccloskey.wordpress.com/2013/12/05/multiprocess-firefox/ Multiprocess Firefox summary by Bill Mc Closkey]
* [[Embedding/IPCLiteAPI]], [https://github.com/tmeshkova/mozilla-central https://github.com/tmeshkova/mozilla-central]
* [http://en.wikipedia.org/wiki/Google_Native_Client Native Client on Wikipedia] - has links to papers on Native Client's design and use of SFI, as well as papers on SFI itself
* [[AMO/Squeaky]], or Make Addons Awesome

Latest revision as of 17:47, 6 February 2024

Overview

550px-Sandboxing basic architecture.png

Security Sandboxing makes use of child processes as a security boundary. The process model, i.e. how Firefox is split into various processes and how these processes interact between each other is common to all platforms. For more information see the Electrolysis wiki page, and its sucessor, Project Fission. The security aspects of a sandboxed child process are implemented on a per-platform basis. See the Platform Specifics section below for more information.

Technical Docs

Current Status

Sandbox Trunk Beta Release
Level Level Version Level Version
Windows (content) Level 6 Level 6 Fx76 Level 6 Fx76
Windows (compositor) Level 1 Level 1 Level 1
Windows (GMP) enabled enabled enabled
Windows (Socket) Level 1 Level 1 Fx75 Level 1 Fx75
OSX (content) Level 3 Level 3 Fx56 Level 3 Fx56
OSX (GMP) enabled enabled enabled
OSX (RDD) enabled enabled enabled
OSX (Socket) enabled disabled disabled
Linux (content) Level 4 Level 4 Fx60 Level 4 Fx60
Linux (GMP) enabled enabled enabled

A 'level' value reflects unique sandbox security settings for each platform and process. Most processes only have two "active" levels, the current setting and a lower (previous released) setting. Level settings other than these two values carry no guarantee of altering security behavior, level settings are primarily a release rollout debugging feature.

Windows

Content

Sandbox security related setting are grouped together and associated with a security level. Lower level values indicate a less restrictive sandbox.

Sandbox Feature Level 5 Level 6 (default)
Job Level JOB_LOCKDOWN JOB_LOCKDOWN
Access Token Level USER_LIMITED USER_LIMITED
Alternate Desktop YES YES
Alternate Windows Station YES YES
Initial Integrity Level INTEGRITY_LEVEL_LOW INTEGRITY_LEVEL_LOW
Delayed Integrity Level INTEGRITY_LEVEL_LOW INTEGRITY_LEVEL_LOW
Mitigations

MITIGATION_BOTTOM_UP_ASLR
MITIGATION_HEAP_TERMINATE
MITIGATION_SEHOP
MITIGATION_DEP_NO_ATL_THUNK
MITIGATION_DEP
MITIGATION_EXTENSION_POINT_DISABLE
MITIGATION_IMAGE_LOAD_NO_REMOTE
MITIGATION_IMAGE_LOAD_NO_LOW_LABEL
MITIGATION_IMAGE_LOAD_PREFER_SYS32
MITIGATION_CONTROL_FLOW_GUARD_DISABLE
MITIGATION_WIN32K_DISABLE

MITIGATION_BOTTOM_UP_ASLR
MITIGATION_HEAP_TERMINATE
MITIGATION_SEHOP
MITIGATION_DEP_NO_ATL_THUNK
MITIGATION_DEP
MITIGATION_EXTENSION_POINT_DISABLE
MITIGATION_IMAGE_LOAD_NO_REMOTE
MITIGATION_IMAGE_LOAD_NO_LOW_LABEL
MITIGATION_IMAGE_LOAD_PREFER_SYS32
MITIGATION_CONTROL_FLOW_GUARD_DISABLE
MITIGATION_WIN32K_DISABLE
Locked Down Default DACL

Delayed Mitigations

MITIGATION_STRICT_HANDLE_CHECKS
MITIGATION_DLL_SEARCH_ORDER

MITIGATION_STRICT_HANDLE_CHECKS
MITIGATION_DLL_SEARCH_ORDER

Windows Feature Header

Gecko Media Plugin (GMP)

Sandbox Feature Level
Job Level JOB_LOCKDOWN
Access Token Level USER_LOCKDOWN, USER_RESTRICTED[1]
Initial Integrity Level INTEGRITY_LEVEL_LOW
Delayed Integrity Level INTEGRITY_LEVEL_UNTRUSTED
Alternate desktop yes
Mitigations

MITIGATION_BOTTOM_UP_ASLR
MITIGATION_HEAP_TERMINATE
MITIGATION_SEHOP
MITIGATION_EXTENSION_POINT_DISABLE
MITIGATION_DEP_NO_ATL_THUNK
MITIGATION_DEP
MITIGATION_NONSYSTEM_FONT_DISABLE
MITIGATION_IMAGE_LOAD_NO_REMOTE
MITIGATION_IMAGE_LOAD_NO_LOW_LABEL
MITIGATION_CET_COMPAT_MODE
Locked Down Default DACL

Delayed Mitigations

MITIGATION_STRICT_HANDLE_CHECKS
MITIGATION_DLL_SEARCH_ORDER

[1] depends on the media plugin

Remote Data Decoder (RDD)

Sandbox Feature Level
Job Level JOB_LOCKDOWN
Access Token Level USER_LIMITED
Initial Integrity Level INTEGRITY_LEVEL_LOW
Delayed Integrity Level INTEGRITY_LEVEL_LOW
Alternate desktop yes
Mitigations

MITIGATION_BOTTOM_UP_ASLR
MITIGATION_HEAP_TERMINATE
MITIGATION_SEHOP
MITIGATION_EXTENSION_POINT_DISABLE
MITIGATION_DEP_NO_ATL_THUNK
MITIGATION_DEP
MITIGATION_NONSYSTEM_FONT_DISABLE
MITIGATION_IMAGE_LOAD_NO_REMOTE
MITIGATION_IMAGE_LOAD_NO_LOW_LABEL
MITIGATION_IMAGE_LOAD_PREFER_SYS32
MITIGATION_CET_COMPAT_MODE
Locked Down Default DACL

Delayed Mitigations

MITIGATION_STRICT_HANDLE_CHECKS
MITIGATION_DYNAMIC_CODE_DISABLE
MITIGATION_DLL_SEARCH_ORDER
MITIGATION_FORCE_MS_SIGNED_BINS

OSX

Content Levels for Web and File Content Processes

Mac content processes use sandbox level 3. File content processes (for file:/// origins) also use level 3 with additional rules to allow read access to the filesystem. Levels 1 and 2 can still be enabled in about:config, but they are not supported and using them is not recommended. Different sandbox levels were used for testing and debugging during rollout of Mac sandboxing features, but they now are planned to be removed. Mac sandboxing uses a white list policy for all process types. Each policy begins with a statement to deny all access to system resources and then specifies the allowed resources. The level 3 sandbox allows file system read metadata access with full read access for specific system directories and some user directories, access to the microphone, access to various system services, windowserver, named sysctls and iokit properties, and other miscellaneous items. Work is ongoing to remove access to the microphone, windowserver, and other system services where possible. The sandbox blocks write access to all of the file system, read access to the profile directory (apart from the chrome and extensions subdirectories, read access to the home directory, inbound/outbound network I/O, exec, fork, printing, video input devices such as cameras. Older sandbox levels 1 and 2 are less restrictive. Mainly, level 2 allows file-read access to all of the filesystem except the ~/Library directory. Level 1 allows all file-read access. Level 1 restrictions are a subset of level 2. Level 2 restrictions are a subset of level 3.

The web and file content policy is defined in SandboxPolicyContent.h

Gecko Media Plugin Processes

The Gecko Media Plugins (GMP) policy is defined in SandboxPolicyGMP.h.

Remote Data Decoder Processes

The Remote Data Decoder (RDD) policy is defined in SandboxPolicyUtility.h.

Socket Process

The socket process policy is defined in SandboxPolicySocket.h. At this time (May 2020), the socket process sandbox is only used on the Nightly channel and only for WebRTC networking.

Linux

Content Levels

Job Level What's Blocked by the Sandbox?
Level 1
  • Many syscalls, including process creation
Level 2
  • Everything from level 1
  • Write access to the filesystem
    • Excludes shared memory, tempdir, video hardware
Level 3
  • Everything from level 1-2
  • Read access to most of the filesystem
    • Excludes themes/GTK configuration, fonts, shared data and libraries
Level 4
  • Everything from level 1-3
  • Network access including local sockets
    • Excludes X11 socket
  • System V IPC
    • Unless fgxlrx or VirtualGL is in use
  • Uses chroot jail
  • Uses Unprivileged User Namespaces (if available)

Content Rules

Filter ruleset

Filesystem access policy

Gecko Media Plugin

Filter ruleset

Customization Settings

The Linux sandbox allows some amount of control over the sandbox policy through various about:config settings. These are meant to allow more non-standard configurations and exotic distributions to stay working - without compiling custom versions of Firefox - even if they can't be directly supported by the default configuration.

See Activity Logging for information on how to debug these scenarios.

security.sandbox.content.level

  • See Content Levels above. Reducing this can help identify sandboxing as the cause of a problem, but you're better of trying the more fine grained permissions below.

security.sandbox.content.read_path_whitelist
security.sandbox.content.write_path_whitelist

  • Comma-separated list of additional paths that the content process is allowed to read from or write to, respectively. To allow access to an entire directory tree (rather than just the directory itself), include a trailing / character.

security.sandbox.content.syscall_whitelist

  • Comma-seperated list of additional system call numbers that should be allowed in the content process. These affect the seccomp-bpf filter.

Preferences

Process Type Preference Type Preference
Content numerical security.sandbox.content.level
Windows NPAPI Plugin numerical dom.ipc.plugins.sandbox-level.default
dom.ipc.plugins.sandbox-level.<plugintype>
Compositor numerical security.sandbox.gpu.level
Media Embedded N/A

Note - Levels greater than the current default for a particular process type are not implemented.

File System Restrictions

Sandboxing enforces file system write and read restrictions for XUL based add-on content (frame and process) scripts. To avoid issues as sandboxing features roll out add-on authors should update their legacy add-on code today such that content scripts no longer attempt to read or write from restricted locations. Note these restrictions do not affect WebExtension content script or XUL add-on script running in the browser process.

File system access rules for content processes, reverse precedence:

Location Access Type Restriction
file system read/write deny by default
install location write deny
install location read allow
system library locations write deny
system library locations read allow
profile/* read/write deny by default
profile/extensions write deny
profile/extensions read allow

Debugging Features

Activity Logging

The following prefs control sandbox logging. On Windows, output is sent to the Browser Console when available, and to a developer console attached to the running browser process. On OSX, once enabled, violation log entries are visible in the Console.app (/Applications/Utilities/Console.app). On Linux, once enabled, violation log entries are logged on the command line console.

security.sandbox.logging.enabled (boolean)
security.sandbox.windows.log.stackTraceDepth (integer, Windows specific)

The following environment variables also triggers sandbox logging output:

MOZ_SANDBOX_LOGGING=1

OSX Specific Sandbox Logging

On Mac, sandbox violation logging is disabled by default. To enable logging,

  1. Launch the OS X Console app (/Applications/Utilities/Console.app) and filter on "plugin-container".
  2. Either set the pref security.sandbox.logging.enabled=true and restart the browser OR launch the browser with the MOZ_SANDBOX_LOGGING environment variable set.

Linux specific Sandbox Logging

The following environment variable triggers extra sandbox debugging output:

MOZ_SANDBOX_LOGGING=1

Environment variables

ENVIRONMENT VARIABLE DESCRIPTION PLATFORM
MOZ_DISABLE_CONTENT_SANDBOX Disables content process sandboxing for debugging purposes. All
MOZ_DISABLE_GMP_SANDBOX Disable media plugin sandbox for debugging purposes All
MOZ_DISABLE_NPAPI_SANDBOX Disable 64-bit NPAPI process sandbox Windows and Mac
MOZ_DISABLE_GPU_SANDBOX Disable GPU process sandbox Windows
MOZ_DISABLE_RDD_SANDBOX Disable Data Decoder process sandbox All
MOZ_DISABLE_SOCKET_PROCESS_SANDBOX Disable Socket Process process sandbox All

Setting a custom environment in Windows

1) Close Firefox
2) Browser to the location of your Firefox install using Explorer
3) Shift + Right-click in the folder window where firefox.exe is located, select "Open command window here"
4) Add the environment variable(s) you wish to set to your command window -

set MOZ_DISABLE_NPAPI_SANDBOX=1(return)

5) enter firefox.exe and press enter to launch Firefox with your custom environment

Local Build Options

To disable building the sandbox completely build with this in your mozconfig:

ac_add_options --disable-sandbox

To disable just the content sandbox parts:

ac_add_options --disable-content-sandbox

Bug Lists

Priorities

Security/Process Sandboxing Lists

Triage Lists

  • Sandboxing Triage List: https://is.gd/ghRoW8
    • Lists sandboxing component bugs that are not tracked by a milestone
    • Ignores previously triaged into either sb- or sb+
    • Ignores meta bugs and bugs with needinfos
  • Global Triage List
    • Lists any bug in the database with sb?
    • Ignores bugs with needinfos
  • sb+ triage list
    • Previously triaged bugs that have no milestone and no priority set
  • sb? needinfos: http://is.gd/dnSyBs
  • webrtc specific sandboxing bugs: https://is.gd/c5bAe6
    • sb tracking + 'webrtc'

Roadmap

2020 H1 - Main work focus

2020 H2 - Main work focus

Communication

Weekly Team Meeting Thursday at 8:00am PT
Matrix

People

Engineering Management
  • Gian-Carlo Pascutto (gcp)
Project Management
  • N/A
QA
  • N/A
Development Team
  • Haik Aftandilian (haik)
  • Jed Davis (jld)
  • Chris Martin (cmartin)
  • Bob Owen (bobowen)
  • David Parks (handyman)
  • Stephen Pohl (spohl)
  • Gian-Carlo Pascutto (gcp)

Repo Module Ownership

Links

B2G Archive

B2G has always been “sandboxed” to some extent; every app/tab gets its own content process, which uses the Android security model: a separate uid per process, no group memberships, and kernel patches that require group membership for things like network access. But privilege escalation via kernel vulnerabilities is relatively common, so we also use the seccomp-bpf system call filter to reduce the attack surface that a compromised content process can directly access.