Network programs are exposed to malicious traffic all day long. Web and FTP servers, peer-to-peer network servers, and chat clients are constantly under attack.
Nobody knows what binary-only executables are really doing. Is notepad phoning home? Even with source, configure scripts can be trojaned and take over a system when you do a “make install” as root.
Most of the other system calls cannot be denied without changing program execution and must be permitted.
native-fsread: true then permit
native-fswrite: filename match "$HOME" then permit
native-fswrite: filename match "/tmp" then permit
native-fsread: filename match "$HOME" then permit
native-fsread: filename match "/home" then deny[eperm]
native-fsread: true then permit
Notice that first matching rule wins.
native-execve: filename match "/bin" then permit
native-execve: filename match "/sbin" then permit
native-execve: filename match "/usr/bin" then permit
native-execve: filename match "/usr/games" then permit
native-execve: filename match "/usr/sbin" then permit
native-execve: filename match "/bin" \
then permit[inherit]
native-execve: filename match "/sbin" \
then permit[inherit]
native-execve: filename match "/usr/bin" \
then permit[inherit]
native-execve: filename match "/usr/games" \
then permit[inherit]
native-execve: filename match "/usr/sbin" \
then permit[inherit]
native-connect: sockaddr match "inet-*:5190" \
then permit
native-connect: sockaddr eq "inet-[127.0.0.1]:53" \
then permit
native-connect: sockaddr match "inet-*:443" \
then permit
native-connect: sockaddr match "inet-*:80" \
then permit
native-connect: sockaddr eq "inet-[127.0.0.1]:53" \
then permit
native-connect: sockaddr eq "inet-*" then ask
native-bind: sockaddr match "inet-*:80" then permit
# systrace -Ai firefox
Policies can be overwhelming if everything were automatically generated.
Sorting clarifies the policy immensely.
I use sort -k1,1 -k4 to sort the policies first by system call,
then by parameter (usually filenames).
Libraries, pathnames, and IP addresses can usually be generalized using globbing rules.
Version control keeps policies from getting out of hand. Every new system call added can be identified easily by diffing the current version with an older version.
We can use the jail facility, found in FreeBSD. This requires installing and configuring the operating system for every jail instance. It also gives attackers the full tool set found in an operating system.
We can use system emulators, such as Xen and VMWare. These also require installing and configuring operating systems for every instance and gives attackers all the tools provided by the operating system. There is also overhead from emulating a machine.
We can use the privilege separation techniques used by OpenBSD to chroot into empty directories and drop all privileges. This requires source code change, which can be very simple or very difficult (look at OpenSSH).