REGRESSION(r225858): Sandbox violations due to blocked access to Spotlight search...
[WebKit-https.git] / Source / WebKit / Resources / SandboxProfiles / ios / com.apple.WebKit.WebContent.sb
1 ; Copyright (C) 2010-2018 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 (deny mach-lookup (xpc-service-name-prefix ""))
29
30 (import "common.sb")
31
32 ;;;
33 ;;; The following rules were originally contained in 'UIKit-apps.sb'. We are duplicating them here so we can
34 ;;; remove unneeded sandbox extensions.
35 ;;;
36
37 ;;; <rdar://problem/29959382> Allow UIKit apps access to com.apple.TextInput.preferences mach service
38 (allow mach-lookup
39     (global-name "com.apple.TextInput.preferences"))
40
41 (allow mach-lookup
42     (xpc-service-name "com.apple.siri.context.service"))
43
44 (allow mach-lookup
45     (global-name "com.apple.frontboard.systemappservices")                 ; -[UIViewServiceInterface _createProcessAssertion] -> SBSProcessIDForDisplayIdentifier()
46     (global-name-regex #"^com\.apple\.uikit\.viewservice\..+"))
47
48 ;; Any app could use ubiquity.
49 (ubiquity-client)
50
51 ;; Any app can play audio & movies.
52 (play-audio)
53 (play-media)
54
55 (url-translation)
56
57 ;; For <rdar://problem/20812377> All applications need to be able to access the com.apple.UIKit.KeyboardManagement running in backboardd
58 ;; renamed in <rdar://problem/20909914> Rename com.apple.UIKit.KeyboardManagement
59 (allow mach-lookup
60     (global-name "com.apple.UIKit.KeyboardManagement")
61     (global-name "com.apple.UIKit.KeyboardManagement.hosted"))
62
63 ;; TextInput framework
64 (allow mach-lookup
65     (global-name "com.apple.TextInput")
66     (global-name "com.apple.TextInput.emoji")
67     (global-name "com.apple.TextInput.image-cache-server")
68     (global-name "com.apple.TextInput.lexicon-server")
69     (global-name "com.apple.TextInput.rdt")
70     (global-name "com.apple.TextInput.shortcuts"))
71 (mobile-preferences-read "com.apple.da")
72
73 ;; Various Accessibility services.
74 (allow mach-lookup
75     (xpc-service-name "com.apple.accessibility.AccessibilityUIServer")) ; Needed for Zoom focus updates
76
77 ;; ZoomTouch
78 ;; <rdar://problem/11823957>
79 (allow mach-lookup
80     (global-name "com.apple.accessibility.AXBackBoardServer"))
81
82 ;; Speak Selection & VoiceOver
83 ;; <rdar://problem/12030530> AX: Sandbox violation with changing Language while VO is on
84 ;; and <rdar://problem/13071747>
85 (mobile-preferences-read
86     "com.apple.SpeakSelection") ; Needed for WebSpeech
87
88 (allow mach-lookup
89     (global-name "com.apple.audio.AudioComponentPrefs")
90     (global-name "com.apple.audio.AudioComponentRegistrar")
91     (global-name "com.apple.audio.AudioQueueServer"))
92
93 (allow mach-register
94     (local-name "com.apple.iphone.axserver")) ; Needed for Application Accessibility
95
96 ;; <rdar://problem/14555119> Access to high quality speech voices
97 ;; Needed for WebSpeech
98 (allow file-read*
99     (home-subpath "/Library/VoiceServices/Assets")
100     (home-subpath "/Library/Assets/com_apple_MobileAsset_VoiceServicesVocalizerVoice"))
101
102 ;; HearingAidSupport
103 (allow mach-lookup
104     (xpc-service-name "com.apple.accessibility.heard"))
105
106 ;; MediaAccessibility (captions)
107 ;; <rdar://problem/12801477>
108 (mobile-preferences-read "com.apple.mediaaccessibility")
109 (allow mach-lookup (global-name "com.apple.accessibility.mediaaccessibilityd"))
110
111 ;; Permit reading assets via MobileAsset framework.
112 (asset-access 'with-media-playback)
113
114 ;; allow 3rd party applications to access nsurlstoraged's top level domain data cache
115 (allow-well-known-system-group-container-literal-read
116     "/systemgroup.com.apple.nsurlstoragedresources/Library/dafsaData.bin")
117
118 ;; Access the keyboards
119 (allow file-read*
120     (home-subpath "/Library/Caches/com.apple.keyboards"))
121
122 ;; NSExtension helper for supplying information not provided by PlugInKit
123 (allow mach-lookup
124     (xpc-service-name "com.apple.uifoundation-bundle-helper"))
125
126 ;; <rdar://problem/19525887>
127 (allow mach-lookup (xpc-service-name-regex #"\.apple-extension-service$"))
128 ;; <rdar://problem/31252371>
129 (allow mach-lookup (xpc-service-name-regex #"\.viewservice$"))
130
131 (mobile-preferences-read
132     "com.apple.EmojiPreferences"
133     ; <rdar://problem/8477596> com.apple.InputModePreferences
134     "com.apple.InputModePreferences"
135     ; <rdar://problem/8206632> Weather(1038) deny file-read-data ~/Library/Preferences/com.apple.keyboard.plist
136     "com.apple.keyboard"
137     ; <rdar://problem/9384085>
138     "com.apple.Preferences"
139     "com.apple.lookup.shared" ; Needed for DataDetector (Spotlight) support
140 )
141
142 ;; <rdar://problem/12985925> Need read access to /var/mobile/Library/Fonts to all apps
143 (allow file-read*
144     (home-subpath "/Library/Fonts"))
145
146 ;; <rdar://problem/7344719&26323449> LaunchServices app icons
147 (allow file-read*
148     (well-known-system-group-container-subpath "/systemgroup.com.apple.lsd.iconscache"))
149 (allow mach-lookup
150     (xpc-service-name "com.apple.lsdiconservice"))
151
152 ;; Common mach services needed by UIKit.
153 (allow mach-lookup
154     (global-name "com.apple.CARenderServer")
155     (global-name "com.apple.KeyboardServices.TextReplacementService")
156     (global-name "com.apple.assertiond.applicationstateconnection")
157     (global-name "com.apple.assertiond.expiration")
158     (global-name "com.apple.assertiond.processinfoservice")
159     (global-name "com.apple.audio.SystemSoundServer-iOS")
160     (global-name "com.apple.backboard.TouchDeliveryPolicyServer")
161     (global-name "com.apple.backboard.animation-fence-arbiter")
162     (global-name "com.apple.backboard.display.services")
163     (global-name "com.apple.backboard.hid.focus")
164     (global-name "com.apple.backboard.hid.services")
165     (global-name "com.apple.iohideventsystem")
166     (global-name "com.apple.iphone.axserver-systemwide")
167     (global-name "com.apple.frontboard.workspace")
168     (global-name "com.apple.frontboard.systemappservices"))
169
170 (allow-preferences-common)
171
172 ;; CoreMotion
173 (mobile-preferences-read "com.apple.CoreMotion")
174
175 ;; CoreMotion’s deviceMotion API
176 (with-filter
177     (require-any
178         (iokit-registry-entry-class "AppleOscarNub")
179         (iokit-registry-entry-class "AppleSPUHIDInterface"))
180     (allow iokit-get-properties
181         (iokit-property "gyro-interrupt-calibration")))
182 (with-filter
183     (iokit-registry-entry-class "IOHIDEventServiceFastPathUserClient")
184     (allow iokit-open)
185     (allow iokit-get-properties iokit-set-properties
186         (iokit-property "interval"
187                         "mode"
188                         "QueueSize"
189                         "useMag"))
190     (allow iokit-get-properties
191         (iokit-property "client")))
192
193 ;; Common preferences read by UIKit.
194 (mobile-preferences-read "com.apple.Accessibility"
195     "com.apple.UIKit"
196     "com.apple.WebUI"
197     "com.apple.airplay"
198     "com.apple.avkit"
199     "com.apple.coreanimation"
200     "com.apple.mt"
201     "com.apple.preferences.sounds")
202
203 ;; Silence sandbox violations from apps trying to create the empty plist if it doesn't exist.
204 ;; <rdar://problem/13796537>
205 (deny file-write-create
206     (home-prefix "/Library/Preferences/com.apple.UIKit.plist")
207     (with no-report))
208
209 ;; <rdar://problem/10809394>
210 (deny file-write-create
211     (home-prefix "/Library/Preferences/com.apple.Accessibility.plist")
212     (with no-report))
213
214 ;; <rdar://problem/9404009>
215 (mobile-preferences-read "kCFPreferencesAnyApplication")
216
217 ;; <rdar://problem/10266866>
218 (marco-logging-client)
219
220 ;; <rdar://problem/12250145>
221 (mobile-preferences-read "com.apple.mediaaccessibility")
222
223 ; Dictionary Services used by UITextFields.
224 ; <rdar://problem/9386926>
225 (allow-create-directory
226     (home-literal "/Library/Caches/com.apple.DictionaryServices"))
227
228 (allow-network-common)
229
230 ; <rdar://problem/8548856> Sub-TLF: Sandbox change for apps for read-only access to the dictionary directory/data
231 (allow file-read*
232     ; XXX - /Library ought to be allowed in all UI profiles but isn't (CF, MobileSafari)
233     (subpath "/Library/Dictionaries")
234     (home-subpath "/Library/Dictionaries"))
235
236 ; <rdar://problem/8440231>
237 (allow file-read*
238     (home-literal "/Library/Caches/DateFormats.plist"))
239 ; Silently deny writes when CFData attempts to write to the cache directory.
240 (deny file-write*
241     (home-literal "/Library/Caches/DateFormats.plist")
242     (with no-log))
243
244 ; UIKit-required IOKit nodes.
245 (allow iokit-open
246     (iokit-user-client-class "AppleJPEGDriverUserClient")
247     (iokit-user-client-class "IOSurfaceAcceleratorClient")
248     (iokit-user-client-class "IOSurfaceSendRight")
249     ;; Requires by UIView -> UITextMagnifierRenderer -> UIWindow
250     (iokit-user-client-class "IOSurfaceRootUserClient"))
251
252 ;; <rdar://problem/12675621>
253 (allow iokit-open
254     (iokit-user-client-class "IOHIDLibUserClient"))
255
256 (framebuffer-access)
257
258 ;; <rdar://problem/7822790>
259 (mobile-keybag-access)
260
261 ; <rdar://problem/7595408> , <rdar://problem/7643881>
262 (opengl)
263
264 (location-services)
265
266 ; CRCopyRestrictionsDictionary periodically tries to CFPreferencesAppSynchronize com.apple.springboard.plist
267 ; which will attempt to create the plist if it doesn't exist -- from any application.  Only SpringBoard is
268 ; allowed to write its plist; ignore all others, they don't know what they are doing.
269 ; See <rdar://problem/9375027> for sample backtraces.
270 (deny file-write*
271     (home-prefix "/Library/Preferences/com.apple.springboard.plist")
272     (with no-log))
273
274 ;; <rdar://problem/34092690>
275 (allow mach-lookup
276     (xpc-service-name "com.apple.avkit.SharedPreferences"))
277
278 ;; <rdar://problem/34986314>
279 (mobile-preferences-read "com.apple.indigo")
280
281 ;; <rdar://problem/35417382>, <rdar://problem/35518557>
282 (allow mach-lookup
283     (global-name "com.apple.corespotlightservice"))
284
285 ;; <rdar://problem/35446577>
286 (allow mach-lookup
287     (global-name "com.apple.coremedia.endpointplaybacksession.xpc"))
288
289 ;; <rdar://problem/35509194>
290 (allow mach-lookup
291     (global-name "com.apple.coremedia.endpointremotecontrolsession.xpc"))
292
293 ;;;
294 ;;; End UIKit-apps.sb content
295 ;;;
296
297 ;; Access to media controls
298 (play-media)
299 (media-remote)
300
301 (deny sysctl*)
302 (allow sysctl-read
303     (sysctl-name
304         "hw.availcpu"
305         "hw.ncpu"
306         "hw.model"
307         "kern.memorystatus_level"
308         "vm.footprint_suspend"))
309
310 ;; Read-only preferences and data
311 (mobile-preferences-read
312     "com.apple.LaunchServices"
313     "com.apple.WebFoundation"
314     "com.apple.mobileipod"
315     "com.apple.avfoundation.videoperformancehud" ;; <rdar://problem/31594568>
316     "com.apple.voiceservices.logging")
317
318 ;; Sandbox extensions
319 (define (apply-read-and-issue-extension op path-filter)
320     (op file-read* path-filter)
321     (op file-issue-extension (require-all (extension-class "com.apple.app-sandbox.read") path-filter)))
322 (define (apply-write-and-issue-extension op path-filter)
323     (op file-write* path-filter)
324     (op file-issue-extension (require-all (extension-class "com.apple.app-sandbox.read-write") path-filter)))
325 (define (read-only-and-issue-extensions path-filter)
326     (apply-read-and-issue-extension allow path-filter))
327 (define (read-write-and-issue-extensions path-filter)
328     (apply-read-and-issue-extension allow path-filter)
329     (apply-write-and-issue-extension allow path-filter))
330 (read-only-and-issue-extensions (extension "com.apple.app-sandbox.read"))
331 (read-write-and-issue-extensions (extension "com.apple.app-sandbox.read-write"))
332
333 ;; Access to client's cache folder & re-vending to CFNetwork.
334 ;; FIXME: Remove the webkti specific extension classes <rdar://problem/17755931>
335 (allow file-issue-extension (require-all
336     (extension "com.apple.app-sandbox.read-write")
337     (extension-class "com.apple.nsurlstorage.extension-cache")))
338
339 ;; MediaAccessibility
340 (mobile-preferences-read "com.apple.mediaaccessibility")
341 (mobile-preferences-read-write "com.apple.mediaaccessibility.public")
342
343 ;; Remote Web Inspector
344 (allow mach-lookup
345        (global-name "com.apple.webinspector"))
346
347 ;; Various services required by CFNetwork and other frameworks
348 (allow mach-lookup
349     (global-name "com.apple.PowerManagement.control")
350     (global-name "com.apple.accountsd.accountmanager")
351     (global-name "com.apple.analyticsd")
352     (global-name "com.apple.coremedia.audiodeviceclock"))
353
354 (deny file-write-create (vnode-type SYMLINK))
355 (deny file-read-xattr file-write-xattr (xattr-regex #"^com\.apple\.security\.private\."))
356
357 ;; Allow loading injected bundles.
358 (allow file-map-executable)
359
360 ;; AWD logging
361 (awd-log-directory "com.apple.WebKit.WebContent")
362
363 (network-client (remote tcp) (remote udp))
364
365 ;; Allow ManagedPreference access
366 (allow file-read* (literal "/private/var/Managed Preferences/mobile/com.apple.webcontentfilter.plist"))
367
368 ;; Allow mediaserverd to issue file extensions for the purposes of reading media
369 (allow file-issue-extension (require-all
370     (extension "com.apple.app-sandbox.read")
371     (extension-class "com.apple.mediaserverd.read")))
372
373 ;; Allow CoreMedia to communicate with mediaserverd in order to implement custom media loading
374 (allow mach-lookup
375     (global-name "com.apple.coremedia.customurlloader.xpc"))
376
377 ;; Media capture, microphone access
378 (with-filter (extension "com.apple.webkit.microphone")
379     (allow device-microphone))
380
381 ;; Media capture, camera access
382 (with-filter (extension "com.apple.webkit.camera")
383     (allow user-preference-read
384         (preference-domain "com.apple.coremedia"))
385     (allow file-read* (subpath "/Library/CoreMediaIO/Plug-Ins/DAL"))
386     (allow mach-lookup (extension "com.apple.app-sandbox.mach"))
387     (allow device-camera))
388
389 ;; Support incoming video connections
390 (allow mach-lookup
391     (global-name "com.apple.audio.audiohald")
392     (global-name "com.apple.coremedia.compressionsession")
393     (global-name "com.apple.coremedia.decompressionsession")
394     (global-name "com.apple.coremedia.videoqueue"))