9220757ce832df2372efb5b0e4e89d40c90bfc9d
[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 ;; Silently deny unnecessary accesses caused by MessageUI framework.
159 ;; This can be removed once <rdar://problem/47038102> is resolved.
160 (deny file-read*
161     (home-literal "/Library/Preferences/com.apple.mobilemail.plist")
162     (with no-log))
163
164 ;; <rdar://problem/12985925> Need read access to /var/mobile/Library/Fonts to all apps
165 (allow file-read*
166     (home-subpath "/Library/Fonts"))
167
168 ;; <rdar://problem/7344719&26323449> LaunchServices app icons
169 (allow file-read*
170     (well-known-system-group-container-subpath "/systemgroup.com.apple.lsd.iconscache"))
171 (allow mach-lookup
172     (xpc-service-name "com.apple.lsdiconservice"))
173
174 ;; Common mach services needed by UIKit.
175 (allow mach-lookup
176     (global-name "com.apple.CARenderServer")
177     (global-name "com.apple.KeyboardServices.TextReplacementService")
178     (global-name "com.apple.assertiond.applicationstateconnection")
179     (global-name "com.apple.assertiond.expiration")
180     (global-name "com.apple.assertiond.processinfoservice")
181     (global-name "com.apple.audio.SystemSoundServer-iOS")
182     (global-name "com.apple.backboard.TouchDeliveryPolicyServer")
183     (global-name "com.apple.backboard.animation-fence-arbiter")
184     (global-name "com.apple.backboard.display.services")
185     (global-name "com.apple.backboard.hid.focus")
186     (global-name "com.apple.backboard.hid.services")
187     (global-name "com.apple.iohideventsystem")
188     (global-name "com.apple.iphone.axserver-systemwide")
189     (global-name "com.apple.frontboard.workspace")
190     (global-name "com.apple.frontboard.systemappservices"))
191
192 (allow-preferences-common)
193
194 ;; CoreMotion
195 (mobile-preferences-read "com.apple.CoreMotion")
196
197 ;; CoreMotion’s deviceMotion API
198 (with-filter
199     (require-any
200         (iokit-registry-entry-class "AppleOscarNub")
201         (iokit-registry-entry-class "AppleSPUHIDInterface"))
202     (allow iokit-get-properties
203         (iokit-property "gyro-interrupt-calibration")))
204 (with-filter
205     (iokit-registry-entry-class "IOHIDEventServiceFastPathUserClient")
206     (allow iokit-open)
207     (allow iokit-get-properties iokit-set-properties
208         (iokit-property "interval"
209                         "mode"
210                         "QueueSize"
211                         "useMag"))
212     (allow iokit-get-properties
213         (iokit-property "client")))
214
215 ;; Home Button
216 (with-filter (iokit-registry-entry-class "IOPlatformDevice")
217     (allow iokit-get-properties
218         (iokit-property "home-button-type")))
219
220 ;; Common preferences read by UIKit.
221 (mobile-preferences-read "com.apple.Accessibility"
222     "com.apple.UIKit"
223     "com.apple.WebUI"
224     "com.apple.airplay"
225     "com.apple.avkit"
226     "com.apple.coreanimation"
227     "com.apple.mt"
228     "com.apple.preferences.sounds")
229
230 ;; Silence sandbox violations from apps trying to create the empty plist if it doesn't exist.
231 ;; <rdar://problem/13796537>
232 (deny file-write-create
233     (home-prefix "/Library/Preferences/com.apple.UIKit.plist")
234     (with no-report))
235
236 ;; <rdar://problem/10809394>
237 (deny file-write-create
238     (home-prefix "/Library/Preferences/com.apple.Accessibility.plist")
239     (with no-report))
240
241 ;; <rdar://problem/9404009>
242 (mobile-preferences-read "kCFPreferencesAnyApplication")
243
244 ;; <rdar://problem/12250145>
245 (mobile-preferences-read "com.apple.mediaaccessibility")
246
247 ; Dictionary Services used by UITextFields.
248 ; <rdar://problem/9386926>
249 (allow-create-directory
250     (home-literal "/Library/Caches/com.apple.DictionaryServices"))
251
252 ; <rdar://problem/8548856> Sub-TLF: Sandbox change for apps for read-only access to the dictionary directory/data
253 (allow file-read*
254     ; XXX - /Library ought to be allowed in all UI profiles but isn't (CF, MobileSafari)
255     (subpath "/Library/Dictionaries")
256     (home-subpath "/Library/Dictionaries"))
257
258 ; <rdar://problem/8440231>
259 (allow file-read*
260     (home-literal "/Library/Caches/DateFormats.plist"))
261 ; Silently deny writes when CFData attempts to write to the cache directory.
262 (deny file-write*
263     (home-literal "/Library/Caches/DateFormats.plist")
264     (with no-log))
265
266 ; UIKit-required IOKit nodes.
267 (allow iokit-open
268     (iokit-user-client-class "AppleJPEGDriverUserClient")
269     (iokit-user-client-class "IOSurfaceAcceleratorClient")
270     (iokit-user-client-class "IOSurfaceSendRight")
271     ;; Requires by UIView -> UITextMagnifierRenderer -> UIWindow
272     (iokit-user-client-class "IOSurfaceRootUserClient"))
273
274 ;; <rdar://problem/12675621>
275 (allow iokit-open
276     (iokit-user-client-class "IOHIDLibUserClient"))
277
278 (framebuffer-access)
279
280 ;; <rdar://problem/7822790>
281 (mobile-keybag-access)
282
283 ; <rdar://problem/7595408> , <rdar://problem/7643881>
284 (opengl)
285
286 (location-services)
287
288 ; CRCopyRestrictionsDictionary periodically tries to CFPreferencesAppSynchronize com.apple.springboard.plist
289 ; which will attempt to create the plist if it doesn't exist -- from any application.  Only SpringBoard is
290 ; allowed to write its plist; ignore all others, they don't know what they are doing.
291 ; See <rdar://problem/9375027> for sample backtraces.
292 (deny file-write*
293     (home-prefix "/Library/Preferences/com.apple.springboard.plist")
294     (with no-log))
295
296 ;; <rdar://problem/34092690>
297 (allow mach-lookup
298     (xpc-service-name "com.apple.avkit.SharedPreferences"))
299
300 ;; <rdar://problem/34986314>
301 (mobile-preferences-read "com.apple.indigo")
302
303 ;; <rdar://problem/35417382>, <rdar://problem/35518557>
304 (allow mach-lookup
305     (global-name "com.apple.corespotlightservice"))
306
307 ;; <rdar://problem/35446577>
308 (allow mach-lookup
309     (global-name "com.apple.coremedia.endpointplaybacksession.xpc"))
310
311 ;; <rdar://problem/35509194>
312 (allow mach-lookup
313     (global-name "com.apple.coremedia.endpointremotecontrolsession.xpc"))
314
315 ;;;
316 ;;; End UIKit-apps.sb content
317 ;;;
318
319 (deny sysctl*)
320 (allow sysctl-read
321     (sysctl-name
322         "hw.availcpu"
323         "hw.ncpu"
324         "hw.model"
325         "kern.memorystatus_level"
326         "vm.footprint_suspend"))
327
328 (deny iokit-get-properties (with partial-symbolication))
329 (allow iokit-get-properties
330     (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)")
331     (iokit-property "APTDevice")
332     (iokit-property "AVCSupported")
333     (iokit-property-regex #"^AppleJPEG(NumCores|Supports(AppleInterchangeFormats|MissingEOI|RSTLogging))")
334     (iokit-property "BaseAddressAlignmentRequirement")
335     (iokit-property-regex #"^DisplayPipe(PlaneBaseAlignment|StrideRequirements)")
336     (iokit-property "HEVCSupported")
337     (iokit-property-regex #"^IOGL(|ES(|Metal))BundleName")
338     (iokit-property "IOGLESDefaultUseMetal")
339     (iokit-property-regex #"IOGVA(BGRAEnc|Codec|EncoderRestricted|Scaler)")
340     (iokit-property "IOClassNameOverride")
341     (iokit-property "IOSurfaceAcceleratorCapabilitiesDict")
342     (iokit-property-regex #"^MetalPlugin(Name|ClassName)")
343     (iokit-property "Protocol Characteristics")
344     (iokit-property "artwork-device-subtype")
345     (iokit-property-regex #"^canvas-(height|width)")
346     (iokit-property "class-code")
347     (iokit-property "color-accuracy-index")
348     (iokit-property "device-id")
349     (iokit-property "device-perf-memory-class")
350     (iokit-property "emu")
351     (iokit-property "hdcp-hoover-protocol")
352     (iokit-property "iommu-present")
353     (iokit-property "product-id")
354     (iokit-property "software-behavior")
355     (iokit-property "vendor-id")
356 )
357
358 ;; Read-only preferences and data
359 (mobile-preferences-read
360     "com.apple.LaunchServices"
361     "com.apple.WebFoundation"
362     "com.apple.mobileipod"
363     "com.apple.avfoundation.frecents" ;; <rdar://problem/33137029>
364     "com.apple.avfoundation.videoperformancehud" ;; <rdar://problem/31594568>
365     "com.apple.voiceservices.logging")
366
367 ;; Sandbox extensions
368 (define (apply-read-and-issue-extension op path-filter)
369     (op file-read* path-filter)
370     (op file-issue-extension (require-all (extension-class "com.apple.app-sandbox.read") path-filter)))
371 (define (apply-write-and-issue-extension op path-filter)
372     (op file-write* path-filter)
373     (op file-issue-extension (require-all (extension-class "com.apple.app-sandbox.read-write") path-filter)))
374 (define (read-only-and-issue-extensions path-filter)
375     (apply-read-and-issue-extension allow path-filter))
376 (define (read-write-and-issue-extensions path-filter)
377     (apply-read-and-issue-extension allow path-filter)
378     (apply-write-and-issue-extension allow path-filter))
379 (read-only-and-issue-extensions (extension "com.apple.app-sandbox.read"))
380 (read-write-and-issue-extensions (extension "com.apple.app-sandbox.read-write"))
381
382 ;; Access to client's cache folder & re-vending to CFNetwork.
383 ;; FIXME: Remove the webkti specific extension classes <rdar://problem/17755931>
384 (allow file-issue-extension (require-all
385     (extension "com.apple.app-sandbox.read-write")
386     (extension-class "com.apple.nsurlstorage.extension-cache")))
387
388 ;; MediaAccessibility
389 (mobile-preferences-read "com.apple.mediaaccessibility")
390 (mobile-preferences-read-write "com.apple.mediaaccessibility.public")
391
392 ;; Remote Web Inspector
393 (allow mach-lookup
394        (global-name "com.apple.webinspector"))
395
396 ;; Various services required by CFNetwork and other frameworks
397 (allow mach-lookup
398     (global-name "com.apple.PowerManagement.control")
399     (global-name "com.apple.accountsd.accountmanager")
400     (global-name "com.apple.analyticsd")
401     (global-name "com.apple.coremedia.audiodeviceclock"))
402
403 (deny file-write-create (vnode-type SYMLINK))
404 (deny file-read-xattr file-write-xattr (xattr-regex #"^com\.apple\.security\.private\."))
405
406 ;; Allow loading injected bundles.
407 (allow file-map-executable)
408
409 ;; AWD logging
410 (awd-log-directory "com.apple.WebKit.WebContent")
411
412 ;; Allow ManagedPreference access
413 (allow file-read* (literal "/private/var/Managed Preferences/mobile/com.apple.webcontentfilter.plist"))
414
415 (allow file-read-data
416     (literal "/usr/local/lib/log") ; <rdar://problem/36629495>
417 )
418
419 ;; Allow mediaserverd to issue file extensions for the purposes of reading media
420 (allow file-issue-extension (require-all
421     (extension "com.apple.app-sandbox.read")
422     (extension-class "com.apple.mediaserverd.read")))
423
424 ;; Allow CoreMedia to communicate with mediaserverd in order to implement custom media loading
425 (allow mach-lookup
426     (global-name "com.apple.coremedia.customurlloader.xpc"))
427
428 ;; Media capture, microphone access
429 (with-filter (extension "com.apple.webkit.microphone")
430     (allow device-microphone))
431
432 ;; Media capture, camera access
433 (with-filter (extension "com.apple.webkit.camera")
434     (allow user-preference-read
435         (preference-domain "com.apple.coremedia"))
436     (allow file-read* (subpath "/Library/CoreMediaIO/Plug-Ins/DAL"))
437     (allow mach-lookup (extension "com.apple.app-sandbox.mach"))
438     (allow device-camera))
439
440 ;; Support incoming video connections
441 (allow mach-lookup
442     (global-name "com.apple.audio.audiohald")
443     (global-name "com.apple.coremedia.compressionsession")
444     (global-name "com.apple.coremedia.decompressionsession")
445     (global-name "com.apple.coremedia.videoqueue"))