linux-hardened icon indicating copy to clipboard operation
linux-hardened copied to clipboard

Implement Trusted Path Execution

Open madaidan opened this issue 5 years ago • 2 comments

Trusted Path Execution (TPE) will restrict certain users so they are only able to execute files in root-owned directories writable only by root. This makes it far harder for an attacker to execute their own code.

By default, only users of the "untrusted" group will be under TPE restrictions.

This adds 4 sysctls. fs.tpe to enable/disable TPE, fs.tpe_restrict_all to cover all non-root users under a weaker TPE restriction (they will only be allowed to execute files in directories they own that aren't group/world-writable, or in directories owned by root and writable only by root), fs.tpe_invert to turn the "untrusted" group into a "trusted" group (only users in that group are exempt from the restriction and all other non-root users are restricted) and fs.tpe_gid to configure the GID of the trusted/untrusted group. There are kconfig options to set the defaults of all of these.

This is disabled by default as it could break many of the user's own programs.

This is based on GRKERNSEC_TPE.

madaidan avatar Feb 12 '20 23:02 madaidan

Thanks for the pull-request.

I've only taken a quick look but can't this be easily bypassed with PROT_EXEC memory mappings? By the way, have you looked at past upstream submissions of LSM-based equivalents for grsecurity's TPE, for instance this one?

tsautereau-anssi avatar Feb 17 '20 12:02 tsautereau-anssi

I've only taken a quick look but can't this be easily bypassed with PROT_EXEC memory mappings?

Executable memory mappings are a big issue but I don't think it should be solved in TPE. Other things like PAX_MPROTECT, S.A.R.A. LSM or SELinux's memory protections can solve this by preventing memory mappings from being writable and executable.

By the way, have you looked at past upstream submissions of LSM-based equivalents for grsecurity's TPE, for instance this one?

I've briefly looked over them.

madaidan avatar Feb 17 '20 15:02 madaidan