Remove code for Mac Lion
[WebKit-https.git] / Source / WebKit2 / WebProcess / com.apple.WebProcess.sb.in
1 (version 1)
2 (deny default (with partial-symbolication))
3 (allow system-audit file-read-metadata)
4
5 (import "system.sb")
6
7 ;; Utility functions for home directory relative path filters
8 (define (home-regex home-relative-regex)
9   (regex (string-append "^" (regex-quote (param "HOME_DIR")) home-relative-regex)))
10
11 (define (home-subpath home-relative-subpath)
12   (subpath (string-append (param "HOME_DIR") home-relative-subpath)))
13
14 (define (home-literal home-relative-literal)
15   (literal (string-append (param "HOME_DIR") home-relative-literal)))
16
17 (define (allow-read-directory-and-issue-read-extensions path)
18     (if path
19         (begin
20             (allow file-read* (subpath path))
21             (allow file-issue-extension (require-all (extension-class "com.apple.app-sandbox.read") (subpath path))))))
22
23 ;; Read-only preferences and data
24 (allow file-read*
25        ;; Basic system paths
26        (subpath "/Library/Dictionaries")
27        (subpath "/Library/Fonts")
28        (subpath "/Library/Frameworks")
29        (subpath "/Library/Managed Preferences")
30        (subpath "/Library/Speech/Synthesizers")
31        (regex #"^/private/etc/(hosts|group|passwd)$")
32
33        ;; System and user preferences
34        (literal "/Library/Preferences/.GlobalPreferences.plist")
35        (home-literal "/Library/Preferences/.GlobalPreferences.plist")
36        (home-regex #"/Library/Preferences/ByHost/\.GlobalPreferences\.")
37        (home-regex #"/Library/Preferences/ByHost/com\.apple\.HIToolbox\.")
38        (home-regex #"/Library/Preferences/ByHost/com\.apple\.networkConnect\.")
39        (home-literal "/Library/Preferences/com.apple.ATS.plist")
40        (home-literal "/Library/Preferences/com.apple.DownloadAssessment.plist")
41        (home-literal "/Library/Preferences/com.apple.HIToolbox.plist")
42        (home-literal "/Library/Preferences/com.apple.LaunchServices.plist")
43        (home-literal "/Library/Preferences/com.apple.MultitouchSupport.plist") ;; FIXME: Remove when <rdar://problem/13011633> is fixed.
44        (home-literal "/Library/Preferences/com.apple.QTKit.plist")
45        (home-literal "/Library/Preferences/com.apple.WebFoundation.plist")
46        (home-literal "/Library/Preferences/com.apple.avfoundation.plist")
47        (home-literal "/Library/Preferences/com.apple.coremedia.plist")
48        (home-literal "/Library/Preferences/com.apple.speech.voice.prefs.plist")
49        (home-regex #"/Library/Preferences/com\.apple\.driver\.(AppleBluetoothMultitouch\.mouse|AppleBluetoothMultitouch\.trackpad|AppleHIDMouse)\.plist$")
50        (home-literal "/.CFUserTextEncoding")
51
52        ;; FIXME: This should be removed when <rdar://problem/8957845> is fixed.
53        (home-subpath "/Library/Fonts")
54
55        ;; FIXME: These should be removed when <rdar://problem/9217757> is fixed.
56        (home-subpath "/Library/Audio/Plug-Ins/Components")
57        (home-subpath "/Library/Preferences/QuickTime Preferences")
58        (home-literal "/Library/Caches/com.apple.coreaudio.components.plist")
59        (subpath "/Library/Audio/Plug-Ins/Components")
60        (subpath "/Library/Audio/Plug-Ins/HAL")
61        (subpath "/Library/Video/Plug-Ins")
62        (subpath "/Library/QuickTime")
63
64        (home-subpath "/Library/Dictionaries"))
65
66 ;; On-disk WebKit2 framework location, to account for debug installations outside of /System/Library/Frameworks,
67 ;; and to allow issuing extensions.
68 (allow-read-directory-and-issue-read-extensions (param "WEBKIT2_FRAMEWORK_DIR"))
69
70 ;; Sandbox extensions
71 (define (apply-read-and-issue-extension op path-filter)
72     (op file-read* path-filter)
73     (op file-issue-extension (require-all (extension-class "com.apple.app-sandbox.read") path-filter)))
74 (define (apply-write-and-issue-extension op path-filter)
75     (op file-write* path-filter)
76     (op file-issue-extension (require-all (extension-class "com.apple.app-sandbox.read-write") path-filter)))
77 (define (read-only-and-issue-extensions path-filter)
78     (apply-read-and-issue-extension allow path-filter))
79 (define (read-write-and-issue-extensions path-filter)
80     (apply-read-and-issue-extension allow path-filter)
81     (apply-write-and-issue-extension allow path-filter))
82 (read-only-and-issue-extensions (extension "com.apple.app-sandbox.read"))
83 (read-write-and-issue-extensions (extension "com.apple.app-sandbox.read-write"))
84 (allow mach-lookup (extension "com.apple.app-sandbox.mach")) ;; FIXME: Should be removed when <rdar://problem/13066206> is fixed.
85
86 ;; MediaAccessibility
87 #if __MAC_OS_X_VERSION_MIN_REQUIRED >= 1090
88 (allow file-read* (home-literal "/Library/Preferences/com.apple.mediaaccessibility.plist"))
89 (allow file-read* file-write* (home-literal "/Library/Preferences/com.apple.mediaaccessibility.public.plist"))
90 #endif
91
92 #if __MAC_OS_X_VERSION_MIN_REQUIRED >= 1080
93 (if (positive? (string-length (param "DARWIN_USER_CACHE_DIR")))
94     (allow file* (subpath (param "DARWIN_USER_CACHE_DIR"))))
95 #else
96 (if (positive? (string-length (param "DARWIN_USER_CACHE_DIR")))
97     (allow file* (subpath (string-append (param "DARWIN_USER_CACHE_DIR") "/mds"))))
98 #endif
99
100 (if (positive? (string-length (param "DARWIN_USER_TEMP_DIR")))
101     (allow file* (subpath (param "DARWIN_USER_TEMP_DIR"))))
102
103 ;; IOKit user clients
104 (allow iokit-open
105        (iokit-user-client-class "AppleUpstreamUserClient")
106        (iokit-user-client-class "IOHIDParamUserClient")
107        (iokit-user-client-class "RootDomainUserClient")
108        (iokit-user-client-class "IOAudioControlUserClient")
109        (iokit-user-client-class "IOAudioEngineUserClient"))
110
111 #if __MAC_OS_X_VERSION_MIN_REQUIRED >= 1080
112
113 ;; cookied.
114 ;; FIXME: Update for <rdar://problem/13642852>.
115 (allow ipc-posix-shm-read-data
116     (ipc-posix-name "FNetwork.defaultStorageSession")
117     (ipc-posix-name-regex #"\.PrivateBrowsing-")
118     (ipc-posix-name-regex #"^Private WebKit Session-"))
119
120 ;; ColorSync
121 ;; FIXME: Remove names with underscores when possible (see <rdar://problem/13072721>).
122 (allow ipc-posix-shm*
123     (ipc-posix-name "_CS_GSHMEMLOCK")
124     (ipc-posix-name "_CS_DSHMEMLOCK")
125     (ipc-posix-name "_CSGRAYPROFILE")
126     (ipc-posix-name "_CSRGBPROFILE")
127     (ipc-posix-name "_CSGENGPROFILE")
128     (ipc-posix-name "_CSGENRPROFILE")
129     (ipc-posix-name "com.apple.ColorSync.Gen.lock")
130     (ipc-posix-name "com.apple.ColorSync.Disp.lock")
131     (ipc-posix-name "com.apple.ColorSync.Gray2.2")
132     (ipc-posix-name "com.apple.ColorSync.sRGB")
133     (ipc-posix-name "com.apple.ColorSync.GenGray")
134     (ipc-posix-name "com.apple.ColorSync.GenRGB"))
135
136 ;; Audio
137 (allow ipc-posix-shm-read* ipc-posix-shm-write-data
138     (ipc-posix-name-regex #"^AudioIO"))
139
140 #endif
141
142 ;; Various services required by AppKit and other frameworks
143 (allow mach-lookup
144        (global-name "com.apple.DiskArbitration.diskarbitrationd")
145        (global-name "com.apple.FileCoordination")
146        (global-name "com.apple.FontObjectsServer")
147        (global-name "com.apple.FontServer")
148        (global-name "com.apple.SystemConfiguration.configd")
149        (global-name "com.apple.SystemConfiguration.PPPController")
150        (global-name "com.apple.audio.VDCAssistant")
151        (global-name "com.apple.audio.audiohald")
152        (global-name "com.apple.audio.coreaudiod")
153        (global-name "com.apple.cookied")
154        (global-name "com.apple.dock.server")
155        (global-name "com.apple.system.opendirectoryd.api")
156        (global-name "com.apple.tccd")
157        (global-name "com.apple.tccd.system")
158        (global-name "com.apple.window_proxies")
159        (global-name "com.apple.windowserver.active")
160        (global-name "com.apple.cfnetwork.AuthBrokerAgent")
161        (global-name "com.apple.PowerManagement.control")
162        (global-name "com.apple.speech.speechsynthesisd")
163        (global-name "com.apple.speech.synthesis.console")
164
165 #if __MAC_OS_X_VERSION_MIN_REQUIRED >= 1090
166        (global-name "com.apple.coreservices.launchservicesd")
167 #endif
168 )
169
170 ;; Security framework
171 (allow mach-lookup
172        (global-name "com.apple.ocspd")
173        (global-name "com.apple.SecurityServer"))
174 (allow file-read* file-write* (home-subpath "/Library/Keychains")) ;; FIXME: This should be removed when <rdar://problem/10479685> is fixed.
175 (allow file-read* file-write* (subpath "/private/var/db/mds/system")) ;; FIXME: This should be removed when <rdar://problem/9538414> is fixed.
176 (allow file-read*
177        (subpath "/Library/Keychains")
178        (subpath "/private/var/db/mds")
179        (literal "/private/var/db/DetachedSignatures")
180        (literal "/Library/Preferences/com.apple.crypto.plist")
181        (literal "/Library/Preferences/com.apple.security.plist")
182        (literal "/Library/Preferences/com.apple.security.common.plist")
183        (literal "/Library/Preferences/com.apple.security.revocation.plist")
184        (home-literal "/Library/Application Support/SyncServices/Local/ClientsWithChanges/com.apple.Keychain")
185        (home-literal "/Library/Preferences/com.apple.security.plist")
186        (home-literal "/Library/Preferences/com.apple.security.revocation.plist"))
187 #if __MAC_OS_X_VERSION_MIN_REQUIRED >= 1080
188 (allow ipc-posix-shm-read* ipc-posix-shm-write-data
189        (ipc-posix-name "com.apple.AppleDatabaseChanged"))
190 #endif
191
192 ;; CoreFoundation. We don't import com.apple.corefoundation.sb, because it allows unnecessary access to pasteboard.
193 (allow mach-lookup
194     (global-name-regex #"^com.apple.distributed_notifications")                                                       
195     (global-name "com.apple.CoreServices.coreservicesd"))
196 (allow file-read-data
197     (literal "/dev/autofs_nowait")) ; Used by CF to circumvent automount triggers
198 (allow ipc-posix-shm
199     (ipc-posix-name-regex #"^CFPBS:")) ; <rdar://problem/13757475>
200
201 ;; Graphics
202 (system-graphics)
203
204 ;; Networking
205 (system-network)
206 (allow network-outbound
207        ;; Local mDNSResponder for DNS, arbitrary outbound TCP
208        (literal "/private/var/run/mDNSResponder")
209        (remote tcp))
210
211 ;; Needed for NSAttributedString, <rdar://problem/10844321>.
212 (allow file-read*
213        (home-literal "/Library/Preferences/pbs.plist")
214        (home-literal "/Library/Preferences/com.apple.ServicesMenu.Services.plist"))
215 (allow mach-lookup
216        (global-name "com.apple.pbs.fetch_services"))
217
218 ;; FIXME should be removed when <rdar://problem/9347205> + related radar in Safari is fixed
219 (allow mach-lookup
220        (global-name "org.h5l.kcm")
221        (global-name "com.apple.system.logger")
222        (global-name "com.apple.system.notification_center"))
223 (allow network-outbound
224        (remote udp))
225 (allow file-read*
226         (home-subpath "/Library/Preferences/com.apple.Kerberos.plist")
227         (home-subpath "/Library/Preferences/com.apple.GSS.plist")
228         (home-subpath "/Library/Preferences/edu.mit.Kerberos")
229         (literal "/Library/Preferences/com.apple.Kerberos.plist")
230         (literal "/Library/Preferences/com.apple.GSS.plist")
231         (literal "/Library/Preferences/edu.mit.Kerberos")
232         (literal "/private/etc/krb5.conf")
233         (literal "/private/etc/services")
234         (literal "/private/etc/host"))
235
236 (if (defined? 'vnode-type)
237         (deny file-write-create (vnode-type SYMLINK)))
238
239 (deny file-read* file-write* (with no-log)
240 #if __MAC_OS_X_VERSION_MIN_REQUIRED <= 1080
241        (home-literal "/Library/Caches/Cache.db") ;; <rdar://problem/9422957>
242 #endif
243 #if __MAC_OS_X_VERSION_MIN_REQUIRED == 1080
244        (home-subpath "/Library/Caches/com.apple.WebProcess") ;; <rdar://problem/12656814>
245 #endif
246
247        ;; FIXME: Should be removed after <rdar://problem/10463881> is fixed.
248        (home-literal "/Library/Preferences/com.apple.LaunchServices.QuarantineEventsV2")
249        (home-literal "/Library/Preferences/com.apple.LaunchServices.QuarantineEventsV2-journal"))
250
251 ;; Deny access needed for unnecessary NSApplication initialization.
252 ;; FIXME: This can be removed once <rdar://problem/13011633> is fixed.
253 (deny file-read* (with no-log)
254        (home-literal "/Library/Preferences/com.apple.speech.recognition.AppleSpeechRecognition.prefs.plist")
255        (subpath "/Library/InputManagers")
256        (home-subpath "/Library/InputManagers"))
257 (deny mach-lookup (with no-log)
258        (global-name "com.apple.coreservices.appleevents")
259        (global-name "com.apple.pasteboard.1")
260        (global-name "com.apple.speech.recognitionserver"))
261 ;; Also part of unnecessary NSApplication initialization, but we can't block access to these yet, see <rdar://problem/13869765>.
262 (allow file-read*
263        (subpath "/Library/Components")
264        (subpath "/Library/Keyboard Layouts")
265        (subpath "/Library/Input Methods")
266        (home-subpath "/Library/Components")
267        (home-subpath "/Library/Keyboard Layouts")
268        (home-subpath "/Library/Input Methods"))