Include lots of logging, including date, time, uid and effective uid, gid and effective gid, terminal information, pid, command-line arguments, errors, and originating host. Make the program's critical portion as short and simple as possible. Always use full pathnames for any file arguments. Make good use of tools such as lint. Be aware of race conditions, including deadlock conditions and sequencing conditions.
Place timeouts on outgoing network-oriented write requests.
Use session encryption to avoid session hijacking and hide authentication information. If possible, statically link secure programs. Do reverse DNS lookups on a connection when you need a hostname. Shed or limit excessive loads in network daemons. Put reasonable timeout limits on network reads and writes.