부록01_Nginx 보안설정

Nginx 보안설정에 대한 현대차증권 권고사항

1. nginx 보안 관련 설정

  1. nginx 띄울때 nginx 전용 계정으로 실행

     # nginx.conf
     user nginx nginxgroup;
    
  2. nginx 실행하는 계정의 접근 권한 제한

     $ chown nginx:nginxgroup ./nginx_root_dir
     $ chmod 750 ./nginx_root_dir
    
  3. nginx 서버 설정 파일 접근 제한

     $ chown nginx:nginxgroup ./nginx_root_dir/conf/*.conf
     $ chmod 600 ./nginx_root_dir/conf/*.conf
    
  4. directory 검색 기능 비활성화

     # nginx.conf
        
     ...
     autoindex off;
     ...
    
  5. log file 에 대한 접근 제한
    1. nginx.config 에 설정된 log directory 확인

       $ cat ./nginx_root_dir/conf/nginx.conf | grep "error_log\\|access_log"
      
    2. default log 에 대한 접근제한

       chown nginx:nginxgroup ./nginx_root_dir/logs/
       chmod 750 ./nginx_root_dir/logs/
       chmod 640 ./nginx_root_dir/logs/*.log
      
  6. 공격등을 파악하기 위해서 필요한 정보를 logging 해야 한다.
     # nginx.conf
     ...
     log_format combined '$remote_addr - $ remote_user [$time_local]''
                 '"$request" $body_bytes_sent'
                 '"$http_referer" "http_user_agent"';
        
     access_log logs/access.log combined
    
  7. 법적으로 log file 을 최소 1년 이상 보관해야 한다.
    1. 사용자 접속 기록 1년 이상: 사용자 로그인/로그아웃/정보변경 등(개인정보 미 취급 시 6개월 이상)
    2. 개인정보취급자의 개인정보처리시스템 접속 기록 2년 이상
      • 정보주체 식별정보 / 개인정보취급자 식별정보 /
      • 접속일시 / 접속지 정보 /
      • 부여된 권한 유형에 따른 수행업무 등 2년 이상
    3. 개인정보취급자권한 변경 기록 5년 이상
      • 개인정보취급자 권한 생성/변경/삭제 등
  8. 헤더 정보 노출 방지

     # nginx config
     ...
     server_tokens off;
     ...
    
  9. http method 제한 nginx 에서 default 로 HTTP Method 중 GET, POST, HEAD, OPTIONS 만 허용 아래처럼 dav_methods 를 설정하지 말아야 한다.(기본값: dav_methods off)

     # nginx.conf
        
     location / {
         root /data/www;
        
         dav_methods PUT DELETE MKCOL COPY MOVE;
     }
        
    
  10. 에러핸들링 설정 값 적용 (필수 항목 : 400, 401, 403, 404, 500)

    # nginx.conf
    ...
    error_page 400 401 403 404 500 /error.html;
    ...
    

2. 솔루션 취약점관련 설정

  1. 기본 문서명 변경: index.html, index.htm 외의 이름으로 한다.
# nginx.conf

location / {
    root html;
    index example_main.html;
}
  1. SSL 을 사용못하게 설정: POODLE 취약점 공격 방어를 위해
# nginx.conf
...
server {
    listen          443 ssl;
    server_name     www.example.com;
    ssl_certificate     www.example.com.crt;
    ssl_certificate_key www.example.com.key;
    ssl_protocols       TLSv1 TLSv1.1 TLSv1.2;
    ssl_ciphers     HIGH:!aNULL:!MD5;
}
...
  • 호환성 이슈로 인해 SSLv3 비활성화가 불가하고, OpenSSL 버전 업그레이드 또한 불가할 경우 OpenSSL설정파일에서 CBC Cipher Suite 제거
    • 제거해야 할 cipher suite
      • TLS_DH_anon_WITH_AES_256_CBC_SHA
      • TLS_DH_anon_WITH_3DES_EDE_CBC_SHA
      • TLS_DH_anon_WITH_AES_128_CBC_SHA
      • TLS_DH_anon_WITH_RC4_128_MD5
      • TLS_DH_anon_WITH_DES_SHA
  • 권장하는 nginx 서버 version
    • nginx 1.17.7 이상
    • nginx 1.16.1 이상
    • nginx 1.15.12 이상