Wednesday, September 25, 2013

Apache benchmark review

Các thành phần cần thiết cho việc bảo mật : firewall , IDS, DNS, Network branch security…
  • Phải có các policy cho nhân viên trong công ty, cũng như là cho website
  • Bảo mật cơ sở hạ tầng website bằng cách kiểm soát các luồn truy cập bằng firewall, router, switch
  • Xây dựng hệ thống IDS để theo dõi việc tấn công vào web server
  • Xây dựng hệ thống load balancing để tăng độ chịu lỗi và khả năng chống DDos
  • Theo dõi và kiểm soát disk space, log rotation
  • Thông tin đăng ký của domain không được liên quan đến các thông tin cá nhân nhằm giảm thiểu việc bị tấn công thông qua Social Engineering, war dialing và brute force
  • Domain name service phải được bảo mật, tránh bị tấn công theo phương pháp domain hi-jacking thông qua cache poisoning
  • Bảo mật ở tầng OS : giảm thiểu tối đa các dịch vụ listen trên network services, update OS và tuning lại các cấu hình dịch vụ (ko để mặc định)
  • Hướng dẫn DEV viết code một cách an toàn
Level 1 Apache benchmark settings :
  • Cài đặt apache từ các gói precompiled
  • Cài đặt gói modSecurity
Vì sao nên cài đặt gói security Core rule
  • Security Core Rule Set (SCRS) được tối ưu hóa cho performance
  • Độ tin tưởng cao
  • Được test trên môi trường thực với lượng traffic lớn
  • Được phát triển để tự động phát hiện các loại tấn công thường xảy ra, và do không viết để ngăn chặn 1 loại tấn công cụ thể nào nên SCRS có performance cao hơn, dễ sử dụng hơn và đòi hỏi update ít hơn.
  • Dễ cài đặt và sử dụng (plug & play)
Các công nghệ sử dụng trong mod_security :
Tuân thủ giao thức HTTP :
  • validation http request : chỉ có những request hợp lệ mới được đi qua
  • loại bỏ những request bất thường
  • giới hạn size của giao thức http để chống buffer overfloaw
  • áp dụng policy cho http, chỉ cho các request hợp lý với các method, content và extension đi vào (chống sql injection)
For apache config :
  • minimize httpd.conf file
  • chỉ enable các module cần sử dụng
  • tạo user riêng để chạy apache :# groupadd apache
    # useradd apache -g apache -d /dev/null -s /sbin/nologin
  • OS root directory access denied :<Directory />
    Options None
    AllowOverride None
    deny from all
    </Directory>
  • Restrict request methods :<LimitExcept GET POST OPTIONS>
    Deny from all
    </LimitExcept>
  • Restrict HTTP Protocol Version :SetEnvIf REQUEST_PROTOCOL ^HTTP/(0\.9|1\.[01])$ valid_protocol=1
    <Directory “/var/www/html”>
    Order allow,deny
    Allow from env=valid_protocol
    Options None
    AllowOverride None
    </Directory>
  • Restrict File Extensions :<FilesMatch
    “\.(?:c(?:o(?:nf(?:ig)?|m)|s(?:proj|r)?|dx|er|fg|md)|p(?:rinter|ass|db|
    ol|wd)|v(?:b(?:proj|s)?|sdisco)|a(?:s(?:ax?|cx)|xd)|d(?:bf?|at|ll|os)|i
    (?:d[acq]|n[ci])|ba(?:[kt]|ckup)|res(?:ources|x)|s(?:h?tm|ql|ys)|l(?:ic
    x|nk|og)|\w{,5}~|webinfo|ht[rw]|xs[dx]|key|mdb|old)$”>
    Deny from all
    </FilesMatch>
  • Denial of Service Prevention Tuning :Timeout 10
    KeepAlive On
    KeepAliveTimeout 15
    AcceptFilter http data
    AcceptFilter https data
  • Buffer Overflow Protection Tuning :# Maximum size of the request body.
    LimitRequestBody 10000
    # Maximum number of request headers in a request.
    LimitRequestFields 40
    # Maximum size of request header lines.
    LimitRequestFieldSize 100
    # Maximum size of the request line.
    LimitRequestLine 500
  • implementing ssl connection
  • Software Information Leakage Protection :# Reveal full identity (standard Apache directive)
    ServerTokens Prod
    ServerSignature Off
  •  Logging :LogLevel notice
    ErrorLog /var/log/httpd/error_log
    LogFormat “%h %l %u %t \”%r\” %>s %b \”%{Accept}i\” \”%{Referer}i\”
    \”%{User-Agent}i\”" combined
    CustomLog /var/log/httpd/access_log combined
  • Remove Default Content
  • Updating Ownership and Permissions :# chown -R root:root /usr/local/apache2
    # find /usr/local/apache2 -type d | xargs chmod 755
    # find /usr/local/apache2 -type f | xargs chmod 644
  • Monitor Vulnerability Lists