본문 바로가기
인프라 진단/전자금융기반시설(서버) - Linux

SRV-021 FTP 서비스 접근 제어 설정 미비

by 49 BLOCK 2024. 1. 1.

notice

SRV-021 FTP 서비스 접근 제어 설정 미비

【 상세설명 】
FTP는 파일을 전송하기 위한 프로토콜로 계정과 패스워드를 암호화하지 않고 평문 전송을 하며, 적절한 접근통제 정책 미적용 시 비인가자에게 시스템 파일이 노출될 수 있으므로 FTP 접근 제어 설정의 적절성 여부를 점검

【 판단기준 】
- 양호 : 특정 IP 주소 또는 호스트에서만 FTP 서버에 접속하도록 접근제어 설정을 적용한 경우
- 취약 : 특정 IP 주소 또는 호스트에서만 FTP 서버에 접속하도록 접근제어 설정을 적용하지 않은 경우

【 판단방법 】
1. FTP 접근제어 설정 확인

  ■ Linux, SOLARIS
    [ ftp ] : Limit 절 명령어 및 호스트 설정 확인
    # cat /etc/ftpaccess
    # cat /etc/ftpd/ftpaccess
        <Limit READ>
            DenyAll
        </Limit>
        ...
        <Limit STOR>
            AllowAll
        </Limit>

    [ proftp ] : Limit 절 명령어 및 호스트 설정 확인
    # cat /etc/ftpaccess
    # cat /etc/ftpd/ftpaccess
또는        
    # cat /etc/proftpd.conf
    # cat /etc/proftpd/proftpd.conf
    # cat /etc/proftpd/conf/proftpd.conf
    # cat /usr/local/etc/proftpd.conf
    # cat /usr/local/proftpd/etc/proftpd.conf
        <Limit READ>
            DenyAll
        </Limit>
        ...
        <Limit STOR>
            AllowAll
        </Limit>

    [ vsftp ] : TCP Wrapper 사용 설정 및 TCP Wrapper 정책 확인
        # cat /etc/vsftpd.conf | grep tcp_wrappers
        # cat /etc/vsftpd/vsftpd.conf | grep tcp_wrappers
        # cat /etc/vsftpd/conf/vsftpd.conf | grep tcp_wrappers
            tcp_wrappers=YES

        # cat /etc/hosts.deny
        # cat /etc/hosts.allow

    ※ 설정을 하지 않으면 설정 값이 없는 상태이며 hosts.allow 파일이 없는 경우도 있음
    ※ TCP Wrapper 접근제어 가능 서비스 : SYSTAT, FINGER, FTP, TELNET, RLOGIN, RSH, TALK, EXEC, TFTP, SSH
    ※ TCP Wrapper 는 다음 두 파일에 의해 접근이 제어됨
        - /etc/hosts.deny : 시스템 접근을 제한할 IP 설정 
        - /etc/hosts.allow : 시스템 접근을 허용할 IP 설정 
        - /etc/hosts.allow, /etc/hosts.deny 파일 둘 다 미존재 : 모든 접근 허용

  ■ AIX
    [ ftp ] : allow, deny 호스트 설정 확인
    # cat /etc/ftpaccess.ctl | egrep "allow|deny"
        allow: host, host, ...
        deny: host, host, ...

    [ proftp ] : Limit 절 명령어 및 호스트 설정 확인
    # cat /etc/ftpaccess
    # cat /etc/ftpd/ftpaccess
또는        
    # cat /etc/proftpd.conf
    # cat /etc/proftpd/proftpd.conf
    # cat /etc/proftpd/conf/proftpd.conf
    # cat /usr/local/etc/proftpd.conf
    # cat /usr/local/proftpd/etc/proftpd.conf
        <Limit READ>
            DenyAll
        </Limit>
        ...
        <Limit STOR>
            AllowAll
        </Limit>

    [ vsftp ] : TCP Wrapper 사용 설정 및 TCP Wrapper 정책 확인
    # cat /etc/vsftpd.conf | grep tcp_wrappers
    # cat /etc/vsftpd/vsftpd.conf | grep tcp_wrappers
    # cat /etc/vsftpd/conf/vsftpd.conf | grep tcp_wrappers
        tcp_wrappers=YES

    # cat /etc/hosts.deny
    # cat /etc/hosts.allow

  ■ HP-UX
    [ ftp ] : allow, deny 호스트 설정 또는 Limit 절 명령어 및 호스트 설정 확인
    # cat /etc/ftpd/ftphosts | egrep "allow|deny"
        allow: host, host, ...
        deny: host, host, ...
