We have an environment where our users ssh into the system and their shell is set to simply launch Mutt on their $HOME/Maildir. We want to restrict our users to only be able to send/receive mail. We realize they can't arbitrary commands since they don't have a shell prompt, but some users may be untrusted and may find some way to break out of Mutt and gain shell access through code execution. We're basically thinking of the worst case scenario. We are aware of SELinux and guest_u accounts but we came across a better solution. Since our users are all part of one group, say "users", we can use the following iptables rule to disable outbound packets. ping, dig, wget, etc do not work but mailing outbound does. This is exactly what we want but why are the users allowed any outbound access at all through Mutt if they are prevented to use the other tools such as dig, host, ping, etc?
Here is the rule we added:
$IPT -A OUTPUT -p all -m owner --gid-owner users -j DROP