LoginSignup
13
11

More than 5 years have passed since last update.

ベーシック認証で8文字までしかパスワードが有効にならない問題

Posted at

某所にBasic認証を設定したところ、パスワードの先頭8文字がマッチしていれば認証が通るという摩訶不思議現象に悩まされまして、そのメモ。

結論から言うと、オプション指定なしでhtpasswdコマンドを利用してパスワードを生成すると、上記のような現象となる。

-dコマンドを利用するとcrypt()を利用してパスワードを生成する。
これは最大8文字まで利用するという制限があって、httpd2.2.17までは標準で利用されていた。

参考までに、PHPでも同様の問題がある。
http://php.net/manual/ja/function.crypt.php

標準の DES ベースの場合、crypt() はstr の最初の 8 文字しか使用しません。
つまり、最初の 8 文字が同じである長い文字列は、 同じ salt を使う限り同じ結果となります。

対応方法

以下のオプションを利用しましょう

-m Use MD5 encryption for passwords. This is the default (since version 2.2.18).
-s Use SHA encryption for passwords. Facilitates migration from/to Netscape servers using the LDAP Directory Interchange Format (ldif).

ただ、md5もshaも、パスワード管理としては強度弱かったような気がするんだけど、どうなんだろうねー。

13
11
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
13
11