开发者

Using a foreach loop to get create variables from $_POST security issues?

In the past I have used the follo开发者_如何转开发wing to create variables from a posted form.

foreach($_POST as $k=>$v)
{
    $$k = $v;
}

What are the security risks associates with using this method?

im trying some test atm. how about this version where it removes anything that is not a letter or number before making the variable?

foreach($_POST as $k=>$v)
{
    $k = preg_replace("/[^[:alnum:]]/","",$k);
    $$k=$v;
}


An attacker can inject a POST variable called _SESSION and by that write data in your session so you can't trust your session anymore.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