您好,欢迎来到三六零分类信息网!老站,搜索引擎当天收录,欢迎发信息

PHP安全编程:会话数据注入

2025/9/15 5:49:11发布13次查看
一个与会话暴露类似的问题是会话注入。此类攻击是基于你的web服务器除了对会话存储目录有读取权限外,还有写入权限。因此,存在着编写一段允许其他用户添加,编辑或删除会话的脚本的可能。下例显示了一个允许用户方便地编辑已存在的会话数据的html表单:

read()){ if (substr($filename, 0, 5) == 'sess_') { $sess_data = file_get_contents($path/$filename); if (!empty($sess_data)) { session_decode($sess_data); $sess_data = $_session; $_session = array(); $sess_name = substr($filename, 5); $sess_name = htmlentities($sess_name, ent_quotes, 'utf-8'); echo session [$sess_name]; foreach ($sess_data as $name => $value) { $name = htmlentities($name, ent_quotes, 'utf-8'); $value = htmlentities($value, ent_quotes, 'utf-8'); echo $name:
; } echo '
'; } }}$handle->close();?>
脚本inject.php执行由表单所指定的修改:
$sess_data){ $_session = $sess_data; $sess_data = session_encode; file_put_contents($path/$sess_name, $sess_data);}$_session = array();?>
此类攻击非常危险。攻击者不仅可以编辑你的用户的数据,还可以编辑他自己的会话数据。它比会话劫持更为强大,因为攻击者能选择所有的会话数据进行修改,从而使绕过访问限制和其他安全手段成为可能。
针对这个问题的最好解决方案是将会话数据保存在数据库中。参见专题前面的内容。
延伸阅读 此文章所在专题列表如下:http://www.nowamagic.net/librarys/veda/detail/2079
该用户其它信息

VIP推荐

免费发布信息,免费发布B2B信息网站平台 - 三六零分类信息网 沪ICP备09012988号-2
企业名录 Product