Bug 1525086 - Part 1 - Split up sandbox policies, create utility policy for the RDD process r=Alex_Gaynor
authorHaik Aftandilian <haftandilian@mozilla.com>
Wed, 27 Mar 2019 20:27:09 +0000
changeset 466499 4c6dfbf1662d955009ff939e842f6157a1bb3fec
parent 466498 6319c1c6a6a4728db33b7424579da7020a2d703a
child 466500 4fc01165236cdf0c3929fd1a5c5fb3731c863d29
push id35768
push useropoprus@mozilla.com
push dateThu, 28 Mar 2019 09:55:54 +0000
treeherdermozilla-central@c045dd97faf2 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersAlex_Gaynor
bugs1525086
milestone68.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1525086 - Part 1 - Split up sandbox policies, create utility policy for the RDD process r=Alex_Gaynor Move sandbox policies for different process types into their own files. Create a new "utility" policy cloned from the GMP policy to be used for basic utility-type processes. Use the utility policy for the RDD process. Differential Revision: https://phabricator.services.mozilla.com/D22405
dom/media/ipc/RDDParent.cpp
security/sandbox/mac/Sandbox.h
security/sandbox/mac/Sandbox.mm
security/sandbox/mac/SandboxPolicies.h
security/sandbox/mac/SandboxPolicyContent.h
security/sandbox/mac/SandboxPolicyFlash.h
security/sandbox/mac/SandboxPolicyGMP.h
security/sandbox/mac/SandboxPolicyUtility.h
security/sandbox/mac/moz.build
--- a/dom/media/ipc/RDDParent.cpp
+++ b/dom/media/ipc/RDDParent.cpp
@@ -105,17 +105,17 @@ static void StartRDDMacSandbox() {
 #  if !MOZ_DIAGNOSTIC_ASSERT_ENABLED
   Unused << result;
 #  endif
 
   nsAutoCString appPath;
   nsMacUtilsImpl::GetAppPath(appPath);
 
   MacSandboxInfo info;
-  info.type = MacSandboxType_Plugin;
+  info.type = MacSandboxType_Utility;
   info.shouldLog = Preferences::GetBool("security.sandbox.logging.enabled") ||
                    PR_GetEnv("MOZ_SANDBOX_LOGGING");
   info.appPath.assign(appPath.get());
   // Per Haik, set appBinaryPath and pluginBinaryPath to '/dev/null' to
   // make sure OSX sandbox policy isn't confused by empty strings for
   // the paths.
   info.appBinaryPath.assign("/dev/null");
   info.pluginInfo.pluginBinaryPath.assign("/dev/null");
--- a/security/sandbox/mac/Sandbox.h
+++ b/security/sandbox/mac/Sandbox.h
@@ -3,22 +3,26 @@
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #ifndef mozilla_Sandbox_h
 #define mozilla_Sandbox_h
 
 #include <string>
 
-#include "SandboxPolicies.h"
+#include "SandboxPolicyContent.h"
+#include "SandboxPolicyFlash.h"
+#include "SandboxPolicyGMP.h"
+#include "SandboxPolicyUtility.h"
 
 enum MacSandboxType {
   MacSandboxType_Default = 0,
   MacSandboxType_Plugin,
   MacSandboxType_Content,
+  MacSandboxType_Utility,
   MacSandboxType_Invalid
 };
 
 enum MacSandboxPluginType {
   MacSandboxPluginType_Default = 0,
   MacSandboxPluginType_GMPlugin_Default,       // Any Gecko Media Plugin
   MacSandboxPluginType_GMPlugin_OpenH264,      // Gecko Media Plugin, OpenH264
   MacSandboxPluginType_GMPlugin_EME,           // Gecko Media Plugin, EME
--- a/security/sandbox/mac/Sandbox.mm
+++ b/security/sandbox/mac/Sandbox.mm
@@ -135,17 +135,17 @@ bool StartMacSandbox(MacSandboxInfo cons
   std::string profile;
   std::string macOSMinor = std::to_string(OSXVersion::OSXVersionMinor());
 
   // Used for the Flash sandbox. Declared here so that they
   // stay in scope until sandbox_init_with_parameters is called.
   std::string flashCacheDir, flashTempDir, flashPath;
 
   if (aInfo.type == MacSandboxType_Plugin && aInfo.pluginInfo.type == MacSandboxPluginType_Flash) {
-    profile = flashPluginSandboxRules;
+    profile = SandboxPolicyFlash;
 
     params.push_back("SHOULD_LOG");
     params.push_back(aInfo.shouldLog ? "TRUE" : "FALSE");
 
     params.push_back("SANDBOX_LEVEL_1");
     params.push_back(aInfo.level == 1 ? "TRUE" : "FALSE");
     params.push_back("SANDBOX_LEVEL_2");
     params.push_back(aInfo.level == 2 ? "TRUE" : "FALSE");
@@ -177,34 +177,40 @@ bool StartMacSandbox(MacSandboxInfo cons
     params.push_back("DARWIN_USER_TEMP_DIR");
     if (!confstr(_CS_DARWIN_USER_TEMP_DIR, confStrBuf, sizeof(confStrBuf))) {
       return false;
     }
     if (!GetRealPath(flashTempDir, confStrBuf)) {
       return false;
     }
     params.push_back(flashTempDir.c_str());
+  } else if (aInfo.type == MacSandboxType_Utility) {
+    profile = const_cast<char *>(SandboxPolicyUtility);
+    params.push_back("SHOULD_LOG");
+    params.push_back(aInfo.shouldLog ? "TRUE" : "FALSE");
+    params.push_back("APP_PATH");
+    params.push_back(aInfo.appPath.c_str());
+    params.push_back("PLUGIN_BINARY_PATH");
+    params.push_back(aInfo.pluginInfo.pluginBinaryPath.c_str());
+    params.push_back("APP_BINARY_PATH");
+    params.push_back(aInfo.appBinaryPath.c_str());
   } else if (aInfo.type == MacSandboxType_Plugin) {
-    profile = const_cast<char *>(pluginSandboxRules);
+    profile = const_cast<char *>(SandboxPolicyGMP);
     params.push_back("SHOULD_LOG");
     params.push_back(aInfo.shouldLog ? "TRUE" : "FALSE");
     params.push_back("PLUGIN_BINARY_PATH");
     params.push_back(aInfo.pluginInfo.pluginBinaryPath.c_str());
     params.push_back("APP_PATH");
     params.push_back(aInfo.appPath.c_str());
     params.push_back("APP_BINARY_PATH");
     params.push_back(aInfo.appBinaryPath.c_str());
-
-    if (aInfo.pluginInfo.type == MacSandboxPluginType_GMPlugin_EME_Widevine) {
-      profile.append(widevinePluginSandboxRulesAddend);
-    }
   } else if (aInfo.type == MacSandboxType_Content) {
     MOZ_ASSERT(aInfo.level >= 1);
     if (aInfo.level >= 1) {
-      profile = contentSandboxRules;
+      profile = SandboxPolicyContent;
       params.push_back("SHOULD_LOG");
       params.push_back(aInfo.shouldLog ? "TRUE" : "FALSE");
       params.push_back("SANDBOX_LEVEL_1");
       params.push_back(aInfo.level == 1 ? "TRUE" : "FALSE");
       params.push_back("SANDBOX_LEVEL_2");
       params.push_back(aInfo.level == 2 ? "TRUE" : "FALSE");
       params.push_back("SANDBOX_LEVEL_3");
       params.push_back(aInfo.level == 3 ? "TRUE" : "FALSE");
@@ -243,20 +249,20 @@ bool StartMacSandbox(MacSandboxInfo cons
 #ifdef DEBUG
       if (!aInfo.debugWriteDir.empty()) {
         params.push_back("DEBUG_WRITE_DIR");
         params.push_back(aInfo.debugWriteDir.c_str());
       }
 #endif  // DEBUG
 
       if (aInfo.hasFilePrivileges) {
-        profile.append(fileContentProcessAddend);
+        profile.append(SandboxPolicyContentFileAddend);
       }
       if (aInfo.hasAudio) {
-        profile.append(contentProcessAudioAddend);
+        profile.append(SandboxPolicyContentAudioAddend);
       }
     } else {
       fprintf(stderr, "Content sandbox disabled due to sandbox level setting\n");
       return false;
     }
   } else {
     char *msg = NULL;
     asprintf(&msg, "Unexpected sandbox type %u", aInfo.type);
deleted file mode 100644
--- a/security/sandbox/mac/SandboxPolicies.h
+++ /dev/null
@@ -1,855 +0,0 @@
-/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-#ifndef mozilla_SandboxPolicies_h
-#define mozilla_SandboxPolicies_h
-
-#define MAX_TESTING_READ_PATHS 4
-
-namespace mozilla {
-
-static const char pluginSandboxRules[] = R"SANDBOX_LITERAL(
-  (version 1)
-
-  (define should-log (param "SHOULD_LOG"))
-  (define plugin-binary-path (param "PLUGIN_BINARY_PATH"))
-  (define app-path (param "APP_PATH"))
-  (define app-binary-path (param "APP_BINARY_PATH"))
-
-  (define (moz-deny feature)
-    (if (string=? should-log "TRUE")
-      (deny feature)
-      (deny feature (with no-log))))
-
-  (moz-deny default)
-  ; These are not included in (deny default)
-  (moz-deny process-info*)
-  ; This isn't available in some older macOS releases.
-  (if (defined? 'nvram*)
-    (moz-deny nvram*))
-  ; This property requires macOS 10.10+
-  (if (defined? 'file-map-executable)
-    (moz-deny file-map-executable))
-
-  (if (defined? 'file-map-executable)
-    (allow file-map-executable file-read*
-      (subpath "/System/Library/PrivateFrameworks")
-      (regex #"^/usr/lib/libstdc\+\+\.[^/]*dylib$")
-      (literal plugin-binary-path)
-      (literal app-binary-path)
-      (subpath app-path))
-    (allow file-read*
-      (subpath "/System/Library/PrivateFrameworks")
-      (regex #"^/usr/lib/libstdc\+\+\.[^/]*dylib$")
-      (literal plugin-binary-path)
-      (literal app-binary-path)
-      (subpath app-path)))
-
-  (allow signal (target self))
-  (allow sysctl-read)
-  (allow iokit-open (iokit-user-client-class "IOHIDParamUserClient"))
-  (allow file-read*
-      (literal "/etc")
-      (literal "/dev/random")
-      (literal "/dev/urandom")
-      (literal "/usr/share/icu/icudt51l.dat")
-      (subpath "/System/Library/Displays/Overrides")
-      (subpath "/System/Library/CoreServices/CoreTypes.bundle"))
-)SANDBOX_LITERAL";
-
-static const char widevinePluginSandboxRulesAddend[] = R"SANDBOX_LITERAL(
-  (allow mach-lookup (global-name "com.apple.windowserver.active"))
-)SANDBOX_LITERAL";
-
-static const char contentSandboxRules[] = R"SANDBOX_LITERAL(
-  (version 1)
-
-  (define should-log (param "SHOULD_LOG"))
-  (define sandbox-level-1 (param "SANDBOX_LEVEL_1"))
-  (define sandbox-level-2 (param "SANDBOX_LEVEL_2"))
-  (define sandbox-level-3 (param "SANDBOX_LEVEL_3"))
-  (define macosMinorVersion (string->number (param "MAC_OS_MINOR")))
-  (define appPath (param "APP_PATH"))
-  (define hasProfileDir (param "HAS_SANDBOXED_PROFILE"))
-  (define profileDir (param "PROFILE_DIR"))
-  (define hasWindowServer (param "HAS_WINDOW_SERVER"))
-  (define home-path (param "HOME_PATH"))
-  (define debugWriteDir (param "DEBUG_WRITE_DIR"))
-  (define testingReadPath1 (param "TESTING_READ_PATH1"))
-  (define testingReadPath2 (param "TESTING_READ_PATH2"))
-  (define testingReadPath3 (param "TESTING_READ_PATH3"))
-  (define testingReadPath4 (param "TESTING_READ_PATH4"))
-  (define crashPort (param "CRASH_PORT"))
-
-  (define (moz-deny feature)
-    (if (string=? should-log "TRUE")
-      (deny feature)
-      (deny feature (with no-log))))
-
-  (moz-deny default)
-  ; These are not included in (deny default)
-  (moz-deny process-info*)
-  ; This isn't available in some older macOS releases.
-  (if (defined? 'nvram*)
-    (moz-deny nvram*))
-  ; The next two properties both require macOS 10.10+
-  (if (defined? 'iokit-get-properties)
-    (moz-deny iokit-get-properties))
-  (if (defined? 'file-map-executable)
-    (moz-deny file-map-executable))
-
-  (if (string=? should-log "TRUE")
-    (debug deny))
-
-  (if (defined? 'file-map-executable)
-    (allow file-map-executable file-read*
-      (subpath "/System")
-      (subpath "/usr/lib")
-      (subpath "/Library/GPUBundles")
-      (subpath appPath))
-    (allow file-read*
-        (subpath "/System")
-        (subpath "/usr/lib")
-        (subpath "/Library/GPUBundles")
-        (subpath appPath)))
-
-  ; Allow read access to standard system paths.
-  (allow file-read*
-    (require-all (file-mode #o0004)
-      (require-any
-        (subpath "/Library/Filesystems/NetFSPlugins")
-        (subpath "/usr/share"))))
-
-  ; Top-level directory metadata access (bug 1404298)
-  (allow file-read-metadata (regex #"^/[^/]+$"))
-
-  (allow file-read-metadata
-    (literal "/private/etc/localtime")
-    (regex #"^/private/tmp/KSInstallAction\."))
-
-  ; Allow read access to standard special files.
-  (allow file-read*
-    (literal "/dev/autofs_nowait")
-    (literal "/dev/random")
-    (literal "/dev/urandom"))
-
-  (allow file-read*
-    file-write-data
-    (literal "/dev/null")
-    (literal "/dev/zero"))
-
-  (allow file-read*
-    file-write-data
-    file-ioctl
-    (literal "/dev/dtracehelper"))
-
-  ; Needed for things like getpriority()/setpriority()
-  (allow process-info-pidinfo process-info-setcontrol (target self))
-
-  ; macOS 10.9 does not support the |sysctl-name| predicate, so unfortunately
-  ; we need to allow all sysctl-reads there.
-  (if (= macosMinorVersion 9)
-    (allow sysctl-read)
-    (allow sysctl-read
-      (sysctl-name-regex #"^sysctl\.")
-      (sysctl-name "kern.ostype")
-      (sysctl-name "kern.osversion")
-      (sysctl-name "kern.osrelease")
-      (sysctl-name "kern.version")
-      ; TODO: remove "kern.hostname". Without it the tests hang, but the hostname
-      ; is arguably sensitive information, so we should see what can be done about
-      ; removing it.
-      (sysctl-name "kern.hostname")
-      (sysctl-name "hw.machine")
-      (sysctl-name "hw.model")
-      (sysctl-name "hw.ncpu")
-      (sysctl-name "hw.activecpu")
-      (sysctl-name "hw.byteorder")
-      (sysctl-name "hw.pagesize_compat")
-      (sysctl-name "hw.logicalcpu_max")
-      (sysctl-name "hw.physicalcpu_max")
-      (sysctl-name "hw.busfrequency_compat")
-      (sysctl-name "hw.busfrequency_max")
-      (sysctl-name "hw.cpufrequency")
-      (sysctl-name "hw.cpufrequency_compat")
-      (sysctl-name "hw.cpufrequency_max")
-      (sysctl-name "hw.l2cachesize")
-      (sysctl-name "hw.l3cachesize")
-      (sysctl-name "hw.cachelinesize")
-      (sysctl-name "hw.cachelinesize_compat")
-      (sysctl-name "hw.tbfrequency_compat")
-      (sysctl-name "hw.vectorunit")
-      (sysctl-name "hw.optional.sse2")
-      (sysctl-name "hw.optional.sse3")
-      (sysctl-name "hw.optional.sse4_1")
-      (sysctl-name "hw.optional.sse4_2")
-      (sysctl-name "hw.optional.avx1_0")
-      (sysctl-name "hw.optional.avx2_0")
-      (sysctl-name "machdep.cpu.vendor")
-      (sysctl-name "machdep.cpu.family")
-      (sysctl-name "machdep.cpu.model")
-      (sysctl-name "machdep.cpu.stepping")
-      (sysctl-name "debug.intel.gstLevelGST")
-      (sysctl-name "debug.intel.gstLoaderControl")))
-
-  (define (home-regex home-relative-regex)
-    (regex (string-append "^" (regex-quote home-path) home-relative-regex)))
-  (define (home-subpath home-relative-subpath)
-    (subpath (string-append home-path home-relative-subpath)))
-  (define (home-literal home-relative-literal)
-    (literal (string-append home-path home-relative-literal)))
-
-  (define (profile-subpath profile-relative-subpath)
-    (subpath (string-append profileDir profile-relative-subpath)))
-
-  (define (allow-shared-list domain)
-    (allow file-read*
-           (home-regex (string-append "/Library/Preferences/" (regex-quote domain)))))
-
-  (allow ipc-posix-shm-read-data ipc-posix-shm-write-data
-    (ipc-posix-name-regex #"^CFPBS:"))
-
-  (allow signal (target self))
-  (if (string? crashPort)
-    (allow mach-lookup (global-name crashPort)))
-  (if (string=? hasWindowServer "TRUE")
-    (allow mach-lookup (global-name "com.apple.windowserver.active")))
-  (allow mach-lookup
-    (global-name "com.apple.CoreServices.coreservicesd")
-    (global-name "com.apple.coreservices.launchservicesd")
-    (global-name "com.apple.lsd.mapdb"))
-
-  (if (>= macosMinorVersion 13)
-    (allow mach-lookup
-      ; bug 1392988
-      (xpc-service-name "com.apple.coremedia.videodecoder")
-      (xpc-service-name "com.apple.coremedia.videoencoder")))
-
-; bug 1312273
-  (if (= macosMinorVersion 9)
-     (allow mach-lookup (global-name "com.apple.xpcd")))
-
-  (allow iokit-open
-     (iokit-user-client-class "IOHIDParamUserClient"))
-
-  ; Only supported on macOS 10.10+
-  (if (defined? 'iokit-get-properties)
-    (allow iokit-get-properties
-      (iokit-property "board-id")
-      (iokit-property "vendor-id")
-      (iokit-property "device-id")
-      (iokit-property "IODVDBundleName")
-      (iokit-property "IOGLBundleName")
-      (iokit-property "IOGVACodec")
-      (iokit-property "IOGVAHEVCDecode")
-      (iokit-property "IOGVAHEVCEncode")
-      (iokit-property "IOPCITunnelled")
-      (iokit-property "IOVARendererID")
-      (iokit-property "MetalPluginName")
-      (iokit-property "MetalPluginClassName")))
-
-; depending on systems, the 1st, 2nd or both rules are necessary
-  (allow user-preference-read (preference-domain "com.apple.HIToolbox"))
-  (allow file-read-data (literal "/Library/Preferences/com.apple.HIToolbox.plist"))
-
-  (allow user-preference-read (preference-domain "com.apple.ATS"))
-  (allow file-read-data (literal "/Library/Preferences/.GlobalPreferences.plist"))
-
-  (allow file-read*
-      (subpath "/Library/ColorSync/Profiles")
-      (subpath "/Library/Spelling")
-      (literal "/")
-      (literal "/private/tmp")
-      (literal "/private/var/tmp")
-      (home-literal "/.CFUserTextEncoding")
-      (home-literal "/Library/Preferences/com.apple.DownloadAssessment.plist")
-      (home-subpath "/Library/Colors")
-      (home-subpath "/Library/ColorSync/Profiles")
-      (home-subpath "/Library/Keyboard Layouts")
-      (home-subpath "/Library/Input Methods")
-      (home-subpath "/Library/Spelling"))
-
-  (if (defined? 'file-map-executable)
-    (begin
-      (when testingReadPath1
-        (allow file-read* file-map-executable (subpath testingReadPath1)))
-      (when testingReadPath2
-        (allow file-read* file-map-executable (subpath testingReadPath2)))
-      (when testingReadPath3
-        (allow file-read* file-map-executable (subpath testingReadPath3)))
-      (when testingReadPath4
-        (allow file-read* file-map-executable (subpath testingReadPath4))))
-    (begin
-      (when testingReadPath1
-        (allow file-read* (subpath testingReadPath1)))
-      (when testingReadPath2
-        (allow file-read* (subpath testingReadPath2)))
-      (when testingReadPath3
-        (allow file-read* (subpath testingReadPath3)))
-      (when testingReadPath4
-        (allow file-read* (subpath testingReadPath4)))))
-
-  (allow file-read-metadata (home-subpath "/Library"))
-
-  (allow file-read-metadata (subpath "/private/var"))
-
-  ; bug 1303987
-  (if (string? debugWriteDir)
-    (begin
-      (allow file-write-data (subpath debugWriteDir))
-      (allow file-write-create
-        (require-all
-          (subpath debugWriteDir)
-          (vnode-type REGULAR-FILE)))))
-
-  (allow-shared-list "org.mozilla.plugincontainer")
-
-; Per-user and system-wide Extensions dir
-  (allow file-read*
-      (home-regex "/Library/Application Support/[^/]+/Extensions/")
-      (regex "^/Library/Application Support/[^/]+/Extensions/"))
-
-; bug 1393805
-  (allow file-read*
-      (home-subpath "/Library/Application Support/Mozilla/SystemExtensionsDev"))
-
-; The following rules impose file access restrictions which get
-; more restrictive in higher levels. When file-origin-specific
-; content processes are used for file:// origin browsing, the
-; global file-read* permission should be removed from each level.
-
-; level 1: global read access permitted, no global write access
-  (if (string=? sandbox-level-1 "TRUE") (allow file-read*))
-
-; level 2: global read access permitted, no global write access,
-;          no read/write access to ~/Library,
-;          no read/write access to $PROFILE,
-;          read access permitted to $PROFILE/{extensions,chrome}
-  (if (string=? sandbox-level-2 "TRUE")
-    (begin
-      ; bug 1201935
-      (allow file-read* (home-subpath "/Library/Caches/TemporaryItems"))
-      (if (string=? hasProfileDir "TRUE")
-        ; we have a profile dir
-        (allow file-read* (require-all
-          (require-not (home-subpath "/Library"))
-          (require-not (subpath profileDir))))
-        ; we don't have a profile dir
-        (allow file-read* (require-not (home-subpath "/Library"))))))
-
-  ; level 3: Does not have any of it's own rules. The global rules provide:
-  ;          no global read/write access,
-  ;          read access permitted to $PROFILE/{extensions,chrome}
-
-  (if (string=? hasProfileDir "TRUE")
-    ; we have a profile dir
-    (allow file-read*
-      (profile-subpath "/extensions")
-      (profile-subpath "/chrome")))
-
-; accelerated graphics
-  (allow user-preference-read (preference-domain "com.apple.opengl"))
-  (allow user-preference-read (preference-domain "com.nvidia.OpenGL"))
-  (allow mach-lookup
-      (global-name "com.apple.cvmsServ"))
-  (allow iokit-open
-      (iokit-connection "IOAccelerator")
-      (iokit-user-client-class "IOAccelerationUserClient")
-      (iokit-user-client-class "IOSurfaceRootUserClient")
-      (iokit-user-client-class "IOSurfaceSendRight")
-      (iokit-user-client-class "IOFramebufferSharedUserClient")
-      (iokit-user-client-class "AGPMClient")
-      (iokit-user-client-class "AppleGraphicsControlClient"))
-
-; bug 1153809
-  (allow iokit-open
-      (iokit-user-client-class "NVDVDContextTesla")
-      (iokit-user-client-class "Gen6DVDContext"))
-
-  ; Fonts
-  (allow file-read*
-    (subpath "/Library/Fonts")
-    (subpath "/Library/Application Support/Apple/Fonts")
-    (home-subpath "/Library/Fonts")
-    ; Allow read access to paths allowed via sandbox extensions.
-    ; This is needed for fonts in non-standard locations normally
-    ; due to third party font managers. The extensions are
-    ; automatically issued by the font server in response to font
-    ; API calls.
-    (extension "com.apple.app-sandbox.read"))
-  ; Fonts may continue to work without explicitly allowing these
-  ; services because, at present, connections are made to the services
-  ; before the sandbox is enabled as a side-effect of some API calls.
-  (allow mach-lookup
-    (global-name "com.apple.fonts")
-    (global-name "com.apple.FontObjectsServer"))
-  (if (<= macosMinorVersion 11)
-    (allow mach-lookup (global-name "com.apple.FontServer")))
-
-  ; Fonts
-  ; Workaround for sandbox extensions not being automatically
-  ; issued for fonts on 10.11 and earlier versions (bug 1460917).
-  (if (<= macosMinorVersion 11)
-    (allow file-read*
-      (regex #"\.[oO][tT][fF]$"          ; otf
-             #"\.[tT][tT][fF]$"          ; ttf
-             #"\.[tT][tT][cC]$"          ; ttc
-             #"\.[oO][tT][cC]$"          ; otc
-             #"\.[dD][fF][oO][nN][tT]$") ; dfont
-      (home-subpath "/Library/FontCollections")
-      (home-subpath "/Library/Application Support/Adobe/CoreSync/plugins/livetype")
-      (home-subpath "/Library/Application Support/FontAgent")
-      (home-subpath "/Library/Extensis/UTC") ; bug 1469657
-      (subpath "/Library/Extensis/UTC")      ; bug 1469657
-      (regex #"\.fontvault/")
-      (home-subpath "/FontExplorer X/Font Library")))
-)SANDBOX_LITERAL";
-
-// These are additional rules that are added to the content process rules for
-// file content processes.
-static const char fileContentProcessAddend[] = R"SANDBOX_LITERAL(
-  ; This process has blanket file read privileges
-  (allow file-read*)
-
-  ; File content processes need access to iconservices to draw file icons in
-  ; directory listings
-  (allow mach-lookup (global-name "com.apple.iconservices"))
-)SANDBOX_LITERAL";
-
-// These are additional rules that are added to the content process rules when
-// audio remoting is not enabled. (Once audio remoting is always used these
-// will be deleted.)
-static const char contentProcessAudioAddend[] = R"SANDBOX_LITERAL(
-  (allow ipc-posix-shm-read* ipc-posix-shm-write-data
-    (ipc-posix-name-regex #"^AudioIO"))
-
-  (allow mach-lookup
-    (global-name "com.apple.audio.coreaudiod")
-    (global-name "com.apple.audio.audiohald"))
-
-  (if (>= macosMinorVersion 13)
-    (allow mach-lookup
-    ; bug 1376163
-    (global-name "com.apple.audio.AudioComponentRegistrar")))
-
-  (allow iokit-open (iokit-user-client-class "IOAudioEngineUserClient"))
-
-  (allow file-read* (subpath "/Library/Audio/Plug-Ins"))
-
-  (allow device-microphone)
-)SANDBOX_LITERAL";
-
-// The "Safe Mode" Flash NPAPI plugin process profile
-static const char flashPluginSandboxRules[] = R"SANDBOX_LITERAL(
-  (version 1)
-
-  ; Parameters
-  (define shouldLog (param "SHOULD_LOG"))
-  (define sandbox-level-1 (param "SANDBOX_LEVEL_1"))
-  (define sandbox-level-2 (param "SANDBOX_LEVEL_2"))
-  (define macosMinorVersion (string->number (param "MAC_OS_MINOR")))
-  (define homeDir (param "HOME_PATH"))
-  (define tempDir (param "DARWIN_USER_TEMP_DIR"))
-  (define cacheDir (param "DARWIN_USER_CACHE_DIR"))
-  (define pluginPath (param "PLUGIN_BINARY_PATH"))
-
-  (if (string=? shouldLog "TRUE")
-      (deny default)
-      (deny default (with no-log)))
-  (debug deny)
-  (allow system-audit file-read-metadata)
-  ; These are not included in (deny default)
-  (deny process-info*)
-  ; This isn't available in some older macOS releases.
-  (if (defined? 'nvram*)
-    (deny nvram*))
-
-  ; Allow read access to standard system paths.
-  (allow file-read*
-    (require-all (file-mode #o0004)
-      (require-any
-        (subpath "/System")
-        (subpath "/usr/lib")
-        (subpath "/Library/Filesystems/NetFSPlugins")
-        (subpath "/Library/GPUBundles")
-        (subpath "/usr/share"))))
-  (allow file-read-metadata
-         (literal "/etc")
-         (literal "/tmp")
-         (literal "/var")
-         (literal "/private/etc/localtime"))
-  (allow file-read*
-         (literal "/dev/autofs_nowait")
-         (literal "/dev/random")
-         (literal "/dev/urandom"))
-  (allow file-read*
-         file-write-data
-         (literal "/dev/null")
-         (literal "/dev/zero"))
-  (allow file-read*
-         file-write-data
-         file-ioctl
-         (literal "/dev/dtracehelper"))
-
-  ; Graphics
-  (allow user-preference-read
-         (preference-domain "com.apple.opengl")
-         (preference-domain "com.nvidia.OpenGL"))
-  (allow mach-lookup
-         (global-name "com.apple.cvmsServ"))
-  (allow iokit-open
-         (iokit-connection "IOAccelerator")
-         (iokit-user-client-class "IOAccelerationUserClient")
-         (iokit-user-client-class "IOSurfaceRootUserClient")
-         (iokit-user-client-class "IOSurfaceSendRight"))
-  (allow iokit-open
-         (iokit-user-client-class "AppleIntelMEUserClient")
-         (iokit-user-client-class "AppleSNBFBUserClient"))
-  (allow iokit-open
-         (iokit-user-client-class "AGPMClient")
-         (iokit-user-client-class "AppleGraphicsControlClient")
-         (iokit-user-client-class "AppleGraphicsPolicyClient"))
-  ; Camera access
-  (allow iokit-open
-         (iokit-user-client-class "IOUSBDeviceUserClientV2")
-         (iokit-user-client-class "IOUSBInterfaceUserClientV2"))
-
-  ; Network
-  (allow file-read*
-         (literal "/Library/Preferences/com.apple.networkd.plist"))
-  (allow mach-lookup
-         (global-name "com.apple.SystemConfiguration.PPPController")
-         (global-name "com.apple.SystemConfiguration.SCNetworkReachability")
-         (global-name "com.apple.nehelper")
-         (global-name "com.apple.networkd")
-         (global-name "com.apple.nsurlstorage-cache")
-         (global-name "com.apple.symptomsd")
-         (global-name "com.apple.usymptomsd"))
-  (allow network-outbound
-         (control-name "com.apple.netsrc")
-         (control-name "com.apple.network.statistics"))
-  (allow system-socket
-         (require-all (socket-domain AF_SYSTEM)
-                      (socket-protocol 2)) ; SYSPROTO_CONTROL
-         (socket-domain AF_ROUTE))
-  (allow network-outbound
-      (literal "/private/var/run/mDNSResponder")
-      (literal "/private/var/run/asl_input")
-      (literal "/private/var/run/syslog")
-      (remote tcp)
-      (remote udp))
-  (allow network-inbound
-      (local udp))
-
-  (allow process-info-pidinfo)
-  (allow process-info-setcontrol (target self))
-
-  ; macOS 10.9 does not support the |sysctl-name| predicate
-  (if (= macosMinorVersion 9)
-      (allow sysctl-read)
-      (allow sysctl-read
-        (sysctl-name
-          "hw.activecpu"
-          "hw.availcpu"
-          "hw.busfrequency_max"
-          "hw.cpu64bit_capable"
-          "hw.cputype"
-          "hw.physicalcpu_max"
-          "hw.logicalcpu_max"
-          "hw.machine"
-          "hw.model"
-          "hw.ncpu"
-          "hw.optional.avx1_0"
-          "hw.optional.avx2_0"
-          "hw.optional.sse2"
-          "hw.optional.sse3"
-          "hw.optional.sse4_1"
-          "hw.optional.sse4_2"
-          "hw.optional.x86_64"
-          "kern.hostname"
-          "kern.maxfilesperproc"
-          "kern.memorystatus_level"
-          "kern.osrelease"
-          "kern.ostype"
-          "kern.osvariant_status"
-          "kern.osversion"
-          "kern.safeboot"
-          "kern.version"
-          "vm.footprint_suspend")))
-
-  ; Utilities for allowing access to home subdirectories
-  (define home-library-path
-    (string-append homeDir "/Library"))
-
-  (define (home-subpath home-relative-subpath)
-    (subpath (string-append homeDir home-relative-subpath)))
-
-  (define home-library-prefs-path
-    (string-append homeDir "/Library" "/Preferences"))
-
-  (define (home-literal home-relative-literal)
-    (literal (string-append homeDir home-relative-literal)))
-
-  (define (home-library-regex home-library-relative-regex)
-    (regex (string-append "^" (regex-quote home-library-path))
-           home-library-relative-regex))
-
-  (define (home-library-subpath home-library-relative-subpath)
-      (subpath (string-append home-library-path home-library-relative-subpath)))
-
-  (define (home-library-literal home-library-relative-literal)
-      (literal (string-append home-library-path home-library-relative-literal)))
-
-  (define (home-library-preferences-literal
-           home-library-preferences-relative-literal)
-      (literal (string-append home-library-prefs-path
-                home-library-preferences-relative-literal)))
-
-  ; Utility for allowing access to a temp dir subdirectory
-  (define (tempDir-regex tempDir-relative-regex)
-    (regex (string-append "^" (regex-quote tempDir)) tempDir-relative-regex))
-
-  ; Utility for allowing access to specific files within the cache dir
-  (define (cache-literal cache-relative-literal)
-    (literal (string-append cacheDir cache-relative-literal)))
-
-  ; Read-only paths
-  (allow file-read*
-      (literal "/")
-      (literal "/private/etc/services")
-      (literal "/private/etc/resolv.conf")
-      (literal "/private/var/run/resolv.conf")
-      (subpath "/Library/Frameworks")
-      (subpath "/Library/Managed Preferences")
-      (home-literal "/.CFUserTextEncoding")
-      (home-library-subpath "/Audio")
-      (home-library-subpath "/ColorPickers")
-      (home-library-subpath "/ColorSync")
-      (subpath "/Library/Components")
-      (home-library-subpath "/Components")
-      (subpath "/Library/Contextual Menu Items")
-      (subpath "/Library/Input Methods")
-      (home-library-subpath "/Input Methods")
-      (subpath "/Library/InputManagers")
-      (home-library-subpath "/InputManagers")
-      (home-library-subpath "/KeyBindings")
-      (subpath "/Library/Keyboard Layouts")
-      (home-library-subpath "/Keyboard Layouts")
-      (subpath "/Library/Spelling")
-      (home-library-subpath "/Spelling")
-      (home-library-literal "/Caches/com.apple.coreaudio.components.plist")
-      (subpath "/Library/Audio/Sounds")
-      (subpath "/Library/Audio/Plug-Ins/Components")
-      (home-library-subpath "/Audio/Plug-Ins/Components")
-      (subpath "/Library/Audio/Plug-Ins/HAL")
-      (subpath "/Library/CoreMediaIO/Plug-Ins/DAL")
-      (subpath "/Library/QuickTime")
-      (home-library-subpath "/QuickTime")
-      (subpath "/Library/Video/Plug-Ins")
-      (home-library-subpath "/Caches/QuickTime")
-      (subpath "/Library/ColorSync")
-      (home-literal "/Library/Preferences/com.apple.lookup.shared.plist"))
-
-  (allow iokit-open
-      (iokit-user-client-class "IOAudioControlUserClient")
-      (iokit-user-client-class "IOAudioEngineUserClient")
-      (iokit-user-client-class "IOHIDParamUserClient")
-      (iokit-user-client-class "RootDomainUserClient"))
-
-  ; Services
-  (allow mach-lookup
-      (global-name "com.apple.audio.AudioComponentRegistrar")
-      (global-name "com.apple.DiskArbitration.diskarbitrationd")
-      (global-name "com.apple.ImageCaptureExtension2.presence")
-      (global-name "com.apple.PowerManagement.control")
-      (global-name "com.apple.SecurityServer")
-      (global-name "com.apple.SystemConfiguration.PPPController")
-      (global-name "com.apple.SystemConfiguration.configd")
-      (global-name "com.apple.UNCUserNotification")
-      (global-name "com.apple.audio.audiohald")
-      (global-name "com.apple.audio.coreaudiod")
-      (global-name "com.apple.cfnetwork.AuthBrokerAgent")
-      (global-name "com.apple.lsd.mapdb")
-      (global-name "com.apple.pasteboard.1") ; Allows paste into input field
-      (global-name "com.apple.dock.server")
-      (global-name "com.apple.dock.fullscreen")
-      (global-name "com.apple.coreservices.appleevents")
-      (global-name "com.apple.coreservices.launchservicesd")
-      (global-name "com.apple.window_proxies")
-      (local-name "com.apple.tsm.portname")
-      (global-name "com.apple.axserver")
-      (global-name "com.apple.pbs.fetch_services")
-      (global-name "com.apple.tsm.uiserver")
-      (global-name "com.apple.inputmethodkit.launchagent")
-      (global-name "com.apple.inputmethodkit.launcher")
-      (global-name "com.apple.inputmethodkit.getxpcendpoint")
-      (global-name "com.apple.decalog4.incoming")
-      (global-name "com.apple.windowserver.active")
-      (global-name "com.apple.trustd.agent")
-      (global-name "com.apple.ocspd"))
-  ; Required for camera access
-  (allow mach-lookup
-      (global-name "com.apple.tccd")
-      (global-name "com.apple.tccd.system")
-      (global-name "com.apple.cmio.AppleCameraAssistant")
-      (global-name "com.apple.cmio.IIDCVideoAssistant")
-      (global-name "com.apple.cmio.AVCAssistant")
-      (global-name "com.apple.cmio.VDCAssistant"))
-  ; bug 1475707
-  (if (= macosMinorVersion 9)
-     (allow mach-lookup (global-name "com.apple.xpcd")))
-
-  ; Fonts
-  (allow file-read*
-    (subpath "/Library/Fonts")
-    (subpath "/Library/Application Support/Apple/Fonts")
-    (home-library-subpath "/Fonts")
-    ; Allow read access to paths allowed via sandbox extensions.
-    ; This is needed for fonts in non-standard locations normally
-    ; due to third party font managers. The extensions are
-    ; automatically issued by the font server in response to font
-    ; API calls.
-    (extension "com.apple.app-sandbox.read"))
-  ; Fonts may continue to work without explicitly allowing these
-  ; services because, at present, connections are made to the services
-  ; before the sandbox is enabled as a side-effect of some API calls.
-  (allow mach-lookup
-    (global-name "com.apple.fonts")
-    (global-name "com.apple.FontObjectsServer"))
-  (if (<= macosMinorVersion 11)
-    (allow mach-lookup (global-name "com.apple.FontServer")))
-
-  ; Fonts
-  ; Workaround for sandbox extensions not being automatically
-  ; issued for fonts on 10.11 and earlier versions (bug 1460917).
-  (if (<= macosMinorVersion 11)
-    (allow file-read*
-      (regex #"\.[oO][tT][fF]$"          ; otf
-             #"\.[tT][tT][fF]$"          ; ttf
-             #"\.[tT][tT][cC]$"          ; ttc
-             #"\.[oO][tT][cC]$"          ; otc
-             #"\.[dD][fF][oO][nN][tT]$") ; dfont
-      (home-subpath "/Library/FontCollections")
-      (home-subpath "/Library/Application Support/Adobe/CoreSync/plugins/livetype")
-      (home-subpath "/Library/Application Support/FontAgent")
-      (home-subpath "/Library/Extensis/UTC") ; bug 1469657
-      (subpath "/Library/Extensis/UTC")      ; bug 1469657
-      (regex #"\.fontvault/")
-      (home-subpath "/FontExplorer X/Font Library")))
-
-  ; level 1: global read access permitted, no global write access
-  (if (string=? sandbox-level-1 "TRUE") (allow file-read*))
-
-  ; level 2: read access via file dialog exceptions, no global write access
-  (if (or (string=? sandbox-level-2 "TRUE")
-          (string=? sandbox-level-1 "TRUE")) (begin
-    ; Open file dialogs
-    (allow mach-lookup
-	; needed for the dialog sidebar
-	(global-name "com.apple.coreservices.sharedfilelistd.xpc")
-	; bird(8) -- "Documents in the Cloud"
-	; needed to avoid iCloud error dialogs and to display iCloud files
-	(global-name "com.apple.bird")
-	(global-name "com.apple.bird.token")
-	; needed for icons in the file dialog
-	(global-name "com.apple.iconservices"))
-    ; Needed for read access to files selected by the user with the
-    ; file dialog. The extensions are granted when the dialog is
-    ; displayed. Unfortunately (testing revealed) that displaying
-    ; the file dialog grants access to all files within the directory
-    ; displayed by the file dialog--a small improvement compared
-    ; to global read access.
-    (allow file-read*
-	(extension "com.apple.app-sandbox.read-write"))))
-
-  (allow ipc-posix-shm*
-      (ipc-posix-name-regex #"^AudioIO")
-      (ipc-posix-name-regex #"^CFPBS:"))
-
-  (allow ipc-posix-shm-read*
-      (ipc-posix-name-regex #"^/tmp/com\.apple\.csseed\.")
-      (ipc-posix-name "FNetwork.defaultStorageSession")
-      (ipc-posix-name "apple.shm.notification_center"))
-
-  ; Printing
-  (allow network-outbound (literal "/private/var/run/cupsd"))
-  (allow mach-lookup
-      (global-name "com.apple.printuitool.agent")
-      (global-name "com.apple.printtool.agent")
-      (global-name "com.apple.printtool.daemon"))
-  (allow file-read*
-      (subpath "/Library/Printers")
-      (home-literal "/.cups/lpoptions")
-      (home-literal "/.cups/client.conf")
-      (literal "/private/etc/cups/client.conf")
-      (literal "/private/etc/cups/lpoptions")
-      (subpath "/private/etc/cups/ppd")
-      (literal "/private/var/run/cupsd"))
-  (allow user-preference-read
-      (preference-domain "org.cups.PrintingPrefs"))
-  ; Temporary files read/written here during printing
-  (allow file-read* file-write-create file-write-data
-      (tempDir-regex "/FlashTmp"))
-
-  ; Camera/Mic
-  (allow device-camera)
-  (allow device-microphone)
-
-  ; Path to the plugin binary, user cache dir, and user temp dir
-  (allow file-read* (subpath pluginPath))
-
-  ; Per Adobe, needed for Flash LocalConnection functionality
-  (allow ipc-posix-sem
-      (ipc-posix-name "MacromediaSemaphoreDig"))
-
-  ; Flash debugger and enterprise deployment config files
-  (allow file-read*
-      (home-literal "/mm.cfg")
-      (home-literal "/mms.cfg"))
-
-  (allow file-read* file-write-create file-write-mode file-write-owner
-      (home-library-literal "/Caches/Adobe")
-      (home-library-preferences-literal "/Macromedia"))
-
-  (allow file-read* file-write-create file-write-data
-      (literal "/Library/Application Support/Macromedia/mms.cfg")
-      (home-library-literal "/Application Support/Macromedia/mms.cfg")
-      (home-library-subpath "/Caches/Adobe/Flash Player"))
-  (allow file-read* file-write-create file-write-data file-write-unlink
-      (home-library-subpath "/Preferences/Macromedia/Flash Player"))
-
-  (allow file-read*
-      (literal "/Library/PreferencePanes/Flash Player.prefPane")
-      (home-library-literal "/PreferencePanes/Flash Player.prefPane")
-      (home-library-regex "/Application Support/Macromedia/ss\.(cfg|cfn|sgn)$"))
-
-  (allow file-read*
-      (literal "/Library/Preferences/com.apple.security.plist")
-      (subpath "/private/var/db/mds"))
-
-  ; Additional read/write paths needed for encrypted video playback.
-  ; Tests revealed file-write-{data,create,flags} are required for the
-  ; accesses to the mds files. file-write-{data,create,mode,unlink}
-  ; required for CertStore.dat access. Allow file-write* to match system
-  ; profiles and for better compatibilty.
-  (allow file-read* file-write*
-      (require-all
-          (vnode-type REGULAR-FILE)
-          (require-any
-              (cache-literal "/mds/mds.lock")
-              (cache-literal "/mds/mdsDirectory.db")
-              (cache-literal "/mds/mdsDirectory.db_")
-              (cache-literal "/mds/mdsObject.db")
-              (cache-literal "/mds/mdsObject.db_")
-              (tempDir-regex "/TemporaryItems/[^/]+/CertStore.dat"))))
-
-  (allow network-bind (local ip))
-
-  (deny file-write-create (vnode-type SYMLINK))
-)SANDBOX_LITERAL";
-
-}  // namespace mozilla
-
-#endif  // mozilla_SandboxPolicies_h
new file mode 100644
--- /dev/null
+++ b/security/sandbox/mac/SandboxPolicyContent.h
@@ -0,0 +1,393 @@
+/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+#ifndef mozilla_SandboxPolicyContent_h
+#define mozilla_SandboxPolicyContent_h
+
+#define MAX_TESTING_READ_PATHS 4
+
+namespace mozilla {
+
+static const char SandboxPolicyContent[] = R"SANDBOX_LITERAL(
+  (version 1)
+
+  (define should-log (param "SHOULD_LOG"))
+  (define sandbox-level-1 (param "SANDBOX_LEVEL_1"))
+  (define sandbox-level-2 (param "SANDBOX_LEVEL_2"))
+  (define sandbox-level-3 (param "SANDBOX_LEVEL_3"))
+  (define macosMinorVersion (string->number (param "MAC_OS_MINOR")))
+  (define appPath (param "APP_PATH"))
+  (define hasProfileDir (param "HAS_SANDBOXED_PROFILE"))
+  (define profileDir (param "PROFILE_DIR"))
+  (define hasWindowServer (param "HAS_WINDOW_SERVER"))
+  (define home-path (param "HOME_PATH"))
+  (define debugWriteDir (param "DEBUG_WRITE_DIR"))
+  (define testingReadPath1 (param "TESTING_READ_PATH1"))
+  (define testingReadPath2 (param "TESTING_READ_PATH2"))
+  (define testingReadPath3 (param "TESTING_READ_PATH3"))
+  (define testingReadPath4 (param "TESTING_READ_PATH4"))
+  (define crashPort (param "CRASH_PORT"))
+
+  (define (moz-deny feature)
+    (if (string=? should-log "TRUE")
+      (deny feature)
+      (deny feature (with no-log))))
+
+  (moz-deny default)
+  ; These are not included in (deny default)
+  (moz-deny process-info*)
+  ; This isn't available in some older macOS releases.
+  (if (defined? 'nvram*)
+    (moz-deny nvram*))
+  ; The next two properties both require macOS 10.10+
+  (if (defined? 'iokit-get-properties)
+    (moz-deny iokit-get-properties))
+  (if (defined? 'file-map-executable)
+    (moz-deny file-map-executable))
+
+  (if (string=? should-log "TRUE")
+    (debug deny))
+
+  (if (defined? 'file-map-executable)
+    (allow file-map-executable file-read*
+      (subpath "/System")
+      (subpath "/usr/lib")
+      (subpath "/Library/GPUBundles")
+      (subpath appPath))
+    (allow file-read*
+        (subpath "/System")
+        (subpath "/usr/lib")
+        (subpath "/Library/GPUBundles")
+        (subpath appPath)))
+
+  ; Allow read access to standard system paths.
+  (allow file-read*
+    (require-all (file-mode #o0004)
+      (require-any
+        (subpath "/Library/Filesystems/NetFSPlugins")
+        (subpath "/usr/share"))))
+
+  ; Top-level directory metadata access (bug 1404298)
+  (allow file-read-metadata (regex #"^/[^/]+$"))
+
+  (allow file-read-metadata
+    (literal "/private/etc/localtime")
+    (regex #"^/private/tmp/KSInstallAction\."))
+
+  ; Allow read access to standard special files.
+  (allow file-read*
+    (literal "/dev/autofs_nowait")
+    (literal "/dev/random")
+    (literal "/dev/urandom"))
+
+  (allow file-read*
+    file-write-data
+    (literal "/dev/null")
+    (literal "/dev/zero"))
+
+  (allow file-read*
+    file-write-data
+    file-ioctl
+    (literal "/dev/dtracehelper"))
+
+  ; Needed for things like getpriority()/setpriority()
+  (allow process-info-pidinfo process-info-setcontrol (target self))
+
+  ; macOS 10.9 does not support the |sysctl-name| predicate, so unfortunately
+  ; we need to allow all sysctl-reads there.
+  (if (= macosMinorVersion 9)
+    (allow sysctl-read)
+    (allow sysctl-read
+      (sysctl-name-regex #"^sysctl\.")
+      (sysctl-name "kern.ostype")
+      (sysctl-name "kern.osversion")
+      (sysctl-name "kern.osrelease")
+      (sysctl-name "kern.version")
+      ; TODO: remove "kern.hostname". Without it the tests hang, but the hostname
+      ; is arguably sensitive information, so we should see what can be done about
+      ; removing it.
+      (sysctl-name "kern.hostname")
+      (sysctl-name "hw.machine")
+      (sysctl-name "hw.model")
+      (sysctl-name "hw.ncpu")
+      (sysctl-name "hw.activecpu")
+      (sysctl-name "hw.byteorder")
+      (sysctl-name "hw.pagesize_compat")
+      (sysctl-name "hw.logicalcpu_max")
+      (sysctl-name "hw.physicalcpu_max")
+      (sysctl-name "hw.busfrequency_compat")
+      (sysctl-name "hw.busfrequency_max")
+      (sysctl-name "hw.cpufrequency")
+      (sysctl-name "hw.cpufrequency_compat")
+      (sysctl-name "hw.cpufrequency_max")
+      (sysctl-name "hw.l2cachesize")
+      (sysctl-name "hw.l3cachesize")
+      (sysctl-name "hw.cachelinesize")
+      (sysctl-name "hw.cachelinesize_compat")
+      (sysctl-name "hw.tbfrequency_compat")
+      (sysctl-name "hw.vectorunit")
+      (sysctl-name "hw.optional.sse2")
+      (sysctl-name "hw.optional.sse3")
+      (sysctl-name "hw.optional.sse4_1")
+      (sysctl-name "hw.optional.sse4_2")
+      (sysctl-name "hw.optional.avx1_0")
+      (sysctl-name "hw.optional.avx2_0")
+      (sysctl-name "machdep.cpu.vendor")
+      (sysctl-name "machdep.cpu.family")
+      (sysctl-name "machdep.cpu.model")
+      (sysctl-name "machdep.cpu.stepping")
+      (sysctl-name "debug.intel.gstLevelGST")
+      (sysctl-name "debug.intel.gstLoaderControl")))
+
+  (define (home-regex home-relative-regex)
+    (regex (string-append "^" (regex-quote home-path) home-relative-regex)))
+  (define (home-subpath home-relative-subpath)
+    (subpath (string-append home-path home-relative-subpath)))
+  (define (home-literal home-relative-literal)
+    (literal (string-append home-path home-relative-literal)))
+
+  (define (profile-subpath profile-relative-subpath)
+    (subpath (string-append profileDir profile-relative-subpath)))
+
+  (define (allow-shared-list domain)
+    (allow file-read*
+           (home-regex (string-append "/Library/Preferences/" (regex-quote domain)))))
+
+  (allow ipc-posix-shm-read-data ipc-posix-shm-write-data
+    (ipc-posix-name-regex #"^CFPBS:"))
+
+  (allow signal (target self))
+  (if (string? crashPort)
+    (allow mach-lookup (global-name crashPort)))
+  (if (string=? hasWindowServer "TRUE")
+    (allow mach-lookup (global-name "com.apple.windowserver.active")))
+  (allow mach-lookup
+    (global-name "com.apple.CoreServices.coreservicesd")
+    (global-name "com.apple.coreservices.launchservicesd")
+    (global-name "com.apple.lsd.mapdb"))
+
+  (if (>= macosMinorVersion 13)
+    (allow mach-lookup
+      ; bug 1392988
+      (xpc-service-name "com.apple.coremedia.videodecoder")
+      (xpc-service-name "com.apple.coremedia.videoencoder")))
+
+; bug 1312273
+  (if (= macosMinorVersion 9)
+     (allow mach-lookup (global-name "com.apple.xpcd")))
+
+  (allow iokit-open
+     (iokit-user-client-class "IOHIDParamUserClient"))
+
+  ; Only supported on macOS 10.10+
+  (if (defined? 'iokit-get-properties)
+    (allow iokit-get-properties
+      (iokit-property "board-id")
+      (iokit-property "vendor-id")
+      (iokit-property "device-id")
+      (iokit-property "IODVDBundleName")
+      (iokit-property "IOGLBundleName")
+      (iokit-property "IOGVACodec")
+      (iokit-property "IOGVAHEVCDecode")
+      (iokit-property "IOGVAHEVCEncode")
+      (iokit-property "IOPCITunnelled")
+      (iokit-property "IOVARendererID")
+      (iokit-property "MetalPluginName")
+      (iokit-property "MetalPluginClassName")))
+
+; depending on systems, the 1st, 2nd or both rules are necessary
+  (allow user-preference-read (preference-domain "com.apple.HIToolbox"))
+  (allow file-read-data (literal "/Library/Preferences/com.apple.HIToolbox.plist"))
+
+  (allow user-preference-read (preference-domain "com.apple.ATS"))
+  (allow file-read-data (literal "/Library/Preferences/.GlobalPreferences.plist"))
+
+  (allow file-read*
+      (subpath "/Library/ColorSync/Profiles")
+      (subpath "/Library/Spelling")
+      (literal "/")
+      (literal "/private/tmp")
+      (literal "/private/var/tmp")
+      (home-literal "/.CFUserTextEncoding")
+      (home-literal "/Library/Preferences/com.apple.DownloadAssessment.plist")
+      (home-subpath "/Library/Colors")
+      (home-subpath "/Library/ColorSync/Profiles")
+      (home-subpath "/Library/Keyboard Layouts")
+      (home-subpath "/Library/Input Methods")
+      (home-subpath "/Library/Spelling"))
+
+  (if (defined? 'file-map-executable)
+    (begin
+      (when testingReadPath1
+        (allow file-read* file-map-executable (subpath testingReadPath1)))
+      (when testingReadPath2
+        (allow file-read* file-map-executable (subpath testingReadPath2)))
+      (when testingReadPath3
+        (allow file-read* file-map-executable (subpath testingReadPath3)))
+      (when testingReadPath4
+        (allow file-read* file-map-executable (subpath testingReadPath4))))
+    (begin
+      (when testingReadPath1
+        (allow file-read* (subpath testingReadPath1)))
+      (when testingReadPath2
+        (allow file-read* (subpath testingReadPath2)))
+      (when testingReadPath3
+        (allow file-read* (subpath testingReadPath3)))
+      (when testingReadPath4
+        (allow file-read* (subpath testingReadPath4)))))
+
+  (allow file-read-metadata (home-subpath "/Library"))
+
+  (allow file-read-metadata (subpath "/private/var"))
+
+  ; bug 1303987
+  (if (string? debugWriteDir)
+    (begin
+      (allow file-write-data (subpath debugWriteDir))
+      (allow file-write-create
+        (require-all
+          (subpath debugWriteDir)
+          (vnode-type REGULAR-FILE)))))
+
+  (allow-shared-list "org.mozilla.plugincontainer")
+
+; Per-user and system-wide Extensions dir
+  (allow file-read*
+      (home-regex "/Library/Application Support/[^/]+/Extensions/")
+      (regex "^/Library/Application Support/[^/]+/Extensions/"))
+
+; bug 1393805
+  (allow file-read*
+      (home-subpath "/Library/Application Support/Mozilla/SystemExtensionsDev"))
+
+; The following rules impose file access restrictions which get
+; more restrictive in higher levels. When file-origin-specific
+; content processes are used for file:// origin browsing, the
+; global file-read* permission should be removed from each level.
+
+; level 1: global read access permitted, no global write access
+  (if (string=? sandbox-level-1 "TRUE") (allow file-read*))
+
+; level 2: global read access permitted, no global write access,
+;          no read/write access to ~/Library,
+;          no read/write access to $PROFILE,
+;          read access permitted to $PROFILE/{extensions,chrome}
+  (if (string=? sandbox-level-2 "TRUE")
+    (begin
+      ; bug 1201935
+      (allow file-read* (home-subpath "/Library/Caches/TemporaryItems"))
+      (if (string=? hasProfileDir "TRUE")
+        ; we have a profile dir
+        (allow file-read* (require-all
+          (require-not (home-subpath "/Library"))
+          (require-not (subpath profileDir))))
+        ; we don't have a profile dir
+        (allow file-read* (require-not (home-subpath "/Library"))))))
+
+  ; level 3: Does not have any of it's own rules. The global rules provide:
+  ;          no global read/write access,
+  ;          read access permitted to $PROFILE/{extensions,chrome}
+
+  (if (string=? hasProfileDir "TRUE")
+    ; we have a profile dir
+    (allow file-read*
+      (profile-subpath "/extensions")
+      (profile-subpath "/chrome")))
+
+; accelerated graphics
+  (allow user-preference-read (preference-domain "com.apple.opengl"))
+  (allow user-preference-read (preference-domain "com.nvidia.OpenGL"))
+  (allow mach-lookup
+      (global-name "com.apple.cvmsServ"))
+  (allow iokit-open
+      (iokit-connection "IOAccelerator")
+      (iokit-user-client-class "IOAccelerationUserClient")
+      (iokit-user-client-class "IOSurfaceRootUserClient")
+      (iokit-user-client-class "IOSurfaceSendRight")
+      (iokit-user-client-class "IOFramebufferSharedUserClient")
+      (iokit-user-client-class "AGPMClient")
+      (iokit-user-client-class "AppleGraphicsControlClient"))
+
+; bug 1153809
+  (allow iokit-open
+      (iokit-user-client-class "NVDVDContextTesla")
+      (iokit-user-client-class "Gen6DVDContext"))
+
+  ; Fonts
+  (allow file-read*
+    (subpath "/Library/Fonts")
+    (subpath "/Library/Application Support/Apple/Fonts")
+    (home-subpath "/Library/Fonts")
+    ; Allow read access to paths allowed via sandbox extensions.
+    ; This is needed for fonts in non-standard locations normally
+    ; due to third party font managers. The extensions are
+    ; automatically issued by the font server in response to font
+    ; API calls.
+    (extension "com.apple.app-sandbox.read"))
+  ; Fonts may continue to work without explicitly allowing these
+  ; services because, at present, connections are made to the services
+  ; before the sandbox is enabled as a side-effect of some API calls.
+  (allow mach-lookup
+    (global-name "com.apple.fonts")
+    (global-name "com.apple.FontObjectsServer"))
+  (if (<= macosMinorVersion 11)
+    (allow mach-lookup (global-name "com.apple.FontServer")))
+
+  ; Fonts
+  ; Workaround for sandbox extensions not being automatically
+  ; issued for fonts on 10.11 and earlier versions (bug 1460917).
+  (if (<= macosMinorVersion 11)
+    (allow file-read*
+      (regex #"\.[oO][tT][fF]$"          ; otf
+             #"\.[tT][tT][fF]$"          ; ttf
+             #"\.[tT][tT][cC]$"          ; ttc
+             #"\.[oO][tT][cC]$"          ; otc
+             #"\.[dD][fF][oO][nN][tT]$") ; dfont
+      (home-subpath "/Library/FontCollections")
+      (home-subpath "/Library/Application Support/Adobe/CoreSync/plugins/livetype")
+      (home-subpath "/Library/Application Support/FontAgent")
+      (home-subpath "/Library/Extensis/UTC") ; bug 1469657
+      (subpath "/Library/Extensis/UTC")      ; bug 1469657
+      (regex #"\.fontvault/")
+      (home-subpath "/FontExplorer X/Font Library")))
+)SANDBOX_LITERAL";
+
+// These are additional rules that are added to the content process rules for
+// file content processes.
+static const char SandboxPolicyContentFileAddend[] = R"SANDBOX_LITERAL(
+  ; This process has blanket file read privileges
+  (allow file-read*)
+
+  ; File content processes need access to iconservices to draw file icons in
+  ; directory listings
+  (allow mach-lookup (global-name "com.apple.iconservices"))
+)SANDBOX_LITERAL";
+
+// These are additional rules that are added to the content process rules when
+// audio remoting is not enabled. (Once audio remoting is always used these
+// will be deleted.)
+static const char SandboxPolicyContentAudioAddend[] = R"SANDBOX_LITERAL(
+  (allow ipc-posix-shm-read* ipc-posix-shm-write-data
+    (ipc-posix-name-regex #"^AudioIO"))
+
+  (allow mach-lookup
+    (global-name "com.apple.audio.coreaudiod")
+    (global-name "com.apple.audio.audiohald"))
+
+  (if (>= macosMinorVersion 13)
+    (allow mach-lookup
+    ; bug 1376163
+    (global-name "com.apple.audio.AudioComponentRegistrar")))
+
+  (allow iokit-open (iokit-user-client-class "IOAudioEngineUserClient"))
+
+  (allow file-read* (subpath "/Library/Audio/Plug-Ins"))
+
+  (allow device-microphone)
+)SANDBOX_LITERAL";
+
+}  // namespace mozilla
+
+#endif  // mozilla_SandboxPolicyContent_h
new file mode 100644
--- /dev/null
+++ b/security/sandbox/mac/SandboxPolicyFlash.h
@@ -0,0 +1,422 @@
+/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+#ifndef mozilla_SandboxPolicyFlash_h
+#define mozilla_SandboxPolicyFlash_h
+
+namespace mozilla {
+
+// Flash NPAPI plugin process profile
+static const char SandboxPolicyFlash[] = R"SANDBOX_LITERAL(
+  (version 1)
+
+  ; Parameters
+  (define shouldLog (param "SHOULD_LOG"))
+  (define sandbox-level-1 (param "SANDBOX_LEVEL_1"))
+  (define sandbox-level-2 (param "SANDBOX_LEVEL_2"))
+  (define macosMinorVersion (string->number (param "MAC_OS_MINOR")))
+  (define homeDir (param "HOME_PATH"))
+  (define tempDir (param "DARWIN_USER_TEMP_DIR"))
+  (define cacheDir (param "DARWIN_USER_CACHE_DIR"))
+  (define pluginPath (param "PLUGIN_BINARY_PATH"))
+
+  (if (string=? shouldLog "TRUE")
+      (deny default)
+      (deny default (with no-log)))
+  (debug deny)
+  (allow system-audit file-read-metadata)
+  ; These are not included in (deny default)
+  (deny process-info*)
+  ; This isn't available in some older macOS releases.
+  (if (defined? 'nvram*)
+    (deny nvram*))
+
+  ; Allow read access to standard system paths.
+  (allow file-read*
+    (require-all (file-mode #o0004)
+      (require-any
+        (subpath "/System")
+        (subpath "/usr/lib")
+        (subpath "/Library/Filesystems/NetFSPlugins")
+        (subpath "/Library/GPUBundles")
+        (subpath "/usr/share"))))
+  (allow file-read-metadata
+         (literal "/etc")
+         (literal "/tmp")
+         (literal "/var")
+         (literal "/private/etc/localtime"))
+  (allow file-read*
+         (literal "/dev/autofs_nowait")
+         (literal "/dev/random")
+         (literal "/dev/urandom"))
+  (allow file-read*
+         file-write-data
+         (literal "/dev/null")
+         (literal "/dev/zero"))
+  (allow file-read*
+         file-write-data
+         file-ioctl
+         (literal "/dev/dtracehelper"))
+
+  ; Graphics
+  (allow user-preference-read
+         (preference-domain "com.apple.opengl")
+         (preference-domain "com.nvidia.OpenGL"))
+  (allow mach-lookup
+         (global-name "com.apple.cvmsServ"))
+  (allow iokit-open
+         (iokit-connection "IOAccelerator")
+         (iokit-user-client-class "IOAccelerationUserClient")
+         (iokit-user-client-class "IOSurfaceRootUserClient")
+         (iokit-user-client-class "IOSurfaceSendRight"))
+  (allow iokit-open
+         (iokit-user-client-class "AppleIntelMEUserClient")
+         (iokit-user-client-class "AppleSNBFBUserClient"))
+  (allow iokit-open
+         (iokit-user-client-class "AGPMClient")
+         (iokit-user-client-class "AppleGraphicsControlClient")
+         (iokit-user-client-class "AppleGraphicsPolicyClient"))
+  ; Camera access
+  (allow iokit-open
+         (iokit-user-client-class "IOUSBDeviceUserClientV2")
+         (iokit-user-client-class "IOUSBInterfaceUserClientV2"))
+
+  ; Network
+  (allow file-read*
+         (literal "/Library/Preferences/com.apple.networkd.plist"))
+  (allow mach-lookup
+         (global-name "com.apple.SystemConfiguration.PPPController")
+         (global-name "com.apple.SystemConfiguration.SCNetworkReachability")
+         (global-name "com.apple.nehelper")
+         (global-name "com.apple.networkd")
+         (global-name "com.apple.nsurlstorage-cache")
+         (global-name "com.apple.symptomsd")
+         (global-name "com.apple.usymptomsd"))
+  (allow network-outbound
+         (control-name "com.apple.netsrc")
+         (control-name "com.apple.network.statistics"))
+  (allow system-socket
+         (require-all (socket-domain AF_SYSTEM)
+                      (socket-protocol 2)) ; SYSPROTO_CONTROL
+         (socket-domain AF_ROUTE))
+  (allow network-outbound
+      (literal "/private/var/run/mDNSResponder")
+      (literal "/private/var/run/asl_input")
+      (literal "/private/var/run/syslog")
+      (remote tcp)
+      (remote udp))
+  (allow network-inbound
+      (local udp))
+
+  (allow process-info-pidinfo)
+  (allow process-info-setcontrol (target self))
+
+  ; macOS 10.9 does not support the |sysctl-name| predicate
+  (if (= macosMinorVersion 9)
+      (allow sysctl-read)
+      (allow sysctl-read
+        (sysctl-name
+          "hw.activecpu"
+          "hw.availcpu"
+          "hw.busfrequency_max"
+          "hw.cpu64bit_capable"
+          "hw.cputype"
+          "hw.physicalcpu_max"
+          "hw.logicalcpu_max"
+          "hw.machine"
+          "hw.model"
+          "hw.ncpu"
+          "hw.optional.avx1_0"
+          "hw.optional.avx2_0"
+          "hw.optional.sse2"
+          "hw.optional.sse3"
+          "hw.optional.sse4_1"
+          "hw.optional.sse4_2"
+          "hw.optional.x86_64"
+          "kern.hostname"
+          "kern.maxfilesperproc"
+          "kern.memorystatus_level"
+          "kern.osrelease"
+          "kern.ostype"
+          "kern.osvariant_status"
+          "kern.osversion"
+          "kern.safeboot"
+          "kern.version"
+          "vm.footprint_suspend")))
+
+  ; Utilities for allowing access to home subdirectories
+  (define home-library-path
+    (string-append homeDir "/Library"))
+
+  (define (home-subpath home-relative-subpath)
+    (subpath (string-append homeDir home-relative-subpath)))
+
+  (define home-library-prefs-path
+    (string-append homeDir "/Library" "/Preferences"))
+
+  (define (home-literal home-relative-literal)
+    (literal (string-append homeDir home-relative-literal)))
+
+  (define (home-library-regex home-library-relative-regex)
+    (regex (string-append "^" (regex-quote home-library-path))
+           home-library-relative-regex))
+
+  (define (home-library-subpath home-library-relative-subpath)
+      (subpath (string-append home-library-path home-library-relative-subpath)))
+
+  (define (home-library-literal home-library-relative-literal)
+      (literal (string-append home-library-path home-library-relative-literal)))
+
+  (define (home-library-preferences-literal
+           home-library-preferences-relative-literal)
+      (literal (string-append home-library-prefs-path
+                home-library-preferences-relative-literal)))
+
+  ; Utility for allowing access to a temp dir subdirectory
+  (define (tempDir-regex tempDir-relative-regex)
+    (regex (string-append "^" (regex-quote tempDir)) tempDir-relative-regex))
+
+  ; Utility for allowing access to specific files within the cache dir
+  (define (cache-literal cache-relative-literal)
+    (literal (string-append cacheDir cache-relative-literal)))
+
+  ; Read-only paths
+  (allow file-read*
+      (literal "/")
+      (literal "/private/etc/services")
+      (literal "/private/etc/resolv.conf")
+      (literal "/private/var/run/resolv.conf")
+      (subpath "/Library/Frameworks")
+      (subpath "/Library/Managed Preferences")
+      (home-literal "/.CFUserTextEncoding")
+      (home-library-subpath "/Audio")
+      (home-library-subpath "/ColorPickers")
+      (home-library-subpath "/ColorSync")
+      (subpath "/Library/Components")
+      (home-library-subpath "/Components")
+      (subpath "/Library/Contextual Menu Items")
+      (subpath "/Library/Input Methods")
+      (home-library-subpath "/Input Methods")
+      (subpath "/Library/InputManagers")
+      (home-library-subpath "/InputManagers")
+      (home-library-subpath "/KeyBindings")
+      (subpath "/Library/Keyboard Layouts")
+      (home-library-subpath "/Keyboard Layouts")
+      (subpath "/Library/Spelling")
+      (home-library-subpath "/Spelling")
+      (home-library-literal "/Caches/com.apple.coreaudio.components.plist")
+      (subpath "/Library/Audio/Sounds")
+      (subpath "/Library/Audio/Plug-Ins/Components")
+      (home-library-subpath "/Audio/Plug-Ins/Components")
+      (subpath "/Library/Audio/Plug-Ins/HAL")
+      (subpath "/Library/CoreMediaIO/Plug-Ins/DAL")
+      (subpath "/Library/QuickTime")
+      (home-library-subpath "/QuickTime")
+      (subpath "/Library/Video/Plug-Ins")
+      (home-library-subpath "/Caches/QuickTime")
+      (subpath "/Library/ColorSync")
+      (home-literal "/Library/Preferences/com.apple.lookup.shared.plist"))
+
+  (allow iokit-open
+      (iokit-user-client-class "IOAudioControlUserClient")
+      (iokit-user-client-class "IOAudioEngineUserClient")
+      (iokit-user-client-class "IOHIDParamUserClient")
+      (iokit-user-client-class "RootDomainUserClient"))
+
+  ; Services
+  (allow mach-lookup
+      (global-name "com.apple.audio.AudioComponentRegistrar")
+      (global-name "com.apple.DiskArbitration.diskarbitrationd")
+      (global-name "com.apple.ImageCaptureExtension2.presence")
+      (global-name "com.apple.PowerManagement.control")
+      (global-name "com.apple.SecurityServer")
+      (global-name "com.apple.SystemConfiguration.PPPController")
+      (global-name "com.apple.SystemConfiguration.configd")
+      (global-name "com.apple.UNCUserNotification")
+      (global-name "com.apple.audio.audiohald")
+      (global-name "com.apple.audio.coreaudiod")
+      (global-name "com.apple.cfnetwork.AuthBrokerAgent")
+      (global-name "com.apple.lsd.mapdb")
+      (global-name "com.apple.pasteboard.1") ; Allows paste into input field
+      (global-name "com.apple.dock.server")
+      (global-name "com.apple.dock.fullscreen")
+      (global-name "com.apple.coreservices.appleevents")
+      (global-name "com.apple.coreservices.launchservicesd")
+      (global-name "com.apple.window_proxies")
+      (local-name "com.apple.tsm.portname")
+      (global-name "com.apple.axserver")
+      (global-name "com.apple.pbs.fetch_services")
+      (global-name "com.apple.tsm.uiserver")
+      (global-name "com.apple.inputmethodkit.launchagent")
+      (global-name "com.apple.inputmethodkit.launcher")
+      (global-name "com.apple.inputmethodkit.getxpcendpoint")
+      (global-name "com.apple.decalog4.incoming")
+      (global-name "com.apple.windowserver.active")
+      (global-name "com.apple.trustd.agent")
+      (global-name "com.apple.ocspd"))
+  ; Required for camera access
+  (allow mach-lookup
+      (global-name "com.apple.tccd")
+      (global-name "com.apple.tccd.system")
+      (global-name "com.apple.cmio.AppleCameraAssistant")
+      (global-name "com.apple.cmio.IIDCVideoAssistant")
+      (global-name "com.apple.cmio.AVCAssistant")
+      (global-name "com.apple.cmio.VDCAssistant"))
+  ; bug 1475707
+  (if (= macosMinorVersion 9)
+     (allow mach-lookup (global-name "com.apple.xpcd")))
+
+  ; Fonts
+  (allow file-read*
+    (subpath "/Library/Fonts")
+    (subpath "/Library/Application Support/Apple/Fonts")
+    (home-library-subpath "/Fonts")
+    ; Allow read access to paths allowed via sandbox extensions.
+    ; This is needed for fonts in non-standard locations normally
+    ; due to third party font managers. The extensions are
+    ; automatically issued by the font server in response to font
+    ; API calls.
+    (extension "com.apple.app-sandbox.read"))
+  ; Fonts may continue to work without explicitly allowing these
+  ; services because, at present, connections are made to the services
+  ; before the sandbox is enabled as a side-effect of some API calls.
+  (allow mach-lookup
+    (global-name "com.apple.fonts")
+    (global-name "com.apple.FontObjectsServer"))
+  (if (<= macosMinorVersion 11)
+    (allow mach-lookup (global-name "com.apple.FontServer")))
+
+  ; Fonts
+  ; Workaround for sandbox extensions not being automatically
+  ; issued for fonts on 10.11 and earlier versions (bug 1460917).
+  (if (<= macosMinorVersion 11)
+    (allow file-read*
+      (regex #"\.[oO][tT][fF]$"          ; otf
+             #"\.[tT][tT][fF]$"          ; ttf
+             #"\.[tT][tT][cC]$"          ; ttc
+             #"\.[oO][tT][cC]$"          ; otc
+             #"\.[dD][fF][oO][nN][tT]$") ; dfont
+      (home-subpath "/Library/FontCollections")
+      (home-subpath "/Library/Application Support/Adobe/CoreSync/plugins/livetype")
+      (home-subpath "/Library/Application Support/FontAgent")
+      (home-subpath "/Library/Extensis/UTC") ; bug 1469657
+      (subpath "/Library/Extensis/UTC")      ; bug 1469657
+      (regex #"\.fontvault/")
+      (home-subpath "/FontExplorer X/Font Library")))
+
+  ; level 1: global read access permitted, no global write access
+  (if (string=? sandbox-level-1 "TRUE") (allow file-read*))
+
+  ; level 2: read access via file dialog exceptions, no global write access
+  (if (or (string=? sandbox-level-2 "TRUE")
+          (string=? sandbox-level-1 "TRUE")) (begin
+    ; Open file dialogs
+    (allow mach-lookup
+	; needed for the dialog sidebar
+	(global-name "com.apple.coreservices.sharedfilelistd.xpc")
+	; bird(8) -- "Documents in the Cloud"
+	; needed to avoid iCloud error dialogs and to display iCloud files
+	(global-name "com.apple.bird")
+	(global-name "com.apple.bird.token")
+	; needed for icons in the file dialog
+	(global-name "com.apple.iconservices"))
+    ; Needed for read access to files selected by the user with the
+    ; file dialog. The extensions are granted when the dialog is
+    ; displayed. Unfortunately (testing revealed) that displaying
+    ; the file dialog grants access to all files within the directory
+    ; displayed by the file dialog--a small improvement compared
+    ; to global read access.
+    (allow file-read*
+	(extension "com.apple.app-sandbox.read-write"))))
+
+  (allow ipc-posix-shm*
+      (ipc-posix-name-regex #"^AudioIO")
+      (ipc-posix-name-regex #"^CFPBS:"))
+
+  (allow ipc-posix-shm-read*
+      (ipc-posix-name-regex #"^/tmp/com\.apple\.csseed\.")
+      (ipc-posix-name "FNetwork.defaultStorageSession")
+      (ipc-posix-name "apple.shm.notification_center"))
+
+  ; Printing
+  (allow network-outbound (literal "/private/var/run/cupsd"))
+  (allow mach-lookup
+      (global-name "com.apple.printuitool.agent")
+      (global-name "com.apple.printtool.agent")
+      (global-name "com.apple.printtool.daemon"))
+  (allow file-read*
+      (subpath "/Library/Printers")
+      (home-literal "/.cups/lpoptions")
+      (home-literal "/.cups/client.conf")
+      (literal "/private/etc/cups/client.conf")
+      (literal "/private/etc/cups/lpoptions")
+      (subpath "/private/etc/cups/ppd")
+      (literal "/private/var/run/cupsd"))
+  (allow user-preference-read
+      (preference-domain "org.cups.PrintingPrefs"))
+  ; Temporary files read/written here during printing
+  (allow file-read* file-write-create file-write-data
+      (tempDir-regex "/FlashTmp"))
+
+  ; Camera/Mic
+  (allow device-camera)
+  (allow device-microphone)
+
+  ; Path to the plugin binary, user cache dir, and user temp dir
+  (allow file-read* (subpath pluginPath))
+
+  ; Per Adobe, needed for Flash LocalConnection functionality
+  (allow ipc-posix-sem
+      (ipc-posix-name "MacromediaSemaphoreDig"))
+
+  ; Flash debugger and enterprise deployment config files
+  (allow file-read*
+      (home-literal "/mm.cfg")
+      (home-literal "/mms.cfg"))
+
+  (allow file-read* file-write-create file-write-mode file-write-owner
+      (home-library-literal "/Caches/Adobe")
+      (home-library-preferences-literal "/Macromedia"))
+
+  (allow file-read* file-write-create file-write-data
+      (literal "/Library/Application Support/Macromedia/mms.cfg")
+      (home-library-literal "/Application Support/Macromedia/mms.cfg")
+      (home-library-subpath "/Caches/Adobe/Flash Player"))
+  (allow file-read* file-write-create file-write-data file-write-unlink
+      (home-library-subpath "/Preferences/Macromedia/Flash Player"))
+
+  (allow file-read*
+      (literal "/Library/PreferencePanes/Flash Player.prefPane")
+      (home-library-literal "/PreferencePanes/Flash Player.prefPane")
+      (home-library-regex "/Application Support/Macromedia/ss\.(cfg|cfn|sgn)$"))
+
+  (allow file-read*
+      (literal "/Library/Preferences/com.apple.security.plist")
+      (subpath "/private/var/db/mds"))
+
+  ; Additional read/write paths needed for encrypted video playback.
+  ; Tests revealed file-write-{data,create,flags} are required for the
+  ; accesses to the mds files. file-write-{data,create,mode,unlink}
+  ; required for CertStore.dat access. Allow file-write* to match system
+  ; profiles and for better compatibilty.
+  (allow file-read* file-write*
+      (require-all
+          (vnode-type REGULAR-FILE)
+          (require-any
+              (cache-literal "/mds/mds.lock")
+              (cache-literal "/mds/mdsDirectory.db")
+              (cache-literal "/mds/mdsDirectory.db_")
+              (cache-literal "/mds/mdsObject.db")
+              (cache-literal "/mds/mdsObject.db_")
+              (tempDir-regex "/TemporaryItems/[^/]+/CertStore.dat"))))
+
+  (allow network-bind (local ip))
+
+  (deny file-write-create (vnode-type SYMLINK))
+)SANDBOX_LITERAL";
+
+}  // namespace mozilla
+
+#endif  // mozilla_SandboxPolicyFlash_h
new file mode 100644
--- /dev/null
+++ b/security/sandbox/mac/SandboxPolicyGMP.h
@@ -0,0 +1,64 @@
+/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+#ifndef mozilla_SandboxPolicyGMP_h
+#define mozilla_SandboxPolicyGMP_h
+
+namespace mozilla {
+
+static const char SandboxPolicyGMP[] = R"SANDBOX_LITERAL(
+  (version 1)
+
+  (define should-log (param "SHOULD_LOG"))
+  (define plugin-binary-path (param "PLUGIN_BINARY_PATH"))
+  (define app-path (param "APP_PATH"))
+  (define app-binary-path (param "APP_BINARY_PATH"))
+
+  (define (moz-deny feature)
+    (if (string=? should-log "TRUE")
+      (deny feature)
+      (deny feature (with no-log))))
+
+  (moz-deny default)
+  ; These are not included in (deny default)
+  (moz-deny process-info*)
+  ; This isn't available in some older macOS releases.
+  (if (defined? 'nvram*)
+    (moz-deny nvram*))
+  ; This property requires macOS 10.10+
+  (if (defined? 'file-map-executable)
+    (moz-deny file-map-executable))
+
+  (if (defined? 'file-map-executable)
+    (allow file-map-executable file-read*
+      (subpath "/System/Library/PrivateFrameworks")
+      (regex #"^/usr/lib/libstdc\+\+\.[^/]*dylib$")
+      (literal plugin-binary-path)
+      (literal app-binary-path)
+      (subpath app-path))
+    (allow file-read*
+      (subpath "/System/Library/PrivateFrameworks")
+      (regex #"^/usr/lib/libstdc\+\+\.[^/]*dylib$")
+      (literal plugin-binary-path)
+      (literal app-binary-path)
+      (subpath app-path)))
+
+  (allow signal (target self))
+  (allow sysctl-read)
+  (allow iokit-open (iokit-user-client-class "IOHIDParamUserClient"))
+  (allow file-read*
+      (literal "/etc")
+      (literal "/dev/random")
+      (literal "/dev/urandom")
+      (literal "/usr/share/icu/icudt51l.dat")
+      (subpath "/System/Library/Displays/Overrides")
+      (subpath "/System/Library/CoreServices/CoreTypes.bundle"))
+
+  (allow mach-lookup (global-name "com.apple.windowserver.active"))
+)SANDBOX_LITERAL";
+
+}  // namespace mozilla
+
+#endif  // mozilla_SandboxPolicyGMP_h
new file mode 100644
--- /dev/null
+++ b/security/sandbox/mac/SandboxPolicyUtility.h
@@ -0,0 +1,62 @@
+/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+#ifndef mozilla_SandboxPolicyUtility_h
+#define mozilla_SandboxPolicyUtility_h
+
+namespace mozilla {
+
+static const char SandboxPolicyUtility[] = R"SANDBOX_LITERAL(
+  (version 1)
+
+  (define should-log (param "SHOULD_LOG"))
+  (define plugin-binary-path (param "PLUGIN_BINARY_PATH"))
+  (define app-path (param "APP_PATH"))
+  (define app-binary-path (param "APP_BINARY_PATH"))
+
+  (define (moz-deny feature)
+    (if (string=? should-log "TRUE")
+      (deny feature)
+      (deny feature (with no-log))))
+
+  (moz-deny default)
+  ; These are not included in (deny default)
+  (moz-deny process-info*)
+  ; This isn't available in some older macOS releases.
+  (if (defined? 'nvram*)
+    (moz-deny nvram*))
+  ; This property requires macOS 10.10+
+  (if (defined? 'file-map-executable)
+    (moz-deny file-map-executable))
+
+  (if (defined? 'file-map-executable)
+    (allow file-map-executable file-read*
+      (subpath "/System/Library/PrivateFrameworks")
+      (regex #"^/usr/lib/libstdc\+\+\.[^/]*dylib$")
+      (literal plugin-binary-path)
+      (literal app-binary-path)
+      (subpath app-path))
+    (allow file-read*
+      (subpath "/System/Library/PrivateFrameworks")
+      (regex #"^/usr/lib/libstdc\+\+\.[^/]*dylib$")
+      (literal plugin-binary-path)
+      (literal app-binary-path)
+      (subpath app-path)))
+
+  (allow signal (target self))
+  (allow sysctl-read)
+  (allow iokit-open (iokit-user-client-class "IOHIDParamUserClient"))
+  (allow file-read*
+      (literal "/etc")
+      (literal "/dev/random")
+      (literal "/dev/urandom")
+      (literal "/usr/share/icu/icudt51l.dat")
+      (subpath "/System/Library/Displays/Overrides")
+      (subpath "/System/Library/CoreServices/CoreTypes.bundle"))
+)SANDBOX_LITERAL";
+
+}  // namespace mozilla
+
+#endif  // mozilla_SandboxPolicyUtility_h
--- a/security/sandbox/mac/moz.build
+++ b/security/sandbox/mac/moz.build
@@ -1,16 +1,19 @@
 # -*- Mode: python; indent-tabs-mode: nil; tab-width: 40 -*-
 # vim: set filetype=python:
 # This Source Code Form is subject to the terms of the Mozilla Public
 # License, v. 2.0. If a copy of the MPL was not distributed with this
 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
 
 EXPORTS.mozilla += [
     'Sandbox.h',
-    'SandboxPolicies.h'
+    'SandboxPolicyContent.h',
+    'SandboxPolicyFlash.h',
+    'SandboxPolicyGMP.h',
+    'SandboxPolicyUtility.h'
 ]
 
 SOURCES += [
     'Sandbox.mm',
 ]
 
 Library('mozsandbox');