com.apple.WebProcess.sb.in 16 KB

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