見出し画像

【IT】ApacheのOPTIONメソッド無効化

皆さま
こんにちは

Webサーバで利用されるサーバが
ApacheからNginxへ移りつつありますが、
まだまだApacheを利用されているWebサーバは、
数多くあります。

今回は、攻撃者へ無用な情報を提供しない様に
OPTIONメソッドの無効化を行います。

まずは、現状を確認します。

<<対策前>>
 
$  curl -v -X OPTIONS http://192.168.123.123
*   Trying 192.168.123.123:80...
* Connected to 192.168.123.123 (192.168.123.123) port 80 (#0)
> OPTIONS / HTTP/1.1
> Host: 192.168.123.123
> User-Agent: curl/7.85.0
> Accept: */*
>
* Mark bundle as not supporting multiuse
< HTTP/1.1 200 OK
< Date: Mon, 26 Dec 2022 15:04:02 GMT
< Server: Apache/2.4.53 (Red Hat Enterprise Linux) OpenSSL/3.0.1 mod_fcgid/2.3.9
< Allow: GET,POST,OPTIONS,HEAD,TRACE
< Content-Length: 0
< Content-Type: httpd/unix-directory
<
* Connection #0 to host 192.168.123.123 left intact

今回は、テスト用のローカルの仮想ゲストOSですが、
レンタルサーバを想定して「.htaccess」での対策を実施します。

公開ディレクトリ直下の「.htaccess」を編集し次の内容を追加します。
※「.htaccess」がない場合は、レンタルサーバの仕様をご確認ください。

RewriteEngine On
RewriteCond %{REQUEST_METHOD} ^OPTIONS
RewriteRule .* - [F]

再び対策されているか確認します。

$  curl -v -X OPTIONS http://192.168.123.123
*   Trying 192.168.123.123:80...
* Connected to 192.168.123.123 (192.168.123.123) port 80 (#0)
> OPTIONS / HTTP/1.1
> Host: 192.168.123.123
> User-Agent: curl/7.85.0
> Accept: */*
>
* Mark bundle as not supporting multiuse
< HTTP/1.1 403 Forbidden
< Date: Mon, 26 Dec 2022 15:14:48 GMT
< Server: Apache/2.4.53 (Red Hat Enterprise Linux) OpenSSL/3.0.1 mod_fcgid/2.3.9
< Last-Modified: Mon, 09 Aug 2021 11:43:42 GMT
< ETag: "1715-5c91ee59c9780"
< Accept-Ranges: bytes
< Content-Length: 5909
< Content-Type: text/html; charset=UTF-8
<
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">

これでOPTIONは、非表示となり対策が出来ました。

Iaasや自身でApacheサーバを起動している場合は、
httpd.confに以下を入れておくとセキュリティレベルが向上します。

ServerTokens ProductOnly
ServerSignature Off
TraceEnable off

上記を対策した結果(ローカルの仮想サーバ)は、以下となります。
レンタルサーバでApacheの情報が開示されている場合は、
他のサーバへお引越しされることをお勧めします。

$  curl -v -X OPTIONS http://192.168.123.123
*   Trying 192.168.123.123:80...
* Connected to 192.168.123.123 (192.168.123.123) port 80 (#0)
> OPTIONS / HTTP/1.1
> Host: 192.168.123.123
> User-Agent: curl/7.85.0
> Accept: */*
>
* Mark bundle as not supporting multiuse
< HTTP/1.1 403 Forbidden
< Date: Mon, 26 Dec 2022 15:26:05 GMT
< Server: Apache
< Last-Modified: Mon, 09 Aug 2021 11:43:42 GMT
< ETag: "1715-5c91ee59c9780"
< Accept-Ranges: bytes
< Content-Length: 5909
< Content-Type: text/html; charset=UTF-8
<
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">


では

この記事が気に入ったらサポートをしてみませんか?