{"id":783,"date":"2012-07-20T15:24:21","date_gmt":"2012-07-20T07:24:21","guid":{"rendered":"http:\/\/rmohan.com\/?p=783"},"modified":"2012-07-20T15:24:21","modified_gmt":"2012-07-20T07:24:21","slug":"avoid-hackers-hacking-linux","status":"publish","type":"post","link":"https:\/\/mohan.sg\/?p=783","title":{"rendered":"Avoid hackers hacking linux"},"content":{"rendered":"<h3>Avoid hackers hacking linux<\/h3>\n<p>Apply Latest OS Patches<\/p>\n<p>All Linux servers running Red Hat are patched at least twice a year.<\/p>\n<p>Configure SSH (server)<br \/>\nSettings:<br \/>\nProtocol\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a02\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0# Default<br \/>\nLogLevel\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0INFO\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0# Default<br \/>\nPermitRootLogin\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0no<br \/>\nHostbasedAuthentication\u00a0\u00a0 \u00a0no\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0# Default<br \/>\nIgnoreRhosts\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0yes\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0# Default<br \/>\nAllowTcpForwarding\u00a0\u00a0 \u00a0no<br \/>\nPermitTunnel\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0no\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0# Default<br \/>\nBanner\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0\/etc\/issue<\/p>\n<p>Description:<\/p>\n<p>The settings are made in the \/etc\/ssh\/sshd_config file.<br \/>\nOnly Protocol 2 can be used. Protocol 1 is deprecated.<br \/>\nLogging must be enabled.<br \/>\nRoot logon must be disabled<br \/>\nHost based authentication is weak.<br \/>\nIgnoreRhosts is disabled (set to \u2018yes\u2019) because host-based authentication using .rhost is not permitted.<br \/>\nTunnelling\/forwarding is not permitted; it can be used to bypass Firewall rules.<br \/>\nBanner should contain the standard warning regarding unauthorised access.<\/p>\n<p>Secure xinetd network services<\/p>\n<p>Settings:<br \/>\nDisable all services except for psynch. In each service file in \/etc\/xinetd.d set this parameter:<br \/>\ndisable = yes<\/p>\n<p>Description:<br \/>\nMany of the default services are obsolete, vulnerable, or deprecated. Examples include rlogin and telnet.<br \/>\nThe psynch service is required for password synchronisation. Everything should be disabled or preferably removed completely.<\/p>\n<p>Minimise Boot Services<br \/>\nGood security practice is to only enable services that are absolutely required. The list below is allowed by default. Only the minimum required should be enabled.<br \/>\nServices Allowed<br \/>\nabrtd<br \/>\nacpid<br \/>\natd<br \/>\nauditd<br \/>\ncpuspeed<br \/>\ncrond<br \/>\ncups<br \/>\necap-monitor<br \/>\nfuncd<br \/>\nhaldaemon<br \/>\nHardware\/VM monitoring agents<br \/>\niptables<br \/>\nkdump<br \/>\nlm_sensors<br \/>\nlvm2-monitor<br \/>\nmdmonitor<br \/>\nmessagebus<br \/>\nnetfs<br \/>\nnetwork<br \/>\nnetworker<br \/>\nntpd<br \/>\nperfcap<br \/>\nportmap<br \/>\nrhnsd<br \/>\nrsyslog<br \/>\nsshd<br \/>\nsysgem<br \/>\nsysstat<br \/>\ntng<br \/>\nVeritas SF\/HA<br \/>\nxinetd<\/p>\n<p>Description:<br \/>\nBecause any running service could potentially have vulnerabilities, and be hijacked for malicious use, it is necessary to only enable those that are actually required. This allows us to reduce the attack surface, and reduce the opportunities available to a potential attacker.<br \/>\nThis list contains (boot up) services one might expect to see on a new server build. Additional services can be enabled if there is a strong business justification for their use.<\/p>\n<p>Set daemon umask<br \/>\nSettings:<br \/>\nThe umask for init should be set to 022. This is the default in RHEL6 and is not tuneable.<br \/>\nThe umask for all services started should also be set to 022. This is the default and is defined in \/etc\/init.d\/functions<\/p>\n<p>Description:<br \/>\nThis ensures that all files created by daemon processes have rw-r&#8211;r&#8211;\u00a0 permissions<\/p>\n<p>System Network Parameter Tuning<\/p>\n<p>Network Parameter Modifications<br \/>\nSettings:<br \/>\nCode these in \/etc\/sysctl.conf<br \/>\n# Controls IP packet forwarding<br \/>\nnet.ipv4.ip_forward = 0<\/p>\n<p># Do not accept source routing<br \/>\nnet.ipv4.conf.default.accept_source_route = 0<br \/>\nnet.ipv4.conf.all.accept_source_route = 0<\/p>\n<p># Controls the use of TCP syncookies<br \/>\nnet.ipv4.tcp_syncookies = 1<br \/>\nnet.ipv4.tcp_max_syn_backlog = 4096<\/p>\n<p># Malicious routing table alteration should be prevented:<br \/>\nnet.ipv4.conf.all.send_redirects = 0<br \/>\nnet.ipv4.conf.default.accept_redirects = 0<br \/>\nnet.ipv4.conf.all.secure_redirects = 0<br \/>\nnet.ipv4.conf.default.secure_redirects = 0<br \/>\nnet.ipv4.conf.default.send_redirects = 0<\/p>\n<p># Preventing Broadcast requests<br \/>\nnet.ipv4.icmp_echo_ignore_broadcasts = 1<\/p>\n<p># Enable bad error message Protection<br \/>\nnet.ipv4.icmp_ignore_bogus_error_responses = 1<\/p>\n<p>Description:<br \/>\nThe above settings are designed to help prevent Denial of service attacks (DOS); spoofing; and redirections, with minimal performance or functionality impact.<\/p>\n<p>Logging<\/p>\n<p>Syslog Message Capture<\/p>\n<p>Settings:<br \/>\nSend all AUTHPRIV and AUTH messages to the loghost server:<br \/>\nExample entry in \/etc\/syslog.conf<\/p>\n<p># The authpriv file has restricted access.<br \/>\nauthpriv.*\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0\/var\/log\/secure<br \/>\nauth.*\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0\/var\/log\/secure<\/p>\n<p># Security Syslog<br \/>\nauth.info\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0@loghost-gen<br \/>\nauthpriv.info\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0@loghost-gen<br \/>\n# End of Security Syslog<\/p>\n<p>Description:<br \/>\nAuthentication messages, including \u2018su\u2019 to another account must be recorded in the \/var\/log\/secure file. Additionally, these messages must be sent to the remote log consolidation server, known as loghost-gen. The log consolidation server provides an indelible record of authentication events.<\/p>\n<p>File and Directory Permissions\/Access<\/p>\n<p>Password File<\/p>\n<p>Settings:<br \/>\nEnsure that MD5 and shadow passwords are selected.<\/p>\n<p>Description:<br \/>\nThese are the default settings. The DES algorithm is now broken, and must not be used. If password shadowing is disabled, the hashes will be stored in \/etc\/passwd, which is world readable. It would be possible to attempt to crack these hashes, and obtain account passwords.<\/p>\n<p>File System Restriction<\/p>\n<p>Settings:<br \/>\nThe following \u2018nosuid\u2019, \u2018nodev\u2019 and \u2018noexec\u2019 settings must be added in \/etc\/fstab<\/p>\n<p>\/dev\/rootvg\/var\u00a0\u00a0\u00a0\u00a0\u00a0 \/var\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 ext3\u00a0\u00a0\u00a0 defaults,nosuid\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 1 2<br \/>\n\/dev\/rootvg\/home\u00a0 \/home\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 ext3\u00a0\u00a0\u00a0 defaults,nosuid,nodev\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 1 2<br \/>\n\/dev\/rootvg\/\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 \/apps\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 ext3\u00a0\u00a0\u00a0 defaults,nodev\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 1 2<br \/>\n\/dev\/rootvg\/tmp\u00a0\u00a0\u00a0 \/tmp\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 ext3\u00a0\u00a0\u00a0 defaults,nosuid,noexec,nodev\u00a0 1 2<br \/>\n\/dev\/rootvg\/crash\u00a0 \/var\/crash\u00a0 ext3\u00a0\u00a0\u00a0 defaults,nosuid,noexec,nodev\u00a0 1 2<br \/>\n\/dev\/rootvg\/ opt\u00a0\u00a0\u00a0 \/opt\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 ext3\u00a0\u00a0\u00a0 defaults,nodev\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 1 2<br \/>\n\/dev\/rootvg\/usr\u00a0\u00a0\u00a0\u00a0 \/usr\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 ext3\u00a0\u00a0\u00a0 defaults,nodev\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 1 2<br \/>\n\/dev\/rootvg\/data\u00a0\u00a0 \/data\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 ext3\u00a0\u00a0\u00a0 defaults,nosuid,noexec,nodev\u00a0 1 2<\/p>\n<p>Description:<br \/>\nThese restrictions are to control mounting of filesystems:<br \/>\nnosuid\u00a0\u00a0\u00a0 &#8211; prevent suid\/sgid access<br \/>\nnodev\u00a0\u00a0\u00a0\u00a0 &#8211; prevent devices being created<br \/>\nnoexec\u00a0\u00a0\u00a0 &#8211; prevent execution of binaries<\/p>\n<p>Accidental Deletion Protection<\/p>\n<p>Settings:<br \/>\nSet permissions on \/tmp to include the sticky-bit i.e rwxrwxtwt (1777).<\/p>\n<p>Description:<br \/>\nThis will prevent file deletion except for the owner of the file.<\/p>\n<p>Eliminate World-Writable Files<\/p>\n<p>Settings:<br \/>\nEnsure files do not have \u2018write\u2019 permission for \u2018other\u2019 category<br \/>\nchmod o-w &lt;filename&gt;<\/p>\n<p>Data in these files could be compromised by anyone with access to the server.<br \/>\nNOTE: Certain vendor applications may break if this setting is made, so exercise caution before making this change.<\/p>\n<p>Ensure Only Authorised Executables are SUID\/SGID<\/p>\n<p>Settings:<br \/>\nOnly entries in appendix X should have SUID\/SGID set.<\/p>\n<p>The SUID\/SGID facility allows executables to execute under root, when run under a non-root account, e.g. ping<\/p>\n<p>Orphaned Files<br \/>\nSettings:<br \/>\nOrphaned files must be removed, or an owner allocated.<\/p>\n<p>Description:<br \/>\nThese files do not have an owner, and it may be indicative of a break-in, or some other problem.<\/p>\n<p>7.7.\u00a0\u00a0 \u00a0Permissions<br \/>\nSettings:<br \/>\nFile\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Owner\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Group\u00a0\u00a0\u00a0\u00a0\u00a0 Access Permissions (minimum)<br \/>\n\/etc\/passwd\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 root\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 root\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 644<br \/>\n\/etc\/shadow\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 root\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 root\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 400<br \/>\n\/etc\/group\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 root\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 root\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 644<br \/>\n\/etc\/pam.d\/&lt;files&gt;\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 root\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 root\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 644<br \/>\n\/etc\/at.allow\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 root\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 root\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 400<br \/>\n\/etc\/cron.allow\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 root\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 root\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 400<br \/>\n\/etc\/crontab\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 root\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 root\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 400<br \/>\n\/etc\/ssh\/sshd.config\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 root\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 root\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 400<br \/>\n\/etc\/syslog.conf\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 root\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 root\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 600<br \/>\n\/var\/log\/secure\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 root\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 root\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 600<\/p>\n<p>Description:<br \/>\nThese important files should have the permissions set as specified, as a minimum.<\/p>\n<p>System Access, Authentication and Authorisation<\/p>\n<p>Remove .rhosts Feature<br \/>\nSettings:<br \/>\nIn \/etc\/pam.d\/rlogin and \/etc\/pam.d\/rsh, remove the entries containing the line:<\/p>\n<p>pam_rhosts_auth.so<\/p>\n<p>Description:<br \/>\nRemoving the \u2018pam_rhosts_auth.so\u2019 clause is an additional security measure, should rlogin\/rsh be enabled. The .rhosts facility has weak authentication, and should not be used.<\/p>\n<p>Restrict Access to at\/cron<br \/>\nSettings:<br \/>\nIn \/etc remove the at.deny and cron.deny files.<br \/>\nAdd the entry \u2018root\u2019 to at.allow and cron.allow. Remove any other user names that may be present.<\/p>\n<p>Description:<\/p>\n<p>The objective is to restrict the scheduling of jobs to the root account only. BNPP has a scheduling tool that should be used by application teams<br \/>\nwho wish to have scheduled tasks.<\/p>\n<p>8.3.\u00a0\u00a0 \u00a0Prevent Receiving of syslog Messages<\/p>\n<p>Settings:<br \/>\nThe \/etc\/init.d\/syslog file must have this setting:\u00a0 SYSLOGD_OPTIONS=\u201d-m 0\u201d<br \/>\nDescription:<br \/>\nThe absence or the \u2013r switch, prevents receiving remote syslog messages. A server that is configured to receive syslog messages can be compromised by being bombarded with (fake) syslog messages. This setting prevents a DOS attack.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Avoid hackers hacking linux <\/p>\n<p>Apply Latest OS Patches<\/p>\n<p>All Linux servers running Red Hat are patched at least twice a year.<\/p>\n<p>Configure SSH (server) Settings: Protocol 2 # Default LogLevel INFO # Default PermitRootLogin no HostbasedAuthentication no # Default IgnoreRhosts yes # Default AllowTcpForwarding no PermitTunnel no # Default Banner \/etc\/issue<\/p>\n<p>Description:<\/p>\n<p>The settings are [&#8230;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[20],"tags":[],"_links":{"self":[{"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/posts\/783"}],"collection":[{"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/mohan.sg\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=783"}],"version-history":[{"count":1,"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/posts\/783\/revisions"}],"predecessor-version":[{"id":784,"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/posts\/783\/revisions\/784"}],"wp:attachment":[{"href":"https:\/\/mohan.sg\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=783"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/mohan.sg\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=783"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/mohan.sg\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=783"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}