카테고리 없음

[LINUX] Redhat 계열 보안 취약점 조치

PeamS 2026. 5. 7. 11:35

 

https://www.kisa.or.kr/2060204/form?postSeq=22&page=1#fnPostAttachDownload

U-01 root 계정 원격 접속 제한

기준 : root 직접 접속을 허용하고 원격 서비스를 사용하는 경우 "취약"

 

찾기

egrep -ne "^[^#]*PermitRootLogin" /etc/ssh/sshd_config /etc/ssh/sshd_config.d/* 2>/dev/null

 

조치 (Rocky 8 / 9)

PermitRootLogin yes를 찾고 no 로 바꾸기 (두줄 이상 검출되면 수동 조치)

p_cmd=$(egrep -ne "^[^#]*PermitRootLogin" /etc/ssh/sshd_config /etc/ssh/sshd_config.d/*)
p_file="$(echo ${p_cmd} | cut -d: -f1)"
p_line="$(echo ${p_cmd} | cut -d: -f2)"

sed -i "${p_line}s/PermitRootLogin yes/PermitRootLogin no/" "${p_file}"
systemctl restart sshd

 

U-02 비밀번호 관리정책 설정

비밀번호 관리 정책이 설정되지 않은 경우

 

찾기

# pwquality 모듈 로드 확인 (password/requisite 에 pam_pwquality.so 정상) 
grep -ie pam_pwquality.so /etc/pam.d/*

# pwquality 설정 확인 (minlen = 8, d u l o = -1, retry = 3, enforce_for_root 정상)
cat /etc/security/pwquality.conf /etc/security/pwquality.conf.d/*.conf 2>/dev/null | grep -v "^#"

# pwhistory 설정 확인 (enforce_for_root, remember = 4, file = /etc/security/opassword 정상)
cat /etc/security/pwhistory.conf | grep -v "^#"

# login.defs 설정 확인 (MAX = 90, MIN = 1 정상
cat /etc/login.defs | egrep "PASS_MAX_DAYS|PASS_MIN_DAYS" | grep -v "^#"

 

조치 (Rocky 8 / 9)

# pwquality
sed -i 's:# minlen = 8:minlen = 8:g' /etc/security/pwquality.conf
sed -i 's:# dcredit = 0:dcredit = -1:g' /etc/security/pwquality.conf
sed -i 's:# ucredit = 0:ucredit = -1:g' /etc/security/pwquality.conf
sed -i 's:# lcredit = 0:lcredit = -1:g' /etc/security/pwquality.conf
sed -i 's:# ocredit = 0:ocredit = -1:g' /etc/security/pwquality.conf
sed -i 's:# enforce_for_root:enforce_for_root:g' /etc/security/pwquality.conf

# pwhistory
sed -i 's:# enforce_for_root:enforce_for_root:' /etc/security/pwhistory.conf
sed -i 's:# remember =.*:remember = 4:' /etc/security/pwhistory.conf
sed -i 's:# file = /etc/security/opasswd:file = /etc/security/opasswd:' /etc/security/pwhistory.conf

# login.defs
sed -i 's:PASS_MAX_DAYS\t99999:PASS_MAX_DAYS\t90:g' /etc/login.defs
sed -i 's:PASS_MIN_DAYS\t0:PASS_MIN_DAYS\t1:g' /etc/login.defs

 

U-03 계정 잠금 임계값 설정

 계정 잠금 임계값이 설정되어 있지 않거나, 10회 이하의 값으로 설정되지 않은 경우

 

확인

# 모듈 확인 (auth 에 preauth, authfail 존재 / account 에 존재 시 정상)
grep -e faillock /etc/pam.d/*

# faillock 설정 확인 (silent, deny = 10, unlock_time = 120 정상)
cat /etc/security/faillock.conf | grep -v "^#"

 

조치 (Rocky 8 / 9)

authselect sssd 프로파일 적용 및 failock 기능 추가

 - 아래 명령어 입력 시 /etc/pam.d/ 가 authselect sssd 기본 프로파일로 덮어 씌워집니다. 수동으로 pam.d 관리 시 주의!(날라가요)

# authselect sssd 사용 여부 확인
authselect current

# authselect sssd 사용하기 (sssd 를 쓰고 있으면 무시)
authselect select sssd --force

# authselect faillock 기능 추가
authselect enable-feature with-faillock
sed -i 's:# silent:silent:g' /etc/security/faillock.conf
sed -i 's:# deny = 3:deny = 10:g' /etc/security/faillock.conf
sed -i 's:# unlock_time = 600:unlock_time = 120:g' /etc/security/faillock.conf

 

U-06 사용자 계정 su 기능 제한

su 명령어를 모든 사용자가 사용하도록 설정된 경우

 

조치 (PAM 모듈 안 쓸 때)(Rocky 8 / 9)

# 사용자 추가
su_user=creeper
useradd ${su_user}
usermod ${su_user} -G wheel
passwd ${su_user}

# su 파일 수정
chown root.wheel /bin/su
chmod 4750 /usr/bin/su

 

U-12 세션 종료 시간 설정

Session Timeout이 600초(10분) 이하로 설정되지 않은 경우

 

확인

echo $TMOUT

 

조치 (Rocky 8 / 9)

cat <<EOF>> /etc/profile

# timeout
TMOUT=600
export TMOUT
EOF

 

U-19 /etc/hosts 파일 소유자 및 권한 설정

/etc/hosts 파일의 소유자가 root가 아니거나, 권한이 644 이하가 아닌 경우

 

확인

# root.root 에 644 면 정상
ll /etc/hosts

 

조치 (Rocky 8 / 9)

chmod 644 /etc/hosts

 

U-21 /etc/(r)syslog.conf 파일 소유자 및 권한 설정

/etc/(r)syslog.conf 파일의 소유자가 root(또는 bin, sys)가 아니거나, 권한이 640 이하가 아닌
경우

 

확인

ll /etc/rsyslog.conf

 

조치 (Rocky 8 / 9)

chmod 640 /etc/rsyslog.conf

 

U-30 UMASK 설정 관리

UMASK 값이 022 미만으로 설정된 경우

 

확인

echo $TMOUT

 

조치 (CentOS 6)

# profile 에 umask 022 추가
cat <<EOF>> /etc/profile

# umask
umask 022
export umask
EOF

# login.defs 에 umask 077 -> 022 로 수정
sed -i 's/UMASK           077/UMASK           022/g' /etc/login.defs

 

 

U-37 crontab 설정파일 권한 설정 미흡

crontab 및 at 명령어에 일반 사용자 실행 권한이 부여되어 있으며, cron 및 at 관련 파일 권한이
640 이상인 경우

 

확인

# 
ll /usr/bin/crontab
ll /var/spool/cron/*
ll /var/sppol/cron/crontabs/*
ls -alF /etc/ | grep cron

 

조치 (Rocky 8 / 9)

# 다음 기준으로 조치 
[root@rocky9 ~]# ls -alF /etc/ | grep cron
-rw-r--r--.  1 root root      541  8월  6  2025 anacrontab
drwxr-xr-x.  2 root root       21  8월  6  2025 cron.d/
drwxr-xr-x.  2 root root        6  5월 11  2022 cron.daily/
-rw-r--r--.  1 root root        0  8월  6  2025 cron.deny
drwxr-xr-x.  2 root root       22 11월 25 12:11 cron.hourly/
drwxr-xr-x.  2 root root        6  5월 11  2022 cron.monthly/
drwxr-xr-x.  2 root root        6  5월 11  2022 cron.weekly/
-rw-r--r--.  1 root root      451  5월 11  2022 crontab

# other 의 read, write, excute 제거
chmod o-rwx /etc/cron*

# cron 파일 other 의 read, write, excute 제거
chmod o-rx /etc/cron.d/0hourly
chmod o-rwx /etc/cron.hourly/0anacron

 

U-41 불필요한 automountd 제거

automountd 서비스가 활성화된 경우

 

CentOS 6

# 확인
chkconfig | grep autofs

# 조치
chkconfig --level 345 autofs off

 

U-62 로그인 시 경고 메시지 설정

서버 및 Telnet, FTP, SMTP, DNS 서비스에 로그온 시 경고 메시지가 설정되어 있지 않은 경우

 

조치 (Rocky 8 / 9)

cat <<EOF> /etc/motd
###############################################################
#                                                             #
#   WARNING: Authorized Access Only!                          #
#   All activities are logged.                                #
#                                                             #
###############################################################
EOF
sed -i 's:#Banner none:Banner /etc/motd:g' /etc/ssh/sshd_config
systemctl restart sshd

 

U-67 로그 디렉터리 소유자 및 권한 설정

디렉터리 내 로그 파일의 소유자가 root가 아니거나, 권한이 644를 초과하는 경우

 

조치 (Rocky 8 / 9)

# dnf 내 log rotate 비활성화
sed -i '/^\[main\]/a log_rotate=0' /etc/dnf/dnf.conf

# rocky 9 기준
# logrotate dnf 내 dnf 관련 로그 관리 추가 및 600 추가
cat <<EOF> /etc/logrotate.d/dnf
/var/log/dnf.librepo.log /var/log/dnf.rpm.log /var/log/hawkey.log /var/log/dnf.log {
    missingok
    notifempty
    rotate 4
    weekly
    create 0600 root root
}
EOF

# 기존 dnf 관련 파일 권한 변경
chmod 600 /var/log/dnf.*
chmod 600 /var/log/hawkey.log*

# anaconda (설치 시 정보 담는 디렉터리)
chmod -R 600 /var/log/anaconda/

chmod 660 /var/log/lastlog
chmod 660 /var/log/wtmp

https://access.redhat.com/solutions/4923771