04d3d105616a4d25d3a76a331f9a3433be48963b
[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
140 ;; <rdar://problem/12985925> Need read access to /var/mobile/Library/Fonts to all apps
141 (allow file-read*
142     (home-subpath "/Library/Fonts"))
143
144 ;; <rdar://problem/7344719&26323449> LaunchServices app icons
145 (allow file-read*
146     (well-known-system-group-container-subpath "/systemgroup.com.apple.lsd.iconscache"))
147 (allow mach-lookup
148     (xpc-service-name "com.apple.lsdiconservice"))
149
150 ;; Common mach services needed by UIKit.
151 (allow mach-lookup
152     (global-name "com.apple.CARenderServer")
153     (global-name "com.apple.KeyboardServices.TextReplacementService")
154     (global-name "com.apple.assertiond.applicationstateconnection")
155     (global-name "com.apple.assertiond.expiration")
156     (global-name "com.apple.assertiond.processinfoservice")
157     (global-name "com.apple.audio.SystemSoundServer-iOS")
158     (global-name "com.apple.backboard.TouchDeliveryPolicyServer")
159     (global-name "com.apple.backboard.animation-fence-arbiter")
160     (global-name "com.apple.backboard.display.services")
161     (global-name "com.apple.backboard.hid.focus")
162     (global-name "com.apple.backboard.hid.services")
163     (global-name "com.apple.iohideventsystem")
164     (global-name "com.apple.iphone.axserver-systemwide")
165     (global-name "com.apple.frontboard.workspace")
166     (global-name "com.apple.frontboard.systemappservices"))
167
168 (allow-preferences-common)
169
170 ;; CoreMotion
171 (mobile-preferences-read "com.apple.CoreMotion")
172
173 ;; CoreMotion’s deviceMotion API
174 (with-filter
175     (require-any
176         (iokit-registry-entry-class "AppleOscarNub")
177         (iokit-registry-entry-class "AppleSPUHIDInterface"))
178     (allow iokit-get-properties
179         (iokit-property "gyro-interrupt-calibration")))
180 (with-filter
181     (iokit-registry-entry-class "IOHIDEventServiceFastPathUserClient")
182     (allow iokit-open)
183     (allow iokit-get-properties iokit-set-properties
184         (iokit-property "interval"
185                         "mode"
186                         "QueueSize"
187                         "useMag"))
188     (allow iokit-get-properties
189         (iokit-property "client")))
190
191 ;; Common preferences read by UIKit.
192 (mobile-preferences-read "com.apple.Accessibility"
193     "com.apple.UIKit"
194     "com.apple.WebUI"
195     "com.apple.airplay"
196     "com.apple.avkit"
197     "com.apple.coreanimation"
198     "com.apple.mt"
199     "com.apple.preferences.sounds")
200
201 ;; Silence sandbox violations from apps trying to create the empty plist if it doesn't exist.
202 ;; <rdar://problem/13796537>
203 (deny file-write-create
204     (home-prefix "/Library/Preferences/com.apple.UIKit.plist")
205     (with no-report))
206
207 ;; <rdar://problem/10809394>
208 (deny file-write-create
209     (home-prefix "/Library/Preferences/com.apple.Accessibility.plist")
210     (with no-report))
211
212 ;; <rdar://problem/9404009>
213 (mobile-preferences-read "kCFPreferencesAnyApplication")
214
215 ;; <rdar://problem/10266866>
216 (marco-logging-client)
217
218 ;; <rdar://problem/12250145>
219 (mobile-preferences-read "com.apple.mediaaccessibility")
220
221 ; Dictionary Services used by UITextFields.
222 ; <rdar://problem/9386926>
223 (allow-create-directory
224     (home-literal "/Library/Caches/com.apple.DictionaryServices"))
225
226 (allow-network-common)
227
228 ; <rdar://problem/8548856> Sub-TLF: Sandbox change for apps for read-only access to the dictionary directory/data
229 (allow file-read*
230     ; XXX - /Library ought to be allowed in all UI profiles but isn't (CF, MobileSafari)
231     (subpath "/Library/Dictionaries")
232     (home-subpath "/Library/Dictionaries"))
233
234 ; <rdar://problem/8440231>
235 (allow file-read*
236     (home-literal "/Library/Caches/DateFormats.plist"))
237 ; Silently deny writes when CFData attempts to write to the cache directory.
238 (deny file-write*
239     (home-literal "/Library/Caches/DateFormats.plist")
240     (with no-log))
241
242 ; UIKit-required IOKit nodes.
243 (allow iokit-open
244     (iokit-user-client-class "AppleJPEGDriverUserClient")
245     (iokit-user-client-class "IOSurfaceAcceleratorClient")
246     (iokit-user-client-class "IOSurfaceSendRight")
247     ;; Requires by UIView -> UITextMagnifierRenderer -> UIWindow
248     (iokit-user-client-class "IOSurfaceRootUserClient"))
249
250 ;; <rdar://problem/12675621>
251 (allow iokit-open
252     (iokit-user-client-class "IOHIDLibUserClient"))
253
254 (framebuffer-access)
255
256 ;; <rdar://problem/7822790>
257 (mobile-keybag-access)
258
259 ; <rdar://problem/7595408> , <rdar://problem/7643881>
260 (opengl)
261
262 (location-services)
263
264 ; CRCopyRestrictionsDictionary periodically tries to CFPreferencesAppSynchronize com.apple.springboard.plist
265 ; which will attempt to create the plist if it doesn't exist -- from any application.  Only SpringBoard is
266 ; allowed to write its plist; ignore all others, they don't know what they are doing.
267 ; See <rdar://problem/9375027> for sample backtraces.
268 (deny file-write*
269     (home-prefix "/Library/Preferences/com.apple.springboard.plist")
270     (with no-log))
271
272 ;; <rdar://problem/34092690>
273 (allow mach-lookup
274     (xpc-service-name "com.apple.avkit.SharedPreferences"))
275
276 ;; <rdar://problem/34986314>
277 (mobile-preferences-read "com.apple.indigo")
278
279 ;; <rdar://problem/35417382>, <rdar://problem/35518557>
280 (allow mach-lookup
281     (global-name "com.apple.corespotlightservice"))
282
283 ;; <rdar://problem/35446577>
284 (allow mach-lookup
285     (global-name "com.apple.coremedia.endpointplaybacksession.xpc"))
286
287 ;; <rdar://problem/35509194>
288 (allow mach-lookup
289     (global-name "com.apple.coremedia.endpointremotecontrolsession.xpc"))
290
291 ;;;
292 ;;; End UIKit-apps.sb content
293 ;;;
294
295 ;; Access to media controls
296 (play-media)
297 (media-remote)
298
299 (deny sysctl*)
300 (allow sysctl-read
301     (sysctl-name
302         "hw.availcpu"
303         "hw.ncpu"
304         "hw.model"
305         "kern.memorystatus_level"
306         "vm.footprint_suspend"))
307
308 ;; Read-only preferences and data
309 (mobile-preferences-read
310     "com.apple.LaunchServices"
311     "com.apple.WebFoundation"
312     "com.apple.mobileipod"
313     "com.apple.avfoundation.videoperformancehud" ;; <rdar://problem/31594568>
314     "com.apple.voiceservices.logging")
315
316 ;; Sandbox extensions
317 (define (apply-read-and-issue-extension op path-filter)
318     (op file-read* path-filter)
319     (op file-issue-extension (require-all (extension-class "com.apple.app-sandbox.read") path-filter)))
320 (define (apply-write-and-issue-extension op path-filter)
321     (op file-write* path-filter)
322     (op file-issue-extension (require-all (extension-class "com.apple.app-sandbox.read-write") path-filter)))
323 (define (read-only-and-issue-extensions path-filter)
324     (apply-read-and-issue-extension allow path-filter))
325 (define (read-write-and-issue-extensions path-filter)
326     (apply-read-and-issue-extension allow path-filter)
327     (apply-write-and-issue-extension allow path-filter))
328 (read-only-and-issue-extensions (extension "com.apple.app-sandbox.read"))
329 (read-write-and-issue-extensions (extension "com.apple.app-sandbox.read-write"))
330
331 ;; Access to client's cache folder & re-vending to CFNetwork.
332 ;; FIXME: Remove the webkti specific extension classes <rdar://problem/17755931>
333 (allow file-issue-extension (require-all
334     (extension "com.apple.app-sandbox.read-write")
335     (extension-class "com.apple.nsurlstorage.extension-cache")))
336
337 ;; MediaAccessibility
338 (mobile-preferences-read "com.apple.mediaaccessibility")
339 (mobile-preferences-read-write "com.apple.mediaaccessibility.public")
340
341 ;; Remote Web Inspector
342 (allow mach-lookup
343        (global-name "com.apple.webinspector"))
344
345 ;; Various services required by CFNetwork and other frameworks
346 (allow mach-lookup
347     (global-name "com.apple.PowerManagement.control")
348     (global-name "com.apple.accountsd.accountmanager")
349     (global-name "com.apple.analyticsd")
350     (global-name "com.apple.coremedia.audiodeviceclock"))
351
352 (deny file-write-create (vnode-type SYMLINK))
353 (deny file-read-xattr file-write-xattr (xattr-regex #"^com\.apple\.security\.private\."))
354
355 ;; Allow loading injected bundles.
356 (allow file-map-executable)
357
358 ;; AWD logging
359 (awd-log-directory "com.apple.WebKit.WebContent")
360
361 (network-client (remote tcp) (remote udp))
362
363 ;; Allow ManagedPreference access
364 (allow file-read* (literal "/private/var/Managed Preferences/mobile/com.apple.webcontentfilter.plist"))
365
366 ;; Allow mediaserverd to issue file extensions for the purposes of reading media
367 (allow file-issue-extension (require-all
368     (extension "com.apple.app-sandbox.read")
369     (extension-class "com.apple.mediaserverd.read")))
370
371 ;; Allow CoreMedia to communicate with mediaserverd in order to implement custom media loading
372 (allow mach-lookup
373     (global-name "com.apple.coremedia.customurlloader.xpc"))
374
375 ;; Media capture, microphone access
376 (with-filter (extension "com.apple.webkit.microphone")
377     (allow device-microphone))
378
379 ;; Media capture, camera access
380 (with-filter (extension "com.apple.webkit.camera")
381     (allow user-preference-read
382         (preference-domain "com.apple.coremedia"))
383     (allow file-read* (subpath "/Library/CoreMediaIO/Plug-Ins/DAL"))
384     (allow mach-lookup (extension "com.apple.app-sandbox.mach"))
385     (allow device-camera))
386
387 ;; Support incoming video connections
388 (allow mach-lookup
389     (global-name "com.apple.audio.audiohald")
390     (global-name "com.apple.coremedia.compressionsession")
391     (global-name "com.apple.coremedia.decompressionsession")
392     (global-name "com.apple.coremedia.videoqueue"))