본문 바로가기

미들웨어/Apache,Tomcat

Apache mod_security를 사용한 보안강화

반응형

Apache로 서비스를 운영할 때 보안취약사항으로 HTTP response header에 WEB서버 정보가 노출내용이 지적된다.

일반적으로 ServerTokens과 ServerSignature 두 항목을 통해 조치를 하지만 최근 mod_security를 통한 추가 조치도 필요한 경우가 자주 발생한다

 

이번 포스팅에는 mod_security를 통해 response header에 WEB서버의 정보를 삭제하는 방법을 가이드한다.


1. mod_security module 생성

[webwas@localhost modsecurity-2.9.1]$ ./configure --with-apxs=/webwas/Apache2.4/bin/apxs --with-apr=/webwas/Apache2.4/bin/apr-1-config --with-apu=/webwas/Apache2.4/bin/apu-1-config                                          checking for a BSD-compatible install... /bin/install -c
checking whether build environment is sane... yes
...
config.status: executing libtool commands

[webwas@localhost modsecurity-2.9.1]# make
Making all in tools
...
make[1]: Leaving directory `/home/webwas/install/modsecurity-2.9.1'
  • 컴파일이 완료되면 HTTPD_HOME/modules/mod_security2.so 파일이 생성된 것을 확인할 수 있다.
[webwas@localhost modules]$ ls -arlt /webwas/Apache2.4/modules/mod_security2.so
-rwxr-xr-x. 1 Apache webwas 2388776  3월  2 11:33 /webwas/Apache2.4/modules/mod_security2.so

 

2. module loading 및 설정

  • httpd.conf에 아래와 같이 mod_security2.so파일을 loading하고 관련 설정을 추가한다.
  • SecServerSignature 뒤에 response header에 보여줄 WEB서버 정보를 입력한다.(" "로 할 경우 아무것도 나오지 않음)
LoadModule security2_module modules/mod_security2.so

<IfModule security2_module>
    SecRuleEngine on
    SecServerSignature " "
</IfModule>

 

3. 결과 확인

  • 개발자도구를 사용해 response header를 확인해보면 아래와 같다.
  • ServerTokens Prod, ServerSignature Off 만 적용한 경우

  • mod_security를 적용한 경우

 

반응형

mod_security는 WEB서버 정보 표시에 대한 설정 외에도 다양한 설정을 통해 여러 공격에 대한 방어가 가능하다.

아래에서 추가 설정들에 대한 내용은 확인이 가능하다.

https://github.com/SpiderLabs/ModSecurity/wiki/Reference-Manual-(v2.x)#user-content-Configuration_Directives 

 

Reference Manual (v2.x)

ModSecurity is an open source, cross platform web application firewall (WAF) engine for Apache, IIS and Nginx that is developed by Trustwave's SpiderLabs. It has a robust event-based programmin...

github.com

 

반응형