5b4b37bde4fa446b6e3752ed401eb3b5f0c6bf53
[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 )
201
202 ;; Security framework
203 (allow mach-lookup
204        (global-name "com.apple.ocspd")
205        (global-name "com.apple.SecurityServer"))
206 (allow file-read* file-write* (home-subpath "/Library/Keychains")) ;; FIXME: This should be removed when <rdar://problem/10479685> is fixed.
207 (allow file-read* file-write* (subpath "/private/var/db/mds/system")) ;; FIXME: This should be removed when <rdar://problem/9538414> is fixed.
208 (allow file-read*
209        (subpath "/Library/Keychains")
210        (subpath "/private/var/db/mds")
211        (literal "/private/var/db/DetachedSignatures")
212        (literal "/Library/Preferences/com.apple.crypto.plist")
213        (literal "/Library/Preferences/com.apple.security.plist")
214        (literal "/Library/Preferences/com.apple.security.common.plist")
215        (literal "/Library/Preferences/com.apple.security.revocation.plist")
216        (home-literal "/Library/Application Support/SyncServices/Local/ClientsWithChanges/com.apple.Keychain")
217        (home-literal "/Library/Preferences/com.apple.security.plist")
218        (home-literal "/Library/Preferences/com.apple.security.revocation.plist"))
219 (allow ipc-posix-shm-read* ipc-posix-shm-write-data
220        (ipc-posix-name "com.apple.AppleDatabaseChanged"))
221
222 ;; CoreFoundation. We don't import com.apple.corefoundation.sb, because it allows unnecessary access to pasteboard.
223 (allow mach-lookup
224     (global-name-regex #"^com.apple.distributed_notifications")                                                       
225     (global-name "com.apple.CoreServices.coreservicesd"))
226 (allow file-read-data
227     (literal "/dev/autofs_nowait")) ; Used by CF to circumvent automount triggers
228 (allow ipc-posix-shm
229     (ipc-posix-name-regex #"^CFPBS:")) ; <rdar://problem/13757475>
230
231 ;; Graphics
232 (system-graphics)
233
234 ;; Networking
235 (system-network)
236 (allow network-outbound
237        ;; Local mDNSResponder for DNS, arbitrary outbound TCP
238        (literal "/private/var/run/mDNSResponder")
239        (remote tcp))
240
241 ;; Needed for NSAttributedString, <rdar://problem/10844321>.
242 (allow file-read*
243        (home-literal "/Library/Preferences/pbs.plist")
244        (home-literal "/Library/Preferences/com.apple.ServicesMenu.Services.plist"))
245 (allow mach-lookup
246        (global-name "com.apple.pbs.fetch_services"))
247
248 ;; FIXME should be removed when <rdar://problem/9347205> + related radar in Safari is fixed
249 (allow mach-lookup
250        (global-name "org.h5l.kcm")
251        (global-name "com.apple.GSSCred")
252        (global-name "com.apple.system.logger")
253        (global-name "com.apple.system.notification_center"))
254 (allow network-outbound
255        (remote udp))
256 (allow file-read*
257         (home-subpath "/Library/Preferences/com.apple.Kerberos.plist")
258         (home-subpath "/Library/Preferences/com.apple.GSS.plist")
259         (home-subpath "/Library/Preferences/edu.mit.Kerberos")
260         (literal "/Library/Preferences/com.apple.Kerberos.plist")
261         (literal "/Library/Preferences/com.apple.GSS.plist")
262         (literal "/Library/Preferences/edu.mit.Kerberos")
263         (literal "/private/etc/krb5.conf")
264         (literal "/private/etc/services")
265         (literal "/private/etc/host")
266         (subpath "/Library/KerberosPlugins/GSSAPI")
267         (subpath "/Library/KerberosPlugins/KerberosFrameworkPlugins"))
268
269 (if (defined? 'vnode-type)
270         (deny file-write-create (vnode-type SYMLINK)))
271
272 ;; FIXME: Should be removed once <rdar://problem/16329087> is fixed.
273 (deny file-write-xattr (xattr "com.apple.quarantine") (with no-log))
274
275 ;; Reserve a namespace for additional protected extended attributes.
276 #if __MAC_OS_X_VERSION_MIN_REQUIRED > 1090
277 (deny file-read-xattr file-write-xattr (xattr-regex #"^com\.apple\.security\.private\."))
278 #else
279 (deny file-read-xattr file-write-xattr (xattr #"^com\.apple\.security\.private\."))
280 #endif
281
282 (deny file-read* file-write* (with no-log)
283        ;; FIXME: Should be removed after <rdar://problem/10463881> is fixed.
284        (home-literal "/Library/Preferences/com.apple.LaunchServices.QuarantineEventsV2")
285        (home-literal "/Library/Preferences/com.apple.LaunchServices.QuarantineEventsV2-journal"))
286
287 ;; Deny access needed for unnecessary NSApplication initialization.
288 ;; FIXME: This can be removed once <rdar://problem/13011633> is fixed.
289 (deny file-read* (with no-log)
290        (home-literal "/Library/Preferences/com.apple.speech.recognition.AppleSpeechRecognition.prefs.plist")
291        (subpath "/Library/InputManagers")
292        (home-subpath "/Library/InputManagers"))
293 (deny mach-lookup (with no-log)
294        (global-name "com.apple.coreservices.appleevents")
295        (global-name "com.apple.pasteboard.1")
296        (global-name "com.apple.speech.recognitionserver"))
297 ;; Also part of unnecessary NSApplication initialization, but we can't block access to these yet, see <rdar://problem/13869765>.
298 (allow file-read*
299        (subpath "/Library/Components")
300        (subpath "/Library/Keyboard Layouts")
301        (subpath "/Library/Input Methods")
302        (home-subpath "/Library/Components")
303        (home-subpath "/Library/Keyboard Layouts")
304        (home-subpath "/Library/Input Methods"))
305
306 ;; AirPlay
307 (allow mach-lookup
308     (global-name "com.apple.coremedia.endpoint.xpc")
309     (global-name "com.apple.coremedia.endpointstream.xpc")
310     (global-name "com.apple.coremedia.endpointplaybacksession.xpc")
311     (global-name "com.apple.coremedia.endpointpicker.xpc"))