## Copyright (C) 2012 - 2022 ENCRYPTED SUPPORT LP <adrelanos@whonix.org>
## See the file COPYING for copying conditions.

## Please use "/etc/permission-hardening.d/20_user.conf" or
## "/usr/local/etc/permission-hardening.d/20_user.conf" for your custom
## configuration. When security-misc is updated, this file may be overwritten.

## File permission hardening.
##
## Syntax:
## [filename] [mode] [owner] [group] [capability]
##
## To remove all SUID/SGID binaries in a directory, you can use the "nosuid"
## argument.

## TODO: white spaces inside file name untested and probably will not work.

######################################################################
# Global Settings
######################################################################

#whitelists_disable_all=true

######################################################################
# SUID disablewhitelist
######################################################################

## disablewhitelist disables below (or in lexically higher) files
## exactwhitelist and matchwhitelist. Add these here (discouraged) or better
## in file "/etc/permission-hardening.d/20_user.conf".

## For example, if you are not using SELinux the following might make sense to
## enable. TODO: research
#/utempter/utempter disablewhitelist

## If you are not going to use AppImages such as electrum Bitcoin wallet.
#/fusermount disablewhitelist

######################################################################
# SUID exact match whitelist
######################################################################

## In case you need to use 'su'. See also:
## https://www.kicksecure.com/wiki/root#su
#/bin/su exactwhitelist
#/usr/bin/su exactwhitelist

######################################################################
# SUID exact match whitelist
######################################################################

## https://manpages.debian.org/xserver-xorg-legacy/Xorg.wrap.1.en.html
## https://lwn.net/Articles/590315/
## http://forums.whonix.org/t/permission-hardening/8655/25
#/usr/lib/xorg/Xorg.wrap whitelist

######################################################################
# SUID regex match whitelist
######################################################################

######################################################################
# SUID regex match whitelist
######################################################################

######################################################################
# Permission Hardening
######################################################################

/home/ 0755 root root
/home/user/ 0700 user user
/root/ 0700 root root
/boot/ 0700 root root
/etc/permission-hardening.d 0600 root root
/usr/local/etc/permission-hardening.d 0600 root root
/lib/modules/ 0700 root root

######################################################################
# SUID/SGID Removal
######################################################################

## Remove all SUID/SGID binaries/libraries.

/bin/ nosuid
/usr/local/bin/ nosuid

/usr/bin/ nosuid
/usr/local/usr/bin/ nosuid

/sbin/ nosuid
/usr/local/sbin/ nosuid

/usr/sbin/ nosuid
/usr/local/usr/sbin/ nosuid

/lib/ nosuid
/usr/local/lib/ nosuid

/lib32/ nosuid
/usr/local/lib32/ nosuid

/lib64/ nosuid
/usr/local/lib64/ nosuid

/usr/lib/ nosuid
/usr/local/usr/lib/ nosuid

/usr/lib32/ nosuid
/usr/local/usr/lib32/ nosuid

/usr/lib64/ nosuid
/usr/local/usr/lib64/ nosuid

## https://forums.whonix.org/t/suid-disabler-and-permission-hardener/7706/68
/opt/ nosuid
/usr/local/opt/ nosuid

######################################################################
# Capability Removal
######################################################################

## Ping doesn't work with Tor anyway so its capabilities are removed to
## reduce attack surface.
## anon-apps-config does this.
#/bin/ping 0744 root root none

## TODO: research
#/usr/lib/x86_64-linux-gnu/gstreamer1.0/grstreamer-1.0/gst-ptp-helper 0744 root root none