As a developer, I ask how to approach security concerns regarding permissions of a binary which needs access to resources only available to root users.
For example, let's think of a simple tool which creates a virtual device or executes commands which may not be executed by the user opening that application.
The easiest approach of course is to change the owner of the application to root chown root <binary>
and allow everyone to use it chmod 5755 <binary>
. Of course, this is just an invitation for issues like privilege escalations.
How to approach this issue "securely"?
My idea was to create a custom user at the end of the installation process (where the post installation script should have root access anyway) and assign the correct permissions to write to specific directories and execute certain binaries.
- Setup file permissions via
setfacl
- Allow executing certain binaries via
/etc/sudoers
I would then change the application owner to that freshly created user and again allow everybody to execute it, tough this time the application is not bound to root but to a user only having the permission it needs to fulfil its purpose.
Is this the right way, or are there any (perhaps better) alternatives?
Best would be a universal way as not every distribution may ship with selinux, apparmor or polkit even tough those frameworks probably are well suited for such problems. Of course, setting a dependency to one of those could be a possibility.
minisudo 1
,minisudo 2
and so on. Not every operation can be controlled this way, but in my experience, most can.