I had a question arise about how installing from source code in the root account is not a good idea because of security reasons.

My stance on it is that it does not really matter if someone is in root account, starting from untarring the code then performing the steps to install it.

#make install

as opposed to:

$sudo make install

My logic is: it does not really matter because if it is going to cause a security risk it is because of the code itself, and not how one installs it because end command uses root to install the final binary and any files that it installs along with it.

Regardless if one is in a not root user session or not, if the source code has malware encoded into its source then it is now in the system no matter what. Therefore, it is always a risk no matter what.

This has nothing to do with one's own code, it is more to do with one's repo it does not have an app included within it, therefore, go to git hub or the persons website that wrote it and use the source code to get it installed. Something as simple as installing tree even.

The user then be more worried about how he came about the source code more then if he or she is logged into root account or a "normal" user account.

I already have heard all of the arguments about why one should not use root, because of lack of paying attention to what they are writing in the terminal can cause irreversible damage to the system; one can do just as much damage using sudo therefore that in itself is a redundant argument, and belief system. Therefore, it is not even to be part of the point that is included in this argument.

This is a more or less an yes or no question. Yes -- I am right it does not matter in a long run if one is using their root account to compile and install source code apps into the system, or not.


No -- I am wrong, it matters because you have to use root privileges in order to do the same.

  • 1
    I usually try to read some of the source, if time and size permits....moreover so in the very rare occasions when getting them from questionable sources (for instance, exploits). – Rui F Ribeiro Feb 11 '16 at 13:14

If you overuse running programs as root, then you give a potential attacker more spots to attack you than just the "necessary" ones. Attempts to compromise your system mostly won't work (or will be more difficult) without root privilege. Your approach with all commands as root can also lead to simply doing everything as root (listing a directory, opening an image, playing music ...) and that means many potentially problematic spots.

Even unintentionally - a bug in a program that you run can do much more damage when run as root (and it is practically impossible to remove all bugs from SW). Or when user inputs incorrect options (much more probable possibility).

Additionally when you ./configure and make, you might not want to install the program for everyone (could be a library that only you need e.g.).

| improve this answer | |
  • sticking to the point: just installing software from extracting tar ball to the three steps to get it installed only as root, really does not present a security issue. yes - no? – uxserx-bw Feb 11 '16 at 14:04
  • 2
    @userx-bw It's not a yes or no question, without more info. System configuration, user behavior, and existence of other malicious or unwanted code factor in to the question. Security IS NOT a binary state. It is a methodology, a mind set, a way of considering the risks and acting accordingly. – 0xSheepdog Feb 11 '16 at 17:14

If you suspect that the program you're installing may be malicious, don't execute it as root or as your usual user. This includes both executing the compiled program and running the supplied build scripts. Once an attacker has run code as you, they own your account (and they'll own your machine as soon as you gain root from that account, at the latest). It doesn't matter whether the attacker's code was executed because you ran make or because you ran make install.

The point of building as your usual user and installing as root is to reduce the risks of accidental problems. Even so, you should typically not install self-built programs as root unless that's necessary (e.g. to install a driver or system service). Install as your own user, into a separate directory, and then use a program such as stow to make the program available in standard directories (/usr/local/bin, etc.). This reduces the risk that the installation step will overwrite existing software (there could be a naming collision) or will write in unintended directories, and makes it easy to uninstall the program since all the files are in one place.

| improve this answer | |
  • Modern GNU style configure/build offers an uninstall target. But that requires keeping the configured source around... – vonbrand Feb 12 '16 at 19:41
  • @vonbrand And it doesn't restore files overwritten during the installation, does it? – Gilles 'SO- stop being evil' Feb 12 '16 at 19:46
  • not as far as I know (or would be reasonable, for that matter) – vonbrand Feb 12 '16 at 22:19

As user joe,

sudo make install

You don't usually need to be root to configure or compile the code, only to install it. If you don't need to be root, then don't be root.

Both configure and make are executing code. Running them as root when you don't need to just introduces another attack vector (someone might be able to compromise the makefile, but not the source code, for example).

| improve this answer | |
  • you're missing the point too. that is not the argument. it is pure logical yes or no question. to get to your next commant, it is within the code that one can get in, be it source, or make file source, if you check make first it will eliminate this chance you stated as introdusing another vector. – uxserx-bw Feb 11 '16 at 17:23
  • 1
    @uxserx-bw then your question isn't clear. If multiple people 'misunderstand you', perhaps you need to clarify what you're asking. My point is that if you don't need to be root, don't be root. – EightBitTony Feb 12 '16 at 8:42

The final program (and it's installation) are presumably more carefully done than the building. Any mistake in the building process or finishing sanity checks, when running as root, can hose your system. Better reduce the risk as much as possible.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.