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