Skip to content

Truly independent web browser

LibSandbox: Let macOS helpers ask to use UDP and nothing else

Ali Mohammad Pur2cfa3588c707
diff --git a/Libraries/LibSandbox/Sandbox.cpp b/Libraries/LibSandbox/Sandbox.cpp
index 1fe0a424ad2..d4ade3aa298 100644
--- a/Libraries/LibSandbox/Sandbox.cpp
+++ b/Libraries/LibSandbox/Sandbox.cpp
@@ -723,6 +723,25 @@ ErrorOr<void> apply_macos_sandbox(SeatbeltProfile const& options)
)~~~"sv));
}
+ if (options.network_access == NetworkAccess::Datagrams) {
+ TRY(profile.try_append(R"~~~(
+; Exchange datagrams with peers from UDP sockets that the helper binds itself, at the addresses of the local interfaces
+; that getifaddrs() lists. The mDNS responder shares its port with the system's.
+(allow network-outbound
+ (remote udp))
+(allow network-bind
+ (local udp))
+(allow network-inbound
+ (local udp))
+(allow syscall-unix
+ (syscall-number SYS_bind))
+(allow system-info
+ (info-type "net.link.addr"))
+(allow sysctl-read
+ (sysctl-name-prefix "net.routetable."))
+)~~~"sv));
+ }
+
TRY(append_allowed_paths(profile, "file-read* file-test-existence"sv, options.paths, SeatbeltPath::Access::ReadOnly));
TRY(append_allowed_ancestor_directories(profile, options.paths));
TRY(append_allowed_paths(profile, "file-map-executable"sv, options.paths, SeatbeltPath::Access::ReadAndExecute));
diff --git a/Libraries/LibSandbox/Sandbox.h b/Libraries/LibSandbox/Sandbox.h
index dfe4ac08c1c..c3885af9e50 100644
--- a/Libraries/LibSandbox/Sandbox.h
+++ b/Libraries/LibSandbox/Sandbox.h
@@ -47,6 +47,8 @@ struct SeatbeltPath {
enum class NetworkAccess {
Denied,
Allowed,
+ // Only UDP datagrams, sent to any host and received on sockets the helper binds itself, as ICE and mDNS need.
+ Datagrams,
};
// System services that a helper may use, in addition to its own Browser endpoint.