1 ; -*- Mode: Scheme; tab-width: 4 -*-
3 ; Copyright (c) 2007 Apple Inc. All rights reserved.
5 ; Redistribution and use in source and binary forms, with or without
6 ; modification, are permitted provided that the following conditions are met:
8 ; 1. Redistributions of source code must retain the above copyright notice,
9 ; this list of conditions and the following disclaimer.
10 ; 2. Redistributions in binary form must reproduce the above copyright notice,
11 ; this list of conditions and the following disclaimer in the documentation
12 ; and/or other materials provided with the distribution.
13 ; 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of its
14 ; contributors may be used to endorse or promote products derived from this
15 ; software without specific prior written permission.
17 ; THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
18 ; EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
19 ; WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
20 ; DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
21 ; DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
22 ; (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
23 ; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
24 ; ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 ; (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
26 ; SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 ; $Log: mDNSResponder.sb,v $
29 ; Revision 1.38 2009/04/16 16:03:08 mcguire
30 ; <rdar://problem/6792024> abort() causes high CPU usage instead of crash & restart
32 ; Revision 1.37 2009/04/02 22:21:17 mcguire
33 ; <rdar://problem/6577409> Adopt IOPM APIs
35 ; Revision 1.36 2009/03/02 01:32:20 mcguire
36 ; <rdar://problem/6623264> Seatbelt: Add rule to allow raw sockets
38 ; Revision 1.35 2009/02/07 02:51:10 cheshire
39 ; <rdar://problem/6084043> Sleep Proxy: Need to adopt IOPMConnection
40 ; Allow mDNSResponder to access IOPMConnection API
42 ; Revision 1.34 2008/11/11 00:55:08 mcguire
43 ; <rdar://problem/6357957> sandbox: need to allow Mach port com.apple.system.DirectoryService.membership_v1
45 ; Revision 1.33 2008/10/24 02:03:30 cheshire
46 ; So we can watch for Internet Sharing changes, allow read access to
47 ; /Library/Preferences/SystemConfiguration/com.apple.nat.plist
49 ; Revision 1.32 2008/10/07 23:06:58 mcguire
50 ; <rdar://problem/6276444> Seatbelt: Policy denied Mach service lookup: com.apple.system.logger
52 ; Revision 1.31 2008/09/24 23:57:27 mcguire
53 ; <rdar://problem/6227808> need read access to /private/var/db/crls/crlcache.db
55 ; Revision 1.30 2008/09/11 22:01:51 mcguire
56 ; re-add accidentally removed log comment
58 ; Revision 1.29 2008/09/11 20:46:08 mcguire
59 ; <rdar://problem/6208848> can't write to -Caches-
61 ; Revision 1.28 2008/09/11 20:04:14 mcguire
62 ; <rdar://problem/6211355> Instances of \. in regex exprs don't do what is intended
64 ; Revision 1.27 2008/07/24 21:18:14 cheshire
65 ; <rdar://problem/3988320> Should use randomized source ports and transaction IDs to avoid DNS cache poisoning
66 ; Need to allow access to /dev/urandom
68 ; Revision 1.26 2008/06/03 01:21:12 mcguire
69 ; <rdar://problem/5902470> add /var/db/mds to sb profile
71 ; Revision 1.25 2008/03/17 18:04:41 mcguire
72 ; <rdar://problem/5800476> SC now reads preference file
74 ; Revision 1.24 2007/09/20 22:33:17 cheshire
75 ; Tidied up inconsistent and error-prone naming -- used to be mDNSResponderHelper in
76 ; some places and mDNSResponder.helper in others; now mDNSResponderHelper everywhere
78 ; Revision 1.23 2007/09/04 22:26:18 mcguire
79 ; <rdar://problem/5442826> Seatbelt: mDNSResponder needs to be allowed to access "/Library/Security/Trust Settings/" etc.
81 ; Revision 1.22 2007/08/24 22:01:56 mcguire
82 ; <rdar://problem/5141606> BTMM: Task: Change mDNSResponder Seatbelt settings to "deny default" instead of "signal FPE" just prior to GM candidate
84 ; Revision 1.21 2007/08/18 01:02:03 mcguire
85 ; <rdar://problem/5415593> No Bonjour services are getting registered at boot
87 ; Revision 1.20 2007/08/08 22:34:59 mcguire
88 ; <rdar://problem/5197869> Security: Run mDNSResponder as user id mdnsresponder instead of root
90 ; Revision 1.19 2007/07/02 23:37:50 cheshire
91 ; <rdar://problem/5267615> Need to list of allowed mach-lookup operations explicitly in mDNSResponder.sb
93 ; Revision 1.18 2007/06/28 20:43:35 cheshire
94 ; <rdar://problem/5298202> Seatbelt: mDNSResponder needs to be able to access /dev/autofs_nowait
96 ; Revision 1.17 2007/06/28 20:34:45 cheshire
97 ; Updated comments to reflect new seatbelt language syntax
99 ; Revision 1.16 2007/05/29 23:32:46 cheshire
100 ; Rearrange file so SPI warning isn't deleted when CVS history is trimmed from installed copy
102 ; Revision 1.15 2007/05/25 22:45:17 jvidrine
103 ; <rdar://problem/5227658> Update mDNSResponder.sb to Seatbelt Profile Language version 1
105 ; Revision 1.14 2007/05/23 17:40:08 cheshire
106 ; <rdar://problem/5221397> Seatbelt killed mDNSResponder trying to read X509Anchors and X509Certificates
108 ; Revision 1.13 2007/05/23 01:47:59 cheshire
109 ; Need to list fs_read_data permission explicitly --
110 ; unlike fs_read/fs_write, fs_read_data does NOT automatically inherit from fs_write_data
112 ; Revision 1.12 2007/05/21 23:52:27 cheshire
113 ; <rdar://problem/5216638> Seatbelt killed mDNSResponder generating Module Directory Services cache
115 ; Revision 1.11 2007/05/20 16:29:06 cheshire
116 ; <rdar://problem/5213725> Seatbelt killed mDNSResponder trying to access /usr/share/icu/icudt36l.dat
118 ; Revision 1.10 2007/05/15 00:21:39 cheshire
119 ; <rdar://problem/5202374> Seatbelt killed mDNSResponder reading /private/var/root/Library/Preferences/com.apple.security.plist
121 ; Revision 1.9 2007/05/14 22:08:26 cheshire
122 ; <rdar://problem/5200986> Seatbelt: Need to escape literal dots in filename patterns
124 ; Revision 1.8 2007/05/14 19:39:31 cheshire
125 ; <rdar://problem/5198345> Seatbelt killed mDNSResponder in CFTimeZoneCopyDefault
126 ; <rdar://problem/5199456> Seatbelt killed mDNSResponder in SecKeychainOpen
128 ; Revision 1.7 2007/05/12 01:57:56 cheshire
129 ; <rdar://problem/5197938> Seatbelt: mDNSResponder needs to be able to access preferences.plist-lock
131 ; Revision 1.6 2007/05/10 21:12:14 cheshire
132 ; <rdar://problem/5149833> Start using "debug deny" mode in Seatbelt
134 ; Revision 1.5 2007/05/10 19:41:25 cheshire
135 ; <rdar://problem/5182549> Have to use "deny mach_lookup_default" because "signal" doesn't work
137 ; Revision 1.4 2007/04/27 20:46:31 cheshire
138 ; Additional requirements: allow mDNSResponder to read /dev/random and /System/Library/Keychains/System.*
140 ; Revision 1.3 2007/04/20 19:42:14 cheshire
141 ; Condense rules a bit to bring file under Seatbelt's 4K limit
143 ; Revision 1.2 2007/04/19 01:47:49 cheshire
144 ; Refinements to sandbox profile, e.g. allow writing to /dev/console early in the boot process
146 ; Revision 1.1 2007/04/18 00:50:47 cheshire
147 ; <rdar://problem/5141540> Sandbox mDNSResponder
149 ;############################################################################
151 ; WARNING! SEATBELT CURRENTLY CAN'T HANDLE PROFILES LARGER THAN 16K
152 ; MAKE SURE THE SIZE OF THIS FILE FROM "version" TO THE END DOESN'T EXCEED 16K
156 ; WARNING: The sandbox rule capabilities and syntax used in this file are currently an
157 ; Apple SPI (System Private Interface) and are subject to change at any time without notice.
158 ; Apple may in future announce an official public supported sandbox API, but until then Developers
159 ; are cautioned not to build products that use or depend on the sandbox facilities illustrated here.
161 ; Use "debug all" to log all operations examined by seatbelt, whether allowed or not.
162 ; Use "debug deny" to log only operations that are denied by seatbelt
163 ; to discover what specific attempted operation is causing an exception.
168 ; To help debugging, "with send-signal SIGFPE" will trigger a fake floating-point exception,
169 ; which will crash the process and show the call stack leading to the offending operation.
170 ; For the shipping version "deny" is probably better because it vetoes the operation
171 ; without killing the process.
174 ;(deny default (with send-signal SIGFPE))
176 ; Special exception: "send-signal" command does not apply to the mach-* operations,
177 ; so for those we have to use a plain unadorned "deny" instead
178 ; (which means we may not get any notification of unintentional mach-* denials)
180 (deny mach-priv-host-port)
182 ; Mach communications
183 ; These are needed for things like getpwnam, hostname changes, & keychain
184 (allow mach-lookup (global-name
185 "com.apple.bsd.dirhelper"
186 "com.apple.distributed_notifications.2"
188 "com.apple.PowerManagement.control"
189 "com.apple.mDNSResponderHelper"
190 "com.apple.SecurityServer"
191 "com.apple.SystemConfiguration.configd"
192 "com.apple.system.DirectoryService.libinfo_v1"
193 "com.apple.system.DirectoryService.membership_v1"
194 "com.apple.system.notification_center"
195 "com.apple.system.logger"))
197 ; Rules to allow the operations mDNSResponder needs start here
199 (allow signal (target self))
200 (allow network*) ; Allow networking, including Unix Domain Sockets
201 (if (defined? 'system-socket)
202 (allow system-socket)) ; To create raw sockets
203 (allow sysctl-read) ; To get hardware model information
204 (allow file-read-metadata) ; Needed for dyld to work
205 (allow ipc-posix-shm) ; Needed for POSIX shared memory
207 (allow file-read-data (regex #"^/dev/random$"))
208 (allow file-read-data file-write-data (regex #"^/dev/console$")) ; Needed for syslog early in the boot process
209 (allow file-read-data (regex #"^/dev/autofs_nowait$")) ; Used by CF to circumvent automount triggers
211 ; Allow us to read and write our socket
212 (allow file-read* file-write* (regex #"^/private/var/run/mDNSResponder$"))
214 ; Allow us to read system version, settings, and other miscellaneous necessary file system accesses
215 (allow file-read-data (regex #"^/dev/urandom$"))
216 (allow file-read-data (regex #"^/usr/sbin(/mDNSResponder)?$")) ; Needed for CFCopyVersionDictionary()
217 (allow file-read-data (regex #"^/usr/share/icu/.*$"))
218 (allow file-read-data (regex #"^/usr/share/zoneinfo/.*$"))
219 (allow file-read-data (regex #"^/Library/Preferences/SystemConfiguration/preferences\.plist$"))
220 (allow file-read-data (regex #"^/Library/Preferences/SystemConfiguration/com\.apple\.nat\.plist$"))
221 (allow file-read-data (regex #"^/Library/Preferences/(ByHost/)?\.GlobalPreferences.*\.plist$"))
222 (allow file-read-data (regex #"^/Library/Preferences/com\.apple\.security.*\.plist$"))
223 (allow file-read-data (regex #"^/Library/Preferences/com\.apple\.crypto\.plist$"))
224 (allow file-read-data (regex #"^/Library/Security/Trust Settings/Admin\.plist$"))
225 (allow file-read-data (regex #"^/System/Library/CoreServices/SystemVersion.*$"))
226 (allow file-read-data (regex #"^/System/Library/Preferences/com\.apple\.security.*\.plist$"))
227 (allow file-read-data (regex #"^/System/Library/Preferences/com\.apple\.crypto\.plist$"))
228 (allow file-read-data (regex #"^/System/Library/SystemConfiguration/PowerManagement\.bundle(/|$)"))
229 (allow file-read-data (regex #"^/Library/Preferences/SystemConfiguration/com\.apple\.PowerManagement\.plist$"))
231 ; Allow access to System Keychain
232 (allow file-read-data (regex #"^/System/Library/Security$"))
233 (allow file-read-data (regex #"^/System/Library/Keychains/.*$"))
234 (allow file-read-data (regex #"^/Library/Keychains/System\.keychain$"))
235 ; Our Module Directory Services cache
236 (allow file-read-data (regex #"^/private/var/tmp/mds/"))
237 (allow file-read* file-write* (regex #"^/private/var/tmp/mds/[0-9]+(/|$)"))
238 (allow file-read-data (regex #"^/private/var/db/mds/"))
239 (allow file-read* file-write* (regex #"^/private/var/db/mds/[0-9]+(/|$)"))
240 (allow file-read* file-write* (regex #"^/private/var/folders/[^/]+/[^/]+/-Caches-/mds(/|$)"))
241 ; CRL Cache for SSL/TLS connections
242 (allow file-read-data (regex #"^/private/var/db/crls/crlcache\.db$"))