SYSTRACE(1) FreeBSD General Commands Manual SYSTRACE(1) NNAAMMEE ssyyssttrraaccee - generates and enforces system call policies SSYYNNOOPPSSIISS ssyyssttrraaccee [--aaAAiittUU] [--gg _g_u_i] [--ff _f_i_l_e] [--pp _p_i_d] _c_o_m_m_a_n_d _._._. DDEESSCCRRIIPPTTIIOONN The ssyyssttrraaccee utility enforces system call policies for applications by constraining the application's access to the system. The policy is gen- erated interactively. Operations not covered by the policy raise an alarm and allow an user to refine the currently configured policy. The options are as follows: --aa Enables automatic enforcement of configured policies. An opera- tion not covered by policy is denied and logged via syslog(3). --AA Automatically generate a policy that allows every operation the application executes. The created policy functions as a base that can be refined. --ii Inherits the policy of the first executed binary to all chil- dren. --tt Uses text mode to ask for interactive policy generation. --UU Ignore user configured policies and use only global system poli- cies. --gg _g_u_i Specifies an alternative location for the notification user interface. --ff _f_i_l_e The policies specified in _f_i_l_e are added to the policies that ssyyssttrraaccee knows about. --pp _p_i_d Specifies the pid of a process that ssyyssttrraaccee should attach to. The full path name of the corresponding binary has to be speci- fied as _c_o_m_m_a_n_d. PPOOLLIICCYY The policy is specified via the following grammar: filter = expression "then" action errorcode expression = symbol | "not" expression | "(" expression ")" | expression "and" expression | expression "or" expression symbol = string typeoff "match" cmdstring | string typeoff "eq" cmdstring | string typeoff "neq" cmdstring | string typeoff "sub" cmdstring | string typeoff "nsub" cmdstring | string typeoff "inpath" cmdstring | "true" typeoff = /* empty */ | "[" number "]" action = "permit" | "deny" errorcode = /* empty */ | "[" string "]" The _c_m_d_s_t_r_i_n_g is an arbitrary string enclosed with quotation marks. The _e_r_r_o_r_c_o_d_e is used to return an errno(2) value to the system call when using a _d_e_n_y action. The value ``inherit'' has a special meaning when used with a _p_e_r_m_i_t rule for the _e_x_e_c_v_e system call. In that case, the current policy is inherited for the new binary. The filter operations have the following meaning: match Evaluates to true if file name globbing according to fnmatch(3) succeeds. eq Evaluates to true if the system call argument matches _c_m_d_s_t_r_i_n_g exactly. neq This is the logical negation of _e_q. sub Performs a substring match on the system call argument. nsub This is the logical negation of _s_u_b. inpath Evaluates to true if the system call argument is a subpath of _c_m_d_s_t_r_i_n_g. Policy entries may contain an appended predicate. Predicates have the following format: ", if" {"user", "group"} {"=", "!="} string A rule is added to the configured policy only if its predicate evaluates to true. EEXXAAMMPPLLEESS An excerpt from a sample ls(1) policy might look as follows: Policy: /bin/ls, Emulation: native [...] native-open: filename eq "$HOME" and oflags sub "ro" then permit native-fchdir: permit [...] native-open: filename eq "/tmp" and oflags sub "ro" then permit native-stat: permit native-open: filename match "$HOME/*" and oflags sub "ro" then permit native-open: filename eq "/etc/pwd.db" and oflags sub "ro" then permit [...] native-open: filename eq "/etc" then deny[eperm], if group != wheel FFIILLEESS /dev/systrace systrace device /etc/systrace global systrace policies $HOME/.systrace user specified policies SSEEEE AALLSSOO systrace(4) BBUUGGSS Applications that use clone()-like system calls to share the complete address space between processes may be able to replace system call argu- ments after they have been evaluated by ssyyssttrraaccee and escape policy enforcement. AAUUTTHHOORRSS The ssyyssttrraaccee utility has been developed by Niels Provos. FreeBSD 4.5 June 3, 2002 FreeBSD 4.5