After a large number of customer configuration audits and penetration tests, we have summarized some common configuration errors in Linux. We believe that summary and review of these common errors can save us more time and resources in the future. More importantly, they can help the system administrator, the server is more audited and tested by a large number of customers. we have summarized some common configuration errors in Linux. We believe that summary and review of these common errors can save us more time and resources in the future. More importantly, they can help system administrators to make their servers more secure and reliable.
Five common configuration errors are as follows:
1. user/home directory permissions;
2. the getgid and setuid programs in the system;
3. globally readable/writable files/directories;
4. use services containing vulnerabilities;
5. default NFS mount options or insecure export options.
1. user/home directory permissions
In most Linux distributions, the default/home directory permission is 755, that is, any user logging on to the system can access the/home directory of other users. Some users, such as administrators or developers, may store some sensitive information in their own user directories, such as passwords, keys used to access the current or other network servers.
2. setgid and setuid programs in the system
The set uid bit of a file is very dangerous because it may allow the file to run as a privileged user, for example, root User: if the owner of a file is root and the setuid bit is set, then it runs with the root permission. This means that if the attacker finds the vulnerability in the file or runs the program in an unexpected way, he may be able to execute his own command with root privileges, then the permissions of the entire system will fall.
3. globally readable/writable files/Directories
The problems caused by global readable and writable files and directories are similar to those caused by improper configuration of the user's main directory permissions, but the impact scope may involve the entire system. The main reason for generating a globally readable file is that the default umask mask for creating the file is 0022 or 0002, which is due to this improper configuration, files that may contain sensitive information may be read by anyone logging on to the system. If the file is globally writable, it may be modified by anyone, and thus attackers may have the opportunity to modify some files or scripts to hide themselves, modify the scripts frequently used by administrators to execute some sensitive commands.
4. improperly configured services or settings
Services with minimal configuration should be run. It is often seen that some services are improperly configured or default certificates and configurations are used, and insecure communication channels are also very common, increasing the risk of server attacks. When using a service, you need to review its options and configurations to ensure the security or configuration of the deployment is appropriate. At the same time, it is often seen that some services are bound to multiple ports, rather than only local listening or only listening to a specific port.
5. default mount options or insecure export options
The default options for all mounts are rw, suid, dev, exec, auto, nouser, and async ". However, it is inappropriate to use these default options because they allow files in external mounted file systems such as NFS to be set with suid and guid bits. When exporting NFS shares, we recommend that you do not set the no_root_squash option. The default value is root_squash, but we often see that it will be modified in actual use. If the no_root_squash option is set, when the user logs on as the root user, the root permission is granted to the shared directory and can be used for anything. If these improper settings are kept by default, the root user is allowed to log on to the server, but users with such permissions should not be allowed to log on.
These settings are often ignored when you configure a Linux server. these improper configurations allow attackers or malicious users to illegally obtain a large amount of information or escalate their permissions on the server. It is easier to hide your ears and protect your system from blind spots than to reinforce the system honestly. but if you don't want your server to be hacked when you are sleeping well, reinforce your system in a down-to-earth manner.