OS/Linux

[Linux] OS 취약점 점검 조치 (U-06,U-13)

dalgong 2023. 3. 14. 21:37
반응형

U-06 파일 및 디렉터리 소유자 설정


Risk level Critical
Description 소유자가 존재하는 않는 파일 및 디렉토리가 존재하는지 점검하고, 임의의 사용자에 의한 불법적 행위를 사전에 차단하기 위하여 삭제하여야 합니다. 삭제된 소유자의 UID와 동일한 사용자가 해당 파일/디렉토리에 접근 가능하여 정보 노출의 위험이 있습니다. 해당 위협은 퇴직자 관련 파일이 삭제되 않거나, 해킹에 의해 악의적인 파일이 생성되었을 가능성이 높습니다.
Recommended

setting and judgment

judgment criteria
소유자가 존재하지 않은 파일 및 디렉터리가 존재하지 않는 경우 양호
아래 명령 실행시 결과값이 나오면 취약
# find /etc /tmp /bin /sbin -nouser -o -nogroup
Mitigation method Step 1) 소유자가 존재하지 않는 파일/디렉토리 점검 find /etc /tmp /bin /sbin -nouser -o -nogroup Step 2) 위 명령으로 확인된 파일 삭제 또는 소유자 변경 (파일 삭제) rm -f <file_name> (소유자 변경) chown <user_name> <file_name>

<조치방법>

[root@ ~]#  find /etc /tmp /bin /sbin -nouser -o -nogroup <= 해당 파일 찾기

chown <user_name> <file_name>
chgrp <user_name> <file_name>

- 소유자가 존재하지 않는 파일/디렉터리를 찾아 소유자를 부여해줍니다.

- chown root example

 

U-13 SUID,SGID,Stick bit 설정 파일 점검


Risk level Critical
Description SUID(Set User-ID)와 SGID(Set Group-ID)가 설정된 파일은(특히, root 소유의 파일인 경우) 특정 명령어를 실행하여 root 권한 획득 및 정상서비스 장애를 발생시킬 수 있습니다. root 소유의 SUID 파일의 경우에는 꼭 필요한 파일을 제외하고는 SUID, SGID 속성을 제거하고, 잘못 설정되어 보안 위협이 되고 있는지 주기적인 진단 및 관리가 요구됩니다.

*SUID(Set User-ID): 설정된 파일 실행 시, 특정 작업 수행을 위하여 일시적으로 파일 소유자의 권한을 얻게 됨.
*SGID(Set Group-ID): 설정된 파일 실행 시, 특정 작업 수행을 위하여 일시적으로 파일 소유 그룹의 권한을 얻게 됨.
Recommended

setting and judgment

judgment criteria
주요 파일의 권한에 SUID와 SGID가 설정되어 있는지 확인
 # ls -alL [check_file] | awk '{print $1}' | grep -i 's'
Linux
 /sbin/dump
 /sbin/restore
 /sbin/unix_chkpwd
 /usr/bin/at
 /usr/bin/lpq
 /usr/bin/lpq-lpd
 /usr/bin/lpr
 /usr/bin/lpr-lpd
 /usr/bin/lprm
 /usr/bin/lprm-lpd
 /usr/bin/newgrp
 /usr/sbin/lpc
 /usr/sbin/lpc-lpd
 /usr/sbin/traceloute
 
AIX
 /usr/bin/X11/xlock
 /usr/dt/bin/dtraction
 /usr/dt/bin/dtterm
 /usr/sbin/mount
 /usr/sbin/lchangelv
Mitigation method Step 1) 제거 방법
  chmod -s <file_name>
Step 2) 주기적인 감사 방법
  find /sbin/dump /sbin/restore /sbin/unix_chkpwd /usr/bin/at /usr/bin/lpq /usr/bin/lpq-lpd /usr/bin/lpr /usr/bin/lpr-lpd /usr/bin/lprm /usr/bin/lprm-lpd /usr/bin/newgrp /usr/sbin/lpc /usr/sbin/lpc-lpd /usr/sbin/traceloute /usr/bin/X11/xlock /usr/dt/bin/dtraction /usr/dt/bin/dtterm /usr/sbin/mount /usr/sbin/lchangelv  -user root -type f \( -perm -04000 -o -perm -02000 \) -xdev -exec ls -al {} \; 2>/dev/null 
Step 3) 반드시 사용이 필요한 경우 특정 그룹에서만 사용하도록 제한하는 방법
  # 일반 사용자의 Setuid 사용을 제한함 (임의의 그룹만 가능)
  /usr/bin/chgrp <group_name> <setuid_file_name>
  /usr/bin/chmod 4750 <setuid_file_name>

<조치방법>

chmod -s <file_name>

- chmod -s 명령어를 입력하여 파일에 부여되어있던 특수권한을 제거해준다.

 

NCP OS 취약점 점검 방법

 

[NCP] OS 취약점 점

서버 보안을 위해서 분기 혹은 반기별로 OS 취약점 점검을 실시해야해서 NCP에서 OS 취약점 점검을 하는 법을 공유하고자 한다. Linux 1. Agent 다운로드 # wget http://pub-ossc.ncloud.com:10080/download/ncp_secuagen

itdalgong.tistory.com

 

반응형