Changeset 286003 in webkit
- Timestamp:
- Nov 18, 2021, 7:52:42 AM (5 years ago)
- Location:
- trunk/Source/WebKit
- Files:
-
- 2 edited
-
ChangeLog (modified) (1 diff)
-
NetworkProcess/mac/com.apple.WebKit.NetworkProcess.sb.in (modified) (22 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebKit/ChangeLog
r285996 r286003 1 2021-11-18 Per Arne Vollan <pvollan@apple.com> 2 3 [macOS] Block access to unused resources in the Networking process' sandbox 4 https://bugs.webkit.org/show_bug.cgi?id=233086 5 <rdar://problem/85376544> 6 7 Reviewed by Brent Fulgham. 8 9 Based on telemetry, block access to unused resources in the Networking process' sandbox on macOS. 10 11 * NetworkProcess/mac/com.apple.WebKit.NetworkProcess.sb.in: 12 1 13 2021-10-25 Carlos Garcia Campos <cgarcia@igalia.com> 2 14 -
trunk/Source/WebKit/NetworkProcess/mac/com.apple.WebKit.NetworkProcess.sb.in
r285412 r286003 39 39 #include "Shared/Sandbox/preferences.sb" 40 40 41 ;; Utility functions for home directory relative path filters 42 (define (home-regex home-relative-regex) 43 (regex (string-append "^" (regex-quote (param "HOME_DIR")) home-relative-regex))) 44 45 (define (home-subpath home-relative-subpath) 46 (subpath (string-append (param "HOME_DIR") home-relative-subpath))) 47 48 (define (home-literal home-relative-literal) 49 (literal (string-append (param "HOME_DIR") home-relative-literal))) 50 41 51 #if PLATFORM(MAC) 42 ;;; 43 ;;; The following rules were originally contained in 'common.sb'. We are duplicating them here so we can 44 ;;; remove unneeded sandbox extensions. 45 ;;; 46 47 (allow mach-register (with telemetry) (local-name-prefix "")) 48 49 (allow mach-lookup (with telemetry) (xpc-service-name-prefix "")) 52 (deny mach-register (with telemetry) (local-name-prefix "")) 50 53 51 54 (allow system-automount … … 53 56 54 57 (allow file-map-executable (with telemetry)) 55 (allow file-map-executable (with telemetry)56 (subpath "/Library/Apple/System/Library/Frameworks")57 (subpath "/Library/Apple/System/Library/PrivateFrameworks")58 (subpath "/System/Library/Frameworks")59 (subpath "/System/Library/PrivateFrameworks")60 (subpath "/usr/lib")61 (subpath "/usr/local/lib/sanitizers") ;; FIXME(209820)62 (subpath "/usr/appleinternal/lib") ;; <rdar://problem/72317112>63 )58 (allow file-map-executable 59 (home-subpath "/Library/Caches") 60 (home-subpath "/Library/Containers") 61 (subpath (param "DARWIN_USER_TEMP_DIR")) 62 (subpath "/Library/KerberosPlugins") 63 (subpath "/System/Library/Frameworks") 64 (subpath "/System/Library/KerberosPlugins") 65 (subpath "/System/Library/PrivateFrameworks") 66 (subpath "/usr/lib")) 64 67 65 68 (allow file-read-metadata 66 (literal "/var")) 67 (allow file-read-metadata (with telemetry) 68 (literal "/etc") 69 (literal "/tmp") 70 (literal "/private/etc/localtime")) 69 (literal "/etc") 70 (literal "/tmp") 71 (literal "/var") 72 (literal "/private/etc/localtime")) 71 73 72 74 (allow file-read-metadata (with telemetry) (path-ancestors "/System/Volumes/Data/private")) … … 77 79 (subpath "/System")) 78 80 79 (allow file-read* (with telemetry) 80 (subpath "/Library/Apple/System") 81 (subpath "/Library/Filesystems/NetFSPlugins") 81 (allow file-read* 82 82 (subpath "/Library/Preferences/Logging") ; Logging Rethink 83 83 #if __MAC_OS_X_VERSION_MIN_REQUIRED < 110000 … … 88 88 (subpath "/usr/share")) 89 89 90 (allow file-read* (with telemetry) 91 (literal "/dev/autofs_nowait") 92 (literal "/dev/random") 90 (allow file-read* 93 91 (literal "/dev/urandom") 94 92 (literal "/private/etc/master.passwd") 95 93 (literal "/private/etc/passwd") 96 (literal "/private/etc/protocols")97 94 (literal "/private/etc/services")) 98 95 99 (allow file-read* (with telemetry) 100 file-write-data 101 (literal "/dev/null") 102 (literal "/dev/zero")) 103 104 (allow file-read* (with telemetry) 105 file-write-data 106 file-ioctl 96 (allow file-read* file-write-data file-ioctl 107 97 (literal "/dev/dtracehelper")) 108 98 109 (allow file-read* (with telemetry) 110 (subpath "/usr/local/lib/sanitizers") ;; FIXME(209820) 111 (subpath "/usr/appleinternal/lib") ;; <rdar://problem/72317112> 112 ) 113 114 (allow file-write-create (with telemetry) 115 (require-all (prefix "/cores/") 116 (vnode-type REGULAR-FILE))) 117 118 (allow file-read* (with telemetry) 99 (allow file-read* 119 100 (require-all (subpath "/AppleInternal/Library/Preferences/Logging") 120 101 (system-attribute apple-internal))) 121 102 122 (allow file-read* file-map-executable (with telemetry) 123 (require-all (subpath "/usr/local/lib/log") 124 (system-attribute apple-internal))) 125 126 (allow network-outbound (with telemetry) 103 (allow network-outbound 127 104 (literal "/private/var/run/syslog")) 128 105 129 (allow ipc-posix-shm-read* (with telemetry) 130 (ipc-posix-name "apple.shm.notification_center") 131 (ipc-posix-name-prefix "apple.cfprefs.")) 132 133 (allow mach-lookup (with telemetry) 106 (allow ipc-posix-shm-read* 107 (ipc-posix-name "apple.shm.notification_center") 108 #if !ENABLE(CFPREFS_DIRECT_MODE) 109 (ipc-posix-name-prefix "apple.cfprefs.") 110 #endif 111 ) 112 113 (allow mach-lookup 134 114 (global-name "com.apple.system.opendirectoryd.libinfo") 135 115 (global-name "com.apple.trustd.agent")) … … 139 119 (global-name "com.apple.trustd"))) 140 120 141 (with-filter (system-attribute apple-internal)142 (allow mach-lookup (with telemetry) (global-name "com.apple.internal.objc_trace")))143 144 121 (define (system-network) 145 (allow file-read* (with telemetry)122 (allow file-read* 146 123 (literal "/Library/Preferences/com.apple.networkd.plist") 147 124 (literal "/private/var/db/nsurlstoraged/dafsaData.bin")) 148 ( allowmach-lookup (with telemetry)125 (deny mach-lookup (with telemetry) 149 126 (global-name "com.apple.SystemConfiguration.PPPController") 150 127 (global-name "com.apple.SystemConfiguration.SCNetworkReachability") 128 (global-name "com.apple.networkd") 129 (global-name "com.apple.nsurlstorage-cache") 130 (global-name "com.apple.symptomsd")) 131 (allow mach-lookup 151 132 (global-name "com.apple.dnssd.service") 152 133 (global-name "com.apple.nehelper") 153 134 (global-name "com.apple.nesessionmanager") 154 (global-name "com.apple.networkd")155 (global-name "com.apple.nsurlstorage-cache")156 (global-name "com.apple.symptomsd")157 135 (global-name "com.apple.usymptomsd")) 158 (allow network-outbound (with telemetry) 159 (control-name "com.apple.netsrc") 160 (control-name "com.apple.network.statistics")) 161 (allow system-socket (with telemetry) 136 (allow network-outbound 137 (control-name "com.apple.netsrc")) 138 (deny system-socket (with telemetry) 139 (socket-domain AF_ROUTE)) 140 (allow system-socket 162 141 (require-all (socket-domain AF_SYSTEM) 163 (socket-protocol 2)) ; SYSPROTO_CONTROL 164 (socket-domain AF_ROUTE)) 165 (allow mach-lookup (with telemetry) 142 (socket-protocol 2))) ; SYSPROTO_CONTROL 143 (allow mach-lookup 166 144 (global-name "com.apple.AppSSO.service-xpc")) 167 ( allowipc-posix-shm-read-data (with telemetry)145 (deny ipc-posix-shm-read-data (with telemetry) 168 146 (ipc-posix-name "/com.apple.AppSSO.version"))) 169 170 ;;;171 ;;; End rules originally copied from 'system.sb'172 ;;;173 147 #else 174 148 (import "system.sb") … … 181 155 (allow process-info-setcontrol (target self)) 182 156 183 (deny sysctl* )184 (allow sysctl-read (with telemetry)157 (deny sysctl* (with telemetry)) 158 (allow sysctl-read 185 159 (sysctl-name 186 "hw.activecpu" ;; <rdar://problem/56795575>187 "hw.availcpu"188 "hw.cacheconfig" ;; <rdar://problem/78213563>189 "hw.cachelinesize" ;; <rdar://problem/56795575>190 "hw.cachesize" ;; <rdar://problem/78213563>191 "hw.cpusubfamily"192 "hw.cputhreadtype"193 "hw.l1dcachesize" ;; <rdar://problem/56795575>194 "hw.l1icachesize" ;; <rdar://problem/56795575>195 "hw.l2cachesize" ;; <rdar://problem/56795575>196 "hw.l3cachesize" ;; <rdar://problem/56795575>197 "hw.logicalcpu" ;; <rdar://problem/56795575>198 "hw.logicalcpu_max" ;; <rdar://problem/56795575>199 160 "hw.memsize" 200 "hw.model" ;; Needed for bundle loading201 161 "hw.ncpu" 202 "hw.nperflevels" ;; <rdar://problem/76783596>203 "hw.pagesize" ;; <rdar://problem/76783596>204 "hw.pagesize_compat" ;; <rdar://problem/76783596>205 "hw.physicalcpu" ;; <rdar://problem/58416475>206 "hw.physicalcpu_max" ;; <rdar://problem/58416475>207 "hw.physmem" ;; <rdar://problem/76782530>208 "kern.hostname"209 "kern.hv_vmm_present"210 162 "kern.maxfilesperproc" 211 "kern.memorystatus_level"212 163 "kern.osproductversion" ;; Needed by CFNetwork (HSTS store and others) 164 "kern.ostype" 213 165 "kern.osversion" ;; Needed by WebKit and ASL logging. 214 166 "kern.tcsm_available" ;; Needed for IndexedDB support. 215 "kern.tcsm_enable" 216 "kern.ostype" 217 "kern.version" 218 "sysctl.name2oid" 219 "vm.footprint_suspend") 167 "kern.tcsm_enable") 220 168 (sysctl-name-prefix "kern.proc.pid.") 221 (sysctl-name-prefix "net.routetable") 222 (sysctl-name-prefix "hw.optional.") ;; <rdar://problem/71462790> 223 (sysctl-name-prefix "hw.perflevel") ;; <rdar://problem/76783596> 224 ) 225 226 (allow sysctl-write (with telemetry) 169 (sysctl-name-prefix "net.routetable")) 170 171 (allow sysctl-write 227 172 (sysctl-name 228 173 "kern.tcsm_enable")) … … 247 192 (deny mach-lookup (xpc-service-name-prefix "")) 248 193 249 ;; Utility functions for home directory relative path filters250 (define (home-regex home-relative-regex)251 (regex (string-append "^" (regex-quote (param "HOME_DIR")) home-relative-regex)))252 253 (define (home-subpath home-relative-subpath)254 (subpath (string-append (param "HOME_DIR") home-relative-subpath)))255 256 (define (home-literal home-relative-literal)257 (literal (string-append (param "HOME_DIR") home-relative-literal)))258 259 ;; CFNetwork260 (allow file-read-data (with telemetry) (path "/private/var/db/nsurlstoraged/dafsaData.bin"))261 262 194 ;; Remove when <rdar://problem/29646094> is fixed. 263 195 (define (HEX-pattern-match-generator pattern-descriptor) … … 296 228 "com.apple.networkConnect") 297 229 298 (allow file-read* (with telemetry)230 (allow file-read* 299 231 ;; Basic system paths 300 232 (subpath "/Library/Frameworks") 301 233 (subpath "/Library/Managed Preferences") 302 234 303 ;; System and user preferences304 (regex #"^/Library/Managed Preferences/[^/]+/com\.apple\.networkConnect\.plist$")305 306 235 ;; On-disk WebKit2 framework location, to account for debug installations 307 236 ;; outside of /System/Library/Frameworks 308 237 (subpath (param "WEBKIT2_FRAMEWORK_DIR"))) 309 (allow system-fsctl (with telemetry) (fsctl-command (_IO "h" 47))) 310 311 (allow file-read-data (with telemetry) 238 239 (allow file-read-data 312 240 (literal "/usr/local/lib/log") ; <rdar://problem/36629495> 313 241 ) … … 315 243 ;; Sandbox extensions 316 244 (define (apply-read-and-issue-extension op path-filter) 317 (op file-read* (with telemetry)path-filter)245 (op file-read* path-filter) 318 246 (op file-issue-extension (require-all (extension-class "com.apple.app-sandbox.read") path-filter))) 319 247 (define (apply-write-and-issue-extension op path-filter) 320 (op file-write* (with telemetry)path-filter)248 (op file-write* path-filter) 321 249 (op file-issue-extension (require-all (extension-class "com.apple.app-sandbox.read-write") path-filter))) 322 250 (define (read-only-and-issue-extensions path-filter) … … 328 256 (read-write-and-issue-extensions (extension "com.apple.app-sandbox.read-write")) 329 257 330 (allow file-read* file-write* ( with telemetry) (subpath (param "DARWIN_USER_CACHE_DIR")))331 332 (allow file-read* file-write* ( with telemetry) (subpath (param "DARWIN_USER_TEMP_DIR")))258 (allow file-read* file-write* (subpath (param "DARWIN_USER_CACHE_DIR"))) 259 260 (allow file-read* file-write* (subpath (param "DARWIN_USER_TEMP_DIR"))) 333 261 334 262 ;; IOKit user clients 335 (allow iokit-open (with telemetry)263 (allow iokit-open 336 264 (iokit-user-client-class "RootDomainUserClient") ; Used by PowerObserver 337 265 ) 338 266 339 ;; cookied. 340 ;; FIXME: Update for <rdar://problem/13642852>. 341 (allow ipc-posix-shm-read-data (with telemetry) 342 (ipc-posix-name "FNetwork.defaultStorageSession") 343 (ipc-posix-name-regex #"\.PrivateBrowsing-") 344 (ipc-posix-name-prefix "^WebKit Test-") 345 (ipc-posix-name "/com.apple.AppSSO.version") 346 ) 267 (deny mach-lookup (with telemetry) 268 (global-name "com.apple.PowerManagement.control")) 347 269 348 270 ;; Various services required by CFNetwork and other frameworks 349 (allow mach-lookup (with telemetry)271 (allow mach-lookup 350 272 (global-name "com.apple.FileCoordination") 351 (global-name "com.apple.PowerManagement.control")352 273 (global-name "com.apple.SystemConfiguration.configd") 353 (global-name "com.apple.cookied")354 274 (global-name "com.apple.cfnetwork.AuthBrokerAgent") 355 275 (global-name "com.apple.cfnetwork.cfnetworkagent") 276 #if __MAC_OS_X_VERSION_MIN_REQUIRED < 120000 277 (global-name "com.apple.cookied") 278 #endif 356 279 (global-name "com.apple.ist.ds.appleconnect2.service.kdctunnelcontroller") 357 280 (global-name "com.apple.logd") … … 360 283 (global-name "com.apple.nesessionmanager.flow-divert-token") 361 284 (global-name "com.apple.nesessionmanager.content-filter") ;; <rdar://problem/47598758> 362 (global-name "com.apple.system.notification_center") 363 (global-name "com.apple.AppSSO.service-xpc") 364 ) 285 (global-name "com.apple.system.notification_center")) 365 286 366 287 (with-filter (system-attribute apple-internal) … … 382 303 ) 383 304 305 (deny mach-lookup (with telemetry) 306 (global-name "com.apple.ctkd.token-client") 307 (global-name "com.apple.securityd.xpc") 308 (global-name "com.apple.CoreAuthentication.agent") 309 (global-name "com.apple.ocspd")) 310 384 311 ;; Security framework 385 (allow mach-lookup (with telemetry) 386 (global-name "com.apple.ctkd.token-client") 387 (global-name "com.apple.securityd.xpc") 388 (global-name "com.apple.CoreAuthentication.agent") 389 (global-name "com.apple.ocspd") 390 (global-name "com.apple.SecurityServer")) 312 (allow mach-lookup 313 (global-name "com.apple.SecurityServer")) 391 314 392 315 ;; FIXME: This should be removed when <rdar://problem/10479685> is fixed. 393 316 ;; Restrict AppSandboxed processes from creating /Library/Keychains, but allow access to the contents of /Library/Keychains: 394 (allow file-read-data file-read-metadata file-write* (with telemetry)317 (allow file-read-data file-read-metadata 395 318 (subpath "/Library/Keychains") 396 319 (home-subpath "/Library/Keychains")) … … 401 324 (home-regex (string-append "/Library/Keychains/" (uuid-regex-string) "(/|$)"))) 402 325 403 (allow file-read* ( with telemetry) (subpath "/private/var/db/mds/system")) ;; FIXME: This should be removed when <rdar://problem/9538414> is fixed.326 (allow file-read* (subpath "/private/var/db/mds/system")) ;; FIXME: This should be removed when <rdar://problem/9538414> is fixed. 404 327 (with-filter (uid 0) 405 328 (allow file-write* (with telemetry) … … 413 336 "com.apple.security.revocation") 414 337 415 (allow file-read* (with telemetry)338 (allow file-read* 416 339 (subpath "/private/var/db/mds") 417 (literal "/private/var/db/DetachedSignatures")418 340 419 341 ; The following are needed until the causes of <rdar://problem/41487786> are resolved. 420 342 (literal "/Library/Preferences/com.apple.security.plist") 421 (literal "/Library/Preferences/com.apple.security.common.plist")422 (literal "/Library/Preferences/com.apple.security.revocation.plist")423 (home-literal "/Library/Application Support/SyncServices/Local/ClientsWithChanges/com.apple.Keychain")424 343 (home-literal "/Library/Preferences/com.apple.security.plist") 425 (home-literal "/Library/Preferences/com.apple.security.revocation.plist")426 344 427 345 ; Likewise for <rdar://problem/43310000> … … 434 352 ) 435 353 436 (allow ipc-posix-shm-read* ipc-posix-shm-write-create ipc-posix-shm-write-data (with telemetry)354 (allow ipc-posix-shm-read* ipc-posix-shm-write-create ipc-posix-shm-write-data 437 355 (ipc-posix-name "com.apple.AppleDatabaseChanged")) 438 356 439 357 (system-network) 440 (allow network-outbound (with telemetry)358 (allow network-outbound 441 359 ;; Local mDNSResponder for DNS, arbitrary outbound TCP 442 360 (literal "/private/var/run/mDNSResponder") … … 444 362 445 363 ;; FIXME should be removed when <rdar://problem/9347205> + related radar in Safari is fixed 446 (allow mach-lookup (with telemetry)364 (allow mach-lookup 447 365 (global-name "org.h5l.kcm") 448 366 (global-name "com.apple.GSSCred") 449 (global-name "com.apple.ist.ds.appleconnect.service.kdctunnel") ;; Remove after <rdar://problem/35542803> ships 450 (global-name "com.apple.system.logger")) 367 (global-name "com.apple.ist.ds.appleconnect.service.kdctunnel")) ;; Remove after <rdar://problem/35542803> ships 451 368 (allow network-outbound (with telemetry) 452 369 (remote udp)) … … 455 372 "com.apple.Kerberos" 456 373 "edu.mit.Kerberos") 457 (allow file-read* (with telemetry) 458 (literal "/private/etc/krb5.conf") 374 (allow file-read* 459 375 (literal "/private/etc/services") 460 376 (literal "/private/etc/hosts") … … 514 430 515 431 ;; For reporting progress for active downloads <rdar://problem/44405661> 516 (allow mach-lookup (with telemetry)432 (allow mach-lookup 517 433 (global-name "com.apple.ProgressReporting")) 518 434 519 435 ;; Needed for TCC. 520 (allow mach-lookup (with telemetry)436 (allow mach-lookup 521 437 (global-name "com.apple.tccd")) 522 438 523 (allow file-read* file-write* (with telemetry)439 (allow file-read* file-write* 524 440 (home-subpath "/Library/HTTPStorages")) 525 441 526 (allow file-read* (with telemetry) 527 (prefix "/private/var/db/com.apple.networkextension.") 528 ) 442 (allow file-read* 443 (prefix "/private/var/db/com.apple.networkextension.")) 529 444 530 445 (when (defined? 'syscall-unix) … … 532 447 (allow syscall-unix (syscall-number 533 448 SYS___channel_get_info 449 SYS___channel_open 534 450 SYS___channel_sync 535 451 SYS___disable_threadsignal 536 452 SYS___mac_syscall 453 SYS___pthread_sigmask 454 SYS___semwait_signal 537 455 SYS_access 538 456 SYS_bsdthread_create … … 541 459 SYS_change_fdguard_np 542 460 SYS_csrctl 461 SYS_dup 462 SYS_exit 543 463 SYS_fcntl 544 464 SYS_fcntl_nocancel 465 SYS_fgetattrlist 466 SYS_fileport_makeport 467 SYS_flock 545 468 SYS_fsgetpath 546 469 SYS_fstat 470 SYS_fstat64 547 471 SYS_fstatat 472 SYS_fstatat64 548 473 SYS_fstatfs 474 SYS_fstatfs64 549 475 SYS_fsync 550 476 SYS_ftruncate … … 552 478 SYS_getaudit_addr 553 479 SYS_getdirentries 480 SYS_getdirentries64 481 SYS_getegid 554 482 SYS_getentropy 555 483 SYS_geteuid 556 484 SYS_getfsstat 485 SYS_getfsstat64 486 SYS_getgid 487 SYS_getgroups 488 SYS_getpeername 557 489 SYS_getrlimit 490 SYS_getsockname 491 SYS_getsockopt 492 SYS_gettid 558 493 SYS_gettimeofday 559 494 SYS_getuid 495 SYS_getxattr 560 496 SYS_guarded_close_np 497 SYS_guarded_open_dprotected_np 561 498 SYS_guarded_open_np 562 499 SYS_guarded_pwrite_np 563 500 SYS_iopolicysys 564 501 SYS_issetugid 502 SYS_kdebug_trace64 503 SYS_kdebug_trace_string 504 SYS_kdebug_typefilter 505 SYS_kevent 565 506 SYS_kevent_id 566 507 SYS_kevent_qos 508 SYS_kqueue 509 SYS_listxattr 567 510 SYS_lseek 568 511 SYS_lstat 512 SYS_lstat64 513 SYS_lstat64_extended 569 514 SYS_madvise 515 SYS_memorystatus_control 516 SYS_mkdir 570 517 SYS_mkdirat 571 518 SYS_mmap … … 575 522 SYS_necp_client_action 576 523 SYS_necp_open 524 SYS_open_dprotected_np 577 525 SYS_pathconf 526 SYS_pipe 578 527 SYS_pread 579 528 SYS_pread_nocancel 529 SYS_pselect 580 530 SYS_psynch_cvbroad 531 SYS_psynch_cvclrprepost 581 532 SYS_psynch_cvsignal 582 533 SYS_psynch_cvwait 583 534 SYS_psynch_mutexdrop 584 535 SYS_psynch_mutexwait 536 SYS_psynch_rw_rdlock 585 537 SYS_psynch_rw_unlock 586 538 SYS_psynch_rw_wrlock 587 539 SYS_read 540 SYS_read_nocancel 541 SYS_readlink 542 SYS_recvfrom 543 SYS_recvfrom_nocancel 544 SYS_recvmsg 545 SYS_rename 588 546 SYS_rmdir 589 547 SYS_select 548 SYS_select_nocancel 549 SYS_sendmsg 550 SYS_sendmsg_nocancel 551 SYS_sendto 552 SYS_sendto_nocancel 590 553 SYS_setattrlistat 591 554 SYS_setrlimit 555 SYS_setsockopt 556 SYS_shutdown 557 SYS_sigaltstack 558 SYS_socketpair 592 559 SYS_stat 560 SYS_stat64 561 SYS_stat64_extended 593 562 SYS_statfs 563 SYS_statfs64 594 564 SYS_thread_selfid 595 565 SYS_ulock_wait
Note:
See TracChangeset
for help on using the changeset viewer.