/
com.apple.WebKit.webpushd.sb.in
212 lines (177 loc) · 7.32 KB
/
com.apple.WebKit.webpushd.sb.in
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
; Copyright (C) 2021-2022 Apple Inc. All rights reserved.
;
; Redistribution and use in source and binary forms, with or without
; modification, are permitted provided that the following conditions
; are met:
; 1. Redistributions of source code must retain the above copyright
; notice, this list of conditions and the following disclaimer.
; 2. Redistributions in binary form must reproduce the above copyright
; notice, this list of conditions and the following disclaimer in the
; documentation and/or other materials provided with the distribution.
;
; THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
; AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
; THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
; PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
; BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
; CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
; SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
; INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
; CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
; ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
; THE POSSIBILITY OF SUCH DAMAGE.
(version 1)
; FIXME: tighten sandbox after we get enough internal reports.
; (deny default (with partial-symbolication))
(allow (with report) default)
(allow system-audit file-read-metadata)
(import "util.sb")
(define (allow-read-write-directory-contents path)
(if path
(begin
(allow file-read* (subpath path))
(allow file-read* file-write*
(regex (string-append "^" (regex-quote path) "/")))
(allow file-write-create
file-write-data
(require-all (vnode-type DIRECTORY) (literal path))))))
(define (allow-read-directory-and-issue-read-extensions path)
(if path
(begin
(allow file-read* (subpath path))
(allow file-issue-extension (require-all (extension-class "com.apple.app-sandbox.read") (subpath path))))))
(allow file-read* file-map-executable
(subpath "/usr/lib")
(subpath "/System/Library/Frameworks")
(subpath "/System/Library/PrivateFrameworks"))
(with-filter (system-attribute apple-internal)
(allow mach-lookup
(global-name "com.apple.analyticsd")
(global-name "com.apple.diagnosticd")))
(deny sysctl* (with telemetry))
(allow sysctl-read
(sysctl-name
"hw.activecpu"
"hw.osenvironment"
"hw.target"
"hw.machine"
"hw.memsize"
"hw.ncpu"
"hw.pagesize_compat"
"kern.bootargs"
"kern.hostname"
"kern.maxfilesperproc"
"kern.osproductversion"
"kern.osrelease"
"kern.ostype"
"kern.osvariant_status"
"kern.osversion"
"kern.secure_kernel"
"kern.version"
"vm.footprint_suspend")
(sysctl-name-prefix "kern.proc.pid.")
)
(with-filter (system-attribute apple-internal)
(allow sysctl-read sysctl-write
(sysctl-name
"vm.footprint_suspend"
)
)
)
(allow-read-write-directory-contents (param "DARWIN_USER_CACHE_DIR"))
(allow-read-write-directory-contents (param "DARWIN_USER_TEMP_DIR"))
(allow-read-directory-and-issue-read-extensions (param "FRAMEWORKS_DIR"))
;; AWD
(allow mach-lookup
(global-name
"com.apple.analyticsd"
"com.apple.awdd"))
;; Note this does not allow subpaths of "/"
(allow file-read* file-test-existence
(literal "/"))
(allow file-read-data
(literal "/System/Library/CoreServices/SystemVersion.plist")
(literal "/usr/lib/log")
(literal "/usr/local/lib/log")) ; <rdar://problem/36629495>
;; Security framework
(allow mach-lookup (global-name "com.apple.SecurityServer")
(global-name "com.apple.ocspd"))
(allow file-read*
(literal "/dev/urandom")
(literal "/private/etc/master.passwd")
(subpath "/private/var/preferences/Logging")
(subpath "/Library/Keychains")
(subpath "/private/var/db/mds")
(literal "/Library/Preferences/com.apple.security.plist")
(home-literal "/Library/Preferences/com.apple.security.plist"))
;;; Allow reading internal profiles on development builds
(allow file-read*
(require-all (file-mode #o0004)
(subpath "/AppleInternal/Library/Preferences/Logging")
(system-attribute apple-internal)))
(allow file-read* (subpath "/usr/share"))
(allow file-read* (literal "/Library/Application Support/CrashReporter/SubmitDiagInfo.domains"))
(allow ipc-posix-shm-read-data
(ipc-posix-name "com.apple.AppleDatabaseChanged"))
(allow ipc-posix-shm-write-data
(ipc-posix-name "com.apple.AppleDatabaseChanged"))
(allow ipc-posix-shm-read*
(ipc-posix-name "apple.shm.notification_center")) ;; Needed by os_log_create
;; Read-only preferences and data
(allow file-read*
;; Basic system paths
(subpath "/Library/Managed Preferences")
;; System and user preferences
(literal "/Library/Preferences/.GlobalPreferences.plist")
(home-literal "/Library/Preferences/.GlobalPreferences.plist")
(home-regex #"/Library/Preferences/ByHost/\.GlobalPreferences\."))
(allow system-fsctl (fsctl-command (_IO "h" 47)))
#if ENABLE(SYSTEM_CONTENT_PATH_SANDBOX_RULES)
#include <WebKitAdditions/SystemContentSandbox-ios.defs>
(allow file-read* file-test-existence
(apply subpath file-read-existence-secondary-paths))
(allow file-map-executable
(apply subpath secondary-framework-and-dylib-paths))
#endif
;; Standard paths.
(define required-etc-files
(literal "/private/etc/hosts"
"/private/etc/passwd"
"/private/etc/services"))
(allow file-read*
required-etc-files)
;; Various services required by CFNetwork and other frameworks.
(allow mach-lookup
(global-name "com.apple.logd")
(global-name "com.apple.system.notification_center"))
;; Daemon prefs.
(allow user-preference-read user-preference-write
(preference-domain "com.apple.webkit.webpushd"))
;; Push notification registration.
(allow mach-lookup
(global-name "com.apple.apsd"))
;; Allow webpushd to launch UI processes in response to a push via LaunchServices.
(allow lsopen)
(allow mach-lookup
(global-name "com.apple.coreservices.launchservicesd")
(global-name "com.apple.coreservices.quarantine-resolver")
(global-name "com.apple.lsd.mapdb"))
(allow user-preference-read
(preference-domain
"com.apple.inputmethodkit"
"com.apple.inputsources"
"com.apple.LaunchServices"
"kCFPreferencesAnyApplication"))
;; We might need to create ~/Library/WebKit and ~/Library/WebKit/WebPush on a clean install.
(allow file-write-create
(require-all (vnode-type DIRECTORY) (home-literal "/Library/WebKit"))
(require-all (vnode-type DIRECTORY) (home-literal "/Library/WebKit/WebPush")))
;; Push database.
(allow file*
(home-literal "/Library/WebKit/WebPush/PushDatabase.db")
(home-literal "/Library/WebKit/WebPush/PushDatabase.db-shm")
(home-literal "/Library/WebKit/WebPush/PushDatabase.db-wal")
(home-literal "/Library/WebKit/WebPush/PushDatabase.db-lock")
(home-literal "/Library/WebKit/WebPush/PushDatabase.db-journal"))
;; Let SQLite open the parent directory of the database for fsync purposes.
(allow file-read-data (require-all (vnode-type DIRECTORY) (home-prefix "/Library/WebKit/WebPush")))