[Mac] WebKit processes should have access to com.apple.nesessionmanager.flow-divert...
[WebKit-https.git] / Source / WebKit2 / WebProcess / com.apple.WebProcess.sb.in
1 ; Copyright (C) 2010, 2011, 2012, 2013, 2014 Apple Inc. All rights reserved.
2 ;
3 ; Redistribution and use in source and binary forms, with or without
4 ; modification, are permitted provided that the following conditions
5 ; are met:
6 ; 1. Redistributions of source code must retain the above copyright
7 ;    notice, this list of conditions and the following disclaimer.
8 ; 2. Redistributions in binary form must reproduce the above copyright
9 ;    notice, this list of conditions and the following disclaimer in the
10 ;    documentation and/or other materials provided with the distribution.
11 ;
12 ; THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
13 ; AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
14 ; THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
15 ; PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
16 ; BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
17 ; CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
18 ; SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
19 ; INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
20 ; CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
21 ; ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
22 ; THE POSSIBILITY OF SUCH DAMAGE.
23
24 (version 1)
25 (deny default (with partial-symbolication))
26 (allow system-audit file-read-metadata)
27
28 (import "system.sb")
29
30 ;; Utility functions for home directory relative path filters
31 (define (home-regex home-relative-regex)
32   (regex (string-append "^" (regex-quote (param "HOME_DIR")) home-relative-regex)))
33
34 (define (home-subpath home-relative-subpath)
35   (subpath (string-append (param "HOME_DIR") home-relative-subpath)))
36
37 (define (home-literal home-relative-literal)
38   (literal (string-append (param "HOME_DIR") home-relative-literal)))
39
40 (define (allow-read-directory-and-issue-read-extensions path)
41     (if path
42         (begin
43             (allow file-read* (subpath path))
44             (allow file-issue-extension (require-all (extension-class "com.apple.app-sandbox.read") (subpath path))))))
45
46 ;; Read-only preferences and data
47 (allow file-read*
48        ;; Basic system paths
49        (subpath "/Library/Dictionaries")
50        (subpath "/Library/Fonts")
51        (subpath "/Library/Frameworks")
52        (subpath "/Library/Managed Preferences")
53        (subpath "/Library/Speech/Synthesizers")
54        (regex #"^/private/etc/(hosts|group|passwd)$")
55
56        (literal "/Library/Application Support/CrashReporter/SubmitDiagInfo.domains")
57
58        ;; System and user preferences
59        (literal "/Library/Preferences/.GlobalPreferences.plist")
60        (home-literal "/Library/Preferences/.GlobalPreferences.plist")
61        (home-regex #"/Library/Preferences/ByHost/\.GlobalPreferences\.")
62        (home-regex #"/Library/Preferences/ByHost/com\.apple\.HIToolbox\.")
63        (home-regex #"/Library/Preferences/ByHost/com\.apple\.networkConnect\.")
64        (home-literal "/Library/Preferences/com.apple.ATS.plist")
65        (home-literal "/Library/Preferences/com.apple.CoreGraphics.plist")
66        (home-literal "/Library/Preferences/com.apple.DownloadAssessment.plist")
67        (home-literal "/Library/Preferences/com.apple.HIToolbox.plist")
68        (home-literal "/Library/Preferences/com.apple.LaunchServices.plist")
69        (home-literal "/Library/Preferences/com.apple.MultitouchSupport.plist") ;; FIXME: Remove when <rdar://problem/13011633> is fixed.
70        (home-literal "/Library/Preferences/com.apple.QTKit.plist")
71        (home-literal "/Library/Preferences/com.apple.WebFoundation.plist")
72        (home-literal "/Library/Preferences/com.apple.avfoundation.plist")
73        (home-literal "/Library/Preferences/com.apple.coremedia.plist")
74        (home-literal "/Library/Preferences/com.apple.speech.voice.prefs.plist")
75        (home-literal "/Library/Preferences/com.apple.systemsound.plist")
76        (home-literal "/Library/Preferences/com.apple.universalaccess.plist")
77        (home-regex #"/Library/Preferences/com\.apple\.driver\.(AppleBluetoothMultitouch\.mouse|AppleBluetoothMultitouch\.trackpad|AppleHIDMouse)\.plist$")
78        (home-literal "/.CFUserTextEncoding")
79
80        ;; FIXME: This should be removed when <rdar://problem/8957845> is fixed.
81        (home-subpath "/Library/Fonts")
82
83        ;; FIXME: These should be removed when <rdar://problem/9217757> is fixed.
84        (home-subpath "/Library/Audio/Plug-Ins/Components")
85        (home-subpath "/Library/Preferences/QuickTime Preferences")
86        (home-literal "/Library/Caches/com.apple.coreaudio.components.plist")
87        (subpath "/Library/Audio/Plug-Ins/Components")
88        (subpath "/Library/Audio/Plug-Ins/HAL")
89        (subpath "/Library/Video/Plug-Ins")
90        (subpath "/Library/QuickTime")
91
92        (home-subpath "/Library/Dictionaries"))
93
94 ;; On-disk WebKit2 framework location, to account for debug installations outside of /System/Library/Frameworks,
95 ;; and to allow issuing extensions.
96 (allow-read-directory-and-issue-read-extensions (param "WEBKIT2_FRAMEWORK_DIR"))
97
98 ;; Allow issuing extensions to system libraries that the Network process can already read.
99 ;; This is to avoid warnings attempting to create extensions for these resources.
100 (allow-read-directory-and-issue-read-extensions "/System/Library/PrivateFrameworks/WebInspectorUI.framework")
101
102 ;; Sandbox extensions
103 (define (apply-read-and-issue-extension op path-filter)
104     (op file-read* path-filter)
105     (op file-issue-extension (require-all (extension-class "com.apple.app-sandbox.read") path-filter)))
106 (define (apply-write-and-issue-extension op path-filter)
107     (op file-write* path-filter)
108     (op file-issue-extension (require-all (extension-class "com.apple.app-sandbox.read-write") path-filter)))
109 (define (read-only-and-issue-extensions path-filter)
110     (apply-read-and-issue-extension allow path-filter))
111 (define (read-write-and-issue-extensions path-filter)
112     (apply-read-and-issue-extension allow path-filter)
113     (apply-write-and-issue-extension allow path-filter))
114 (read-only-and-issue-extensions (extension "com.apple.app-sandbox.read"))
115 (read-write-and-issue-extensions (extension "com.apple.app-sandbox.read-write"))
116 (allow mach-lookup (extension "com.apple.app-sandbox.mach")) ;; FIXME: Should be removed when <rdar://problem/13066206> is fixed.
117
118 ;; Allow the OpenGL Profiler to attach.
119 (if (defined? 'mach-register)
120     (allow mach-register (global-name-regex #"^_oglprof_attach_<[0-9]+>$")))
121
122 ;; MediaAccessibility
123 (allow file-read* (home-literal "/Library/Preferences/com.apple.mediaaccessibility.plist"))
124 (allow file-read* file-write* (home-literal "/Library/Preferences/com.apple.mediaaccessibility.public.plist"))
125
126 (if (positive? (string-length (param "DARWIN_USER_CACHE_DIR")))
127     (allow file* (subpath (param "DARWIN_USER_CACHE_DIR"))))
128
129 (if (positive? (string-length (param "DARWIN_USER_TEMP_DIR")))
130     (allow file* (subpath (param "DARWIN_USER_TEMP_DIR"))))
131
132 ;; IOKit user clients
133 (allow iokit-open
134        (iokit-user-client-class "AppleUpstreamUserClient")
135        (iokit-user-client-class "IOHIDParamUserClient")
136        (iokit-user-client-class "RootDomainUserClient")
137        (iokit-user-client-class "IOAudioControlUserClient")
138        (iokit-user-client-class "IOAudioEngineUserClient"))
139
140 ;; cookied.
141 ;; FIXME: Update for <rdar://problem/13642852>.
142 (allow ipc-posix-shm-read-data
143     (ipc-posix-name "FNetwork.defaultStorageSession")
144     (ipc-posix-name-regex #"\.PrivateBrowsing-")
145     (ipc-posix-name-regex #"^WebKit Test-"))
146
147 ;; ColorSync
148 ;; FIXME: Remove names with underscores when possible (see <rdar://problem/13072721>).
149 (allow ipc-posix-shm*
150     (ipc-posix-name "_CS_GSHMEMLOCK")
151     (ipc-posix-name "_CS_DSHMEMLOCK")
152     (ipc-posix-name "_CSGRAYPROFILE")
153     (ipc-posix-name "_CSRGBPROFILE")
154     (ipc-posix-name "_CSGENGPROFILE")
155     (ipc-posix-name "_CSGENRPROFILE")
156     (ipc-posix-name "com.apple.ColorSync.Gen.lock")
157     (ipc-posix-name "com.apple.ColorSync.Disp.lock")
158     (ipc-posix-name "com.apple.ColorSync.Gray2.2")
159     (ipc-posix-name "com.apple.ColorSync.sRGB")
160     (ipc-posix-name "com.apple.ColorSync.GenGray")
161     (ipc-posix-name "com.apple.ColorSync.GenRGB"))
162
163 ;; Audio
164 (allow ipc-posix-shm-read* ipc-posix-shm-write-data
165     (ipc-posix-name-regex #"^AudioIO"))
166
167 ;; Remote Web Inspector
168 (allow mach-lookup
169        (global-name "com.apple.webinspector"))
170
171 ;; Various services required by AppKit and other frameworks
172 (allow mach-lookup
173        (global-name "com.apple.DiskArbitration.diskarbitrationd")
174        (global-name "com.apple.FileCoordination")
175        (global-name "com.apple.FontObjectsServer")
176        (global-name "com.apple.FontServer")
177        (global-name "com.apple.SystemConfiguration.configd")
178        (global-name "com.apple.SystemConfiguration.PPPController")
179        (global-name "com.apple.audio.SystemSoundServer-OSX")
180        (global-name "com.apple.audio.VDCAssistant")
181        (global-name "com.apple.audio.audiohald")
182        (global-name "com.apple.audio.coreaudiod")
183        (global-name "com.apple.awdd")
184        (global-name "com.apple.cookied")
185        (global-name "com.apple.dock.server")
186        (global-name "com.apple.system.opendirectoryd.api")
187        (global-name "com.apple.tccd")
188        (global-name "com.apple.tccd.system")
189        (global-name "com.apple.window_proxies")
190        (global-name "com.apple.windowserver.active")
191        (global-name "com.apple.cfnetwork.AuthBrokerAgent")
192        (global-name "com.apple.PowerManagement.control")
193        (global-name "com.apple.speech.speechsynthesisd")
194        (global-name "com.apple.speech.synthesis.console")
195        (global-name "com.apple.coreservices.launchservicesd")
196 #if __MAC_OS_X_VERSION_MIN_REQUIRED >= 101000
197        (global-name "com.apple.iconservices")
198        (global-name "com.apple.iconservices.store")
199 #endif
200 #if __MAC_OS_X_VERSION_MIN_REQUIRED >= 101100
201        (global-name "com.apple.nesessionmanager.flow-divert-token")
202 #endif
203 )
204
205 ;; Security framework
206 (allow mach-lookup
207        (global-name "com.apple.ocspd")
208        (global-name "com.apple.SecurityServer"))
209 (allow file-read* file-write* (home-subpath "/Library/Keychains")) ;; FIXME: This should be removed when <rdar://problem/10479685> is fixed.
210 (allow file-read* file-write* (subpath "/private/var/db/mds/system")) ;; FIXME: This should be removed when <rdar://problem/9538414> is fixed.
211 (allow file-read*
212        (subpath "/Library/Keychains")
213        (subpath "/private/var/db/mds")
214        (literal "/private/var/db/DetachedSignatures")
215        (literal "/Library/Preferences/com.apple.crypto.plist")
216        (literal "/Library/Preferences/com.apple.security.plist")
217        (literal "/Library/Preferences/com.apple.security.common.plist")
218        (literal "/Library/Preferences/com.apple.security.revocation.plist")
219        (home-literal "/Library/Application Support/SyncServices/Local/ClientsWithChanges/com.apple.Keychain")
220        (home-literal "/Library/Preferences/com.apple.security.plist")
221        (home-literal "/Library/Preferences/com.apple.security.revocation.plist"))
222 (allow ipc-posix-shm-read* ipc-posix-shm-write-data
223        (ipc-posix-name "com.apple.AppleDatabaseChanged"))
224
225 ;; CoreFoundation. We don't import com.apple.corefoundation.sb, because it allows unnecessary access to pasteboard.
226 (allow mach-lookup
227     (global-name-regex #"^com.apple.distributed_notifications")                                                       
228     (global-name "com.apple.CoreServices.coreservicesd"))
229 (allow file-read-data
230     (literal "/dev/autofs_nowait")) ; Used by CF to circumvent automount triggers
231 (allow ipc-posix-shm
232     (ipc-posix-name-regex #"^CFPBS:")) ; <rdar://problem/13757475>
233
234 ;; Graphics
235 (system-graphics)
236
237 ;; Networking
238 (system-network)
239 (allow network-outbound
240        ;; Local mDNSResponder for DNS, arbitrary outbound TCP
241        (literal "/private/var/run/mDNSResponder")
242        (remote tcp))
243
244 ;; Needed for NSAttributedString, <rdar://problem/10844321>.
245 (allow file-read*
246        (home-literal "/Library/Preferences/pbs.plist")
247        (home-literal "/Library/Preferences/com.apple.ServicesMenu.Services.plist"))
248 (allow mach-lookup
249        (global-name "com.apple.pbs.fetch_services"))
250
251 ;; FIXME should be removed when <rdar://problem/9347205> + related radar in Safari is fixed
252 (allow mach-lookup
253        (global-name "org.h5l.kcm")
254        (global-name "com.apple.GSSCred")
255        (global-name "com.apple.system.logger")
256        (global-name "com.apple.system.notification_center"))
257 (allow network-outbound
258        (remote udp))
259 (allow file-read*
260         (home-subpath "/Library/Preferences/com.apple.Kerberos.plist")
261         (home-subpath "/Library/Preferences/com.apple.GSS.plist")
262         (home-subpath "/Library/Preferences/edu.mit.Kerberos")
263         (literal "/Library/Preferences/com.apple.Kerberos.plist")
264         (literal "/Library/Preferences/com.apple.GSS.plist")
265         (literal "/Library/Preferences/edu.mit.Kerberos")
266         (literal "/private/etc/krb5.conf")
267         (literal "/private/etc/services")
268         (literal "/private/etc/host")
269         (subpath "/Library/KerberosPlugins/GSSAPI")
270         (subpath "/Library/KerberosPlugins/KerberosFrameworkPlugins"))
271
272 (if (defined? 'vnode-type)
273         (deny file-write-create (vnode-type SYMLINK)))
274
275 ;; FIXME: Should be removed once <rdar://problem/16329087> is fixed.
276 (deny file-write-xattr (xattr "com.apple.quarantine") (with no-log))
277
278 ;; Reserve a namespace for additional protected extended attributes.
279 #if __MAC_OS_X_VERSION_MIN_REQUIRED > 1090
280 (deny file-read-xattr file-write-xattr (xattr-regex #"^com\.apple\.security\.private\."))
281 #else
282 (deny file-read-xattr file-write-xattr (xattr #"^com\.apple\.security\.private\."))
283 #endif
284
285 (deny file-read* file-write* (with no-log)
286        ;; FIXME: Should be removed after <rdar://problem/10463881> is fixed.
287        (home-literal "/Library/Preferences/com.apple.LaunchServices.QuarantineEventsV2")
288        (home-literal "/Library/Preferences/com.apple.LaunchServices.QuarantineEventsV2-journal"))
289
290 ;; Deny access needed for unnecessary NSApplication initialization.
291 ;; FIXME: This can be removed once <rdar://problem/13011633> is fixed.
292 (deny file-read* (with no-log)
293        (home-literal "/Library/Preferences/com.apple.speech.recognition.AppleSpeechRecognition.prefs.plist")
294        (subpath "/Library/InputManagers")
295        (home-subpath "/Library/InputManagers"))
296 (deny mach-lookup (with no-log)
297        (global-name "com.apple.coreservices.appleevents")
298        (global-name "com.apple.pasteboard.1")
299        (global-name "com.apple.speech.recognitionserver"))
300 ;; Also part of unnecessary NSApplication initialization, but we can't block access to these yet, see <rdar://problem/13869765>.
301 (allow file-read*
302        (subpath "/Library/Components")
303        (subpath "/Library/Keyboard Layouts")
304        (subpath "/Library/Input Methods")
305        (home-subpath "/Library/Components")
306        (home-subpath "/Library/Keyboard Layouts")
307        (home-subpath "/Library/Input Methods"))
308
309 ;; AirPlay
310 (allow mach-lookup
311     (global-name "com.apple.coremedia.endpoint.xpc")
312     (global-name "com.apple.coremedia.endpointstream.xpc")
313     (global-name "com.apple.coremedia.endpointplaybacksession.xpc")
314     (global-name "com.apple.coremedia.endpointpicker.xpc"))