com.apple.WebKit.NetworkProcess.sb.in 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178
  1. ; Copyright (C) 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. (import "system.sb")
  27. ;; Utility functions for home directory relative path filters
  28. (define (home-regex home-relative-regex)
  29. (regex (string-append "^" (regex-quote (param "HOME_DIR")) home-relative-regex)))
  30. (define (home-subpath home-relative-subpath)
  31. (subpath (string-append (param "HOME_DIR") home-relative-subpath)))
  32. (define (home-literal home-relative-literal)
  33. (literal (string-append (param "HOME_DIR") home-relative-literal)))
  34. #if __MAC_OS_X_VERSION_MIN_REQUIRED == 1070
  35. ;; Low level networking. Defined in system.sb on newer OS versions.
  36. (define (system-network)
  37. (allow file-read*
  38. (literal "/Library/Preferences/com.apple.networkd.plist"))
  39. (allow mach-lookup
  40. (global-name "com.apple.SystemConfiguration.PPPController")
  41. (global-name "com.apple.SystemConfiguration.SCNetworkReachability")
  42. (global-name "com.apple.networkd"))
  43. (allow network-outbound
  44. (control-name "com.apple.netsrc")
  45. (control-name "com.apple.network.statistics"))
  46. (allow system-socket
  47. (require-all (socket-domain AF_SYSTEM)
  48. (socket-protocol 2)) ; SYSPROTO_CONTROL
  49. (socket-domain AF_ROUTE)))
  50. #endif
  51. ;; Read-only preferences and data
  52. (allow file-read*
  53. ;; Basic system paths
  54. (subpath "/Library/Frameworks")
  55. (subpath "/Library/Managed Preferences")
  56. ;; System and user preferences
  57. (literal "/Library/Preferences/.GlobalPreferences.plist")
  58. (regex #"^/Library/Managed Preferences/[^/]+/com\.apple\.networkConnect\.plist$")
  59. (home-literal "/Library/Preferences/.GlobalPreferences.plist")
  60. (home-regex #"/Library/Preferences/ByHost/\.GlobalPreferences\.")
  61. (home-regex #"/Library/Preferences/ByHost/com\.apple\.networkConnect\.")
  62. (home-literal "/Library/Preferences/com.apple.DownloadAssessment.plist")
  63. (home-literal "/Library/Preferences/com.apple.WebFoundation.plist")
  64. ;; On-disk WebKit2 framework location, to account for debug installations
  65. ;; outside of /System/Library/Frameworks
  66. (subpath (param "WEBKIT2_FRAMEWORK_DIR")))
  67. ;; Sandbox extensions
  68. (define (apply-read-and-issue-extension op path-filter)
  69. (op file-read* path-filter)
  70. (op file-issue-extension (require-all (extension-class "com.apple.app-sandbox.read") path-filter)))
  71. (define (apply-write-and-issue-extension op path-filter)
  72. (op file-write* path-filter)
  73. (op file-issue-extension (require-all (extension-class "com.apple.app-sandbox.read-write") path-filter)))
  74. (define (read-only-and-issue-extensions path-filter)
  75. (apply-read-and-issue-extension allow path-filter))
  76. (define (read-write-and-issue-extensions path-filter)
  77. (apply-read-and-issue-extension allow path-filter)
  78. (apply-write-and-issue-extension allow path-filter))
  79. (read-only-and-issue-extensions (extension "com.apple.app-sandbox.read"))
  80. (read-write-and-issue-extensions (extension "com.apple.app-sandbox.read-write"))
  81. #if __MAC_OS_X_VERSION_MIN_REQUIRED >= 1080
  82. (allow file-read* file-write* (subpath (param "DARWIN_USER_CACHE_DIR")))
  83. #else
  84. (allow file-read* file-write* (subpath (string-append (param "DARWIN_USER_CACHE_DIR") "/mds")))
  85. #endif
  86. (allow file-read* file-write* (subpath (param "DARWIN_USER_TEMP_DIR")))
  87. ;; IOKit user clients
  88. (allow iokit-open
  89. (iokit-user-client-class "RootDomainUserClient"))
  90. ;; cookied.
  91. ;; FIXME: Update for <rdar://problem/13642852>.
  92. (allow ipc-posix-shm-read-data
  93. (ipc-posix-name "FNetwork.defaultStorageSession")
  94. (ipc-posix-name-regex #"\.PrivateBrowsing-")
  95. (ipc-posix-name-regex #"^Private WebKit Session-"))
  96. ;; Various services required by CFNetwork and other frameworks
  97. (allow mach-lookup
  98. (global-name "com.apple.PowerManagement.control")
  99. (global-name "com.apple.SystemConfiguration.configd")
  100. (global-name "com.apple.cookied")
  101. (global-name "com.apple.cfnetwork.AuthBrokerAgent"))
  102. ;; Security framework
  103. (allow mach-lookup
  104. (global-name "com.apple.ocspd")
  105. (global-name "com.apple.SecurityServer"))
  106. (allow file-read* file-write* (home-subpath "/Library/Keychains")) ;; FIXME: This should be removed when <rdar://problem/10479685> is fixed.
  107. (allow file-read* file-write* (subpath "/private/var/db/mds/system")) ;; FIXME: This should be removed when <rdar://problem/9538414> is fixed.
  108. (allow file-read*
  109. (subpath "/Library/Keychains")
  110. (subpath "/private/var/db/mds")
  111. (literal "/private/var/db/DetachedSignatures")
  112. (literal "/Library/Preferences/com.apple.crypto.plist")
  113. (literal "/Library/Preferences/com.apple.security.plist")
  114. (literal "/Library/Preferences/com.apple.security.common.plist")
  115. (literal "/Library/Preferences/com.apple.security.revocation.plist")
  116. (home-literal "/Library/Application Support/SyncServices/Local/ClientsWithChanges/com.apple.Keychain")
  117. (home-literal "/Library/Preferences/com.apple.security.plist")
  118. (home-literal "/Library/Preferences/com.apple.security.revocation.plist"))
  119. (allow ipc-posix-shm-read* ipc-posix-shm-write-data
  120. (ipc-posix-name "com.apple.AppleDatabaseChanged"))
  121. (system-network)
  122. (allow network-outbound
  123. ;; Local mDNSResponder for DNS, arbitrary outbound TCP
  124. (literal "/private/var/run/mDNSResponder")
  125. (remote tcp))
  126. ;; FIXME should be removed when <rdar://problem/9347205> + related radar in Safari is fixed
  127. (allow mach-lookup
  128. (global-name "org.h5l.kcm")
  129. (global-name "com.apple.system.logger")
  130. (global-name "com.apple.system.notification_center"))
  131. (allow network-outbound
  132. (remote udp))
  133. (allow file-read*
  134. (home-subpath "/Library/Preferences/com.apple.Kerberos.plist")
  135. (home-subpath "/Library/Preferences/com.apple.GSS.plist")
  136. (home-subpath "/Library/Preferences/edu.mit.Kerberos")
  137. (literal "/Library/Preferences/com.apple.Kerberos.plist")
  138. (literal "/Library/Preferences/com.apple.GSS.plist")
  139. (literal "/Library/Preferences/edu.mit.Kerberos")
  140. (literal "/private/etc/krb5.conf")
  141. (literal "/private/etc/services")
  142. (literal "/private/etc/host"))
  143. (if (defined? 'vnode-type)
  144. (deny file-write-create (vnode-type SYMLINK)))
  145. ;; FIXME: Should be removed once <rdar://problem/16329087> is fixed.
  146. (deny file-write-xattr (xattr "com.apple.quarantine") (with no-log))
  147. ;; Reserve a namespace for additional protected extended attributes.
  148. (deny file-read-xattr file-write-xattr (xattr #"^com\.apple\.security\.private\."))
  149. (deny file-read* file-write* (with no-log)
  150. #if __MAC_OS_X_VERSION_MIN_REQUIRED <= 1080
  151. (home-literal "/Library/Caches/Cache.db") ;; <rdar://problem/9422957>
  152. #endif
  153. ;; FIXME: Should be removed after <rdar://problem/10463881> is fixed.
  154. (home-literal "/Library/Preferences/com.apple.LaunchServices.QuarantineEventsV2")
  155. (home-literal "/Library/Preferences/com.apple.LaunchServices.QuarantineEventsV2-journal"))