TMAegisBêta
Plus de règles pour linux

Linux distributions

TMA-ALINUX3-2.1.23

Ensure mail transfer agents are configured for local-only mode

MoyenneNiveau 1Automatiséelinux

Description

Mail Transfer Agents (MTA), such as sendmail and Postfix, are used to listen for incoming mail and transfer the messages to the appropriate user or mail server. If the system is not intended to be a mail server, it is recommended that the MTA be configured to only process local mail.

Méthode de vérification

Méthode d'audit: Commande shell

shell
alt0() { o=$(bash -c '#!/usr/bin/env bash

{
   a_output=(); a_output2=(); a_port_list=("25" "465" "587")
   for l_port_number in "${a_port_list[@]}"; do
      if ss -plntu | grep -P -- '"'"':'"'"'"$l_port_number"'"'"'\b'"'"' | grep -Pvq -- '"'"'\h+(127\.0\.0\.1|\[?::1\]?):'"'"'"$l_port_number"'"'"'\b'"'"'; then
         a_output2+=(" - Port \"$l_port_number\" is listening on a non- loopback network interface")
      else
         a_output+=(" - Port \"$l_port_number\" is not listening on a non- loopback network interface")
      fi
   done
   if command -v postconf &> /dev/null; then
      l_interfaces="$(postconf -n inet_interfaces)"
   elif command -v exim &> /dev/null; then
      l_interfaces="$(exim -bP local_interfaces)"
   elif command -v sendmail &> /dev/null; then
      l_interfaces="$(grep -i "O DaemonPortOptions=" /etc/mail/sendmail.cf | grep -oP '"'"'(?<=Addr=)[^,+]+'"'"' | grep -v '"'"'^127\.0\.0\.1$'"'"')"
   fi
   if [ -n "$l_interfaces" ]; then
      if grep -Pqi '"'"'\ball\b'"'"' <<< "$l_interfaces"; then
         a_output2+=(" - MTA is bound to all network interfaces")
      elif ! grep -Pqi '"'"'(inet_interfaces\h*=\h*)?(0\.0\.0\.0|::1|loopback- only|localhost)'"'"' <<< "$l_interfaces"; then
         a_output2+=(" - MTA is bound to a network interface" " \"$l_interfaces\"")
      else
         a_output+=(" - MTA is not bound to a non loopback network interface" "   \"$l_interfaces\"")
      fi
   else
      a_output+=(" - MTA not detected or in use")
   fi
   if [ "${#a_output2[@]}" -le 0 ]; then
      printf '"'"'%s\n'"'"' "" "- Audit Result:" "  ** PASS **" "${a_output[@]}"
      exit "${XCCDF_RESULT_PASS:-101}"
   else
      printf '"'"'%s\n'"'"' "" "- Audit Result:" "  ** FAIL **" "  * Reasons for audit failure *" "${a_output2[@]}" ""
      [ "${#a_output[@]}" -gt 0 ] && printf '"'"'%s\n'"'"' "- Correctly set:" "${a_output[@]}"
      exit "${XCCDF_RESULT_FAIL:-102}"
   fi
}' 2>&1); printf '%s\n' "$o" | grep -q '\*\* PASS \*\*' || { echo "step1: script did not report PASS"; return 1; }; }; if alt0; then echo compliant; fi
Sortie attendue
compliant

Méthode de correction

Méthode de correction: Recommandation ou correctif d'infrastructure

Edit /etc/postfix/main.cf and add the following line to the RECEIVING MAIL section. If the line already exists, change it to look like the line below: inet_interfaces = loopback-only Run the following command to restart postfix: # systemctl restart postfix Note: • This recommendation is designed around the postfix mail server. • Depending on your environment you may have an alternative MTA installed such as exim4 or sendmail. If this is the case consult the documentation for your installed MTA to configure the recommended state.

Propriétés

Systèmes d'exploitation
alinux-3
Étiquettes
cis-convertedlinux
Référence
CIS Alibaba Cloud Linux 3 Benchmark v2.0.0 - 2.1.23

Vérifier cet hôte

Exécutez cette commande sur une machine que vous êtes autorisé à auditer. L'analyse est en lecture seule.

shell
tmaegis scan --target linux