2008年3月31日

apricot 計數器的安全性問題

今天在 LogWatch 裡看到一行異狀.. 居然想這麼玩!
apricot.php?u=../../../../../../../../../../../../../../../etc/passwd HTTP Response 200
看了 apricot.php 的程式碼, 發現作者直接取 $_GET 與 $_POST 的值來開檔, 難怪會有人這麼搞.
加個一行過濾吧~

大約在 1940 行, 有個 get_param 的 function.
function get_param($str, $default_value=null)
{
... (略)

// 增加字元過濾, 把路徑符濾掉
$str = ereg_replace('/', '', $str);

return $str;
}

沒有留言: