ApacheでHTTP TRACEを無効にする




バージョン 2.0.58

HTTP TRACEはデフォルトで有効になっているが、
HTTP TRACEリクエストのHTTP headerに含まれるcookieや認証データを
盗まれてしまう可能性があるため無効にしたい

まずは、どのようなオプションが有効になっているかを確認する
# telnet localhost 80
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
OPTIONS * HTTP/1.1
Host: localhost
 
HTTP/1.1 200 OK
Date: Mon, 31 Jul 2006 04:40:29 GMT
Server: Apache/2.0.58 (Unix)
Allow: GET,HEAD,POST,OPTIONS,TRACE  ←TRACEが有効
Content-Length: 0
Content-Type: text/plain

HTTP TRACEが有効な場合以下のようなリクエストに対して、
リクエストをそのまま返してくる
# telnet localhost 80
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
TRACE /index.html HTTP/1.1
Host: localhost
 
HTTP/1.1 200 OK
Date: Mon, 31 Jul 2006 10:00:02 GMT
Server: Apache/2.0.58 (Unix)
Transfer-Encoding: chunked
Content-Type: message/http
 
2f
TRACE /index.html HTTP/1.1  ←リクエストそのまま
Host: localhost  ←リクエストそのまま
 
 
0

無効にする
httpd.confにて以下を記述(どこでも良い)
TraceEnable off

httpdを再起動して反映
再度確認してみる

# telnet localhost 80
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
OPTIONS * HTTP/1.1
host: localhost
 
HTTP/1.1 200 OK
Date: Tue, 01 Aug 2006 09:13:42 GMT
Server: Apache/2.0.58 (Unix)
Allow: GET,HEAD,POST,OPTIONS  ←TRACEがなくなった!
Content-Length: 0
Content-Type: text/plain

# telnet localhost 80
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
TRACE /index.html HTTP/1.1
host: localhost
 
HTTP/1.1 403 Forbidden  ←返さなくなった!
Date: Tue, 01 Aug 2006 09:20:17 GMT
Server: Apache
Content-Length: 271
Content-Type: text/html; charset=iso-8859-1
 
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head>
<title>403 Forbidden</title>
</head><body>
<h1>Forbidden</h1>
<p>You don't have permission to access /index.html
on this server.</p>
<hr>
<address>Apache Server at localhost Port 80</address>
</body></html>