또는
    # cat /etc/ftpd/ftpaccess
        <Limit READ>
          DenyAll
        </Limit>
        ...
        <Limit STOR>
          AllowAll
        </Limit>

    [ proftp ] : Limit 절 명령어 및 호스트 설정 확인
    # cat /etc/ftpaccess
    # cat /etc/ftpd/ftpaccess
또는        
    # cat /etc/proftpd.conf
    # cat /etc/proftpd/proftpd.conf
    # cat /etc/proftpd/conf/proftpd.conf
    # cat /usr/local/etc/proftpd.conf
    # cat /usr/local/proftpd/etc/proftpd.conf
        <Limit READ>
            DenyAll
        </Limit>
        ...
        <Limit STOR>
            AllowAll
        </Limit>

    [ vsftp ] : TCP Wrapper 사용 설정 및 TCP Wrapper 정책 확인
    # cat /etc/vsftpd.conf | grep tcp_wrappers
    # cat /etc/vsftpd/vsftpd.conf | grep tcp_wrappers
    # cat /etc/vsftpd/conf/vsftpd.conf | grep tcp_wrappers
        tcp_wrappers=YES

    # cat /etc/hosts.deny
    # cat /etc/hosts.allow

  ■ RHEL 6, 7
    [ ftp ] : Limit 절 명령어 및 호스트 설정 확인
    # cat /etc/ftpd/ftpaccess
        <Limit READ>
            DenyAll
        </Limit>
        ...
        <Limit STOR>
            AllowAll
        </Limit>

    [ proftp ] : Limit 절 명령어 및 호스트 설정 확인
    # cat /etc/ftpd/ftpaccess
또는        
    # cat /etc/proftpd.conf
        <Limit READ>
            DenyAll
        </Limit>
        ...
        <Limit STOR>
            AllowAll
        </Limit>

    [ vsftp ] : TCP Wrapper 설정 및 TCP Wrapper 정책 확인
    # cat /etc/vsftpd/vsftpd.conf | grep tcp_wrappers
        tcp_wrappers=YES

    # cat /etc/hosts.deny
    # cat /etc/hosts.allow

   (iptables 사용 시) : iptables 정책에서 불필요한 정책 확인
    # iptables -nL --line-number
        Chain INPUT (policy ACCEPT)
        num  target     prot opt source               destination
        1    ACCEPT     all  --  192.168.0.10         0.0.0.0/0            /* admin */
        2    ACCEPT     tcp  --  192.168.0.11         0.0.0.0/0            state NEW tcp dpt:21
        3    ACCEPT     all  --  127.0.0.1            0.0.0.0/0
        4    DROP       icmp --  0.0.0.0/0            0.0.0.0/0
        5    DROP       tcp  --  0.0.0.0/0            0.0.0.0/0
        ...

  ■ RHEL 8, 9
    [ ftp ] : Limit 절 명령어 및 호스트 설정 확인
    # cat /etc/ftpd/ftpaccess
        <Limit READ>
            DenyAll
        </Limit>
        ...
        <Limit STOR>
            AllowAll
        </Limit>

    [ proftp ] : Limit 절 명령어 및 호스트 설정 확인
    # cat /etc/ftpd/ftpaccess
또는        
    # cat /etc/proftpd.conf
        <Limit READ>
            DenyAll
        </Limit>
        ...
        <Limit STOR>
            AllowAll
        </Limit>

    [ vsftp ] : firewall 정책 확인
    # firewall-cmd --zone=public --list-all
    public (active)
      target: default
      icmp-block-inversion: no
      interfaces: enp0s3
      sources:
      services: cockpit dhcpv6-client ftp ssh
      ports:
      protocols:
      forward: yes
      masquerade: no
      forward-ports:
      source-ports:
      icmp-blocks:
      rich rules:
            rule family="ipv4" source address="192.168.217.1" port port="21" protocol="tcp" accept

    ※ firewall 은 기본적으로 차단 정책(All Deny)이 적용되어 있으며 허용 정책만 등록
    ※ firewall 접근제어 가능 서비스 : firewall-cmd --get-services 명령어로 확인 가능
    ※ RHEL 8 버전 이상부터 TCP Wrapper 가 firewall 로 완전히 대체 되었으며 /etc/hosts.allow, /etc/hosts.deny 파일도 삭제되었음
    ※ Amazon Linux 2(RHEL 8 버전 기반) 에는 TCP Wrapper 가 패키지에 포함되어 있지만 Amazon Linux 2023 에서는 미포함

【 조치방법 】
1. FTP 접근제어 설정
    ※ Limit 절 명령어 및 호스트 설정은 정보시스템 운영 환경 및 시스템 영향력 고려하여 설정(필요시 각 경로별로 지정)

2024-01-13 : (조치과정 삭제)