【高危漏洞修复】异次元 V3.0 代理商转账负数刷余额漏洞补丁(附完整代码)
各位老哥,最近很多人的异次元站点日志里出现了疯狂报错,仔细一查,发现系统里藏着一个极度高危的逻辑漏洞:代理商 / 分站转账功能竟然没有校验负数!

🚨 漏洞危害:
黑客只需通过抓包,在转账接口输入 -100(负数金额),系统不仅不会报错,还会因为 “负负得正”,反而给黑客自己的账号余额里凭空增加 100 元!这就是日志里一直出现 转账给 ID: xxx 的原因,别人的脚本正在疯狂刷你的钱。此外,原代码还存在引发数据库死锁(卡死)的坑。
🛠️ 修复方案:
我已经整理好了修复版的完整代码。本次修复完全不影响你原有的正常转账和列表功能,只是加了死拦截,任何人再敢传负数过来,直接弹窗报错!
3.2.X 开始
文件路径: app/Controller/User/Api/AgentMember.php
替换方法:
打开上面这个文件,把里面的内容全部清空,然后复制下方这段完整的安全修复代码贴上去保存即可。
<?php
declare(strict_types=1);
namespace App\Controller\User\Api;
use App\Controller\Base\API\User;
use App\Entity\Query\Get;
use App\Interceptor\UserSession;
use App\Interceptor\Waf;
use App\Service\Query;
use Illuminate\Database\Capsule\Manager as DB;
use Illuminate\Database\Eloquent\Builder;
use Kernel\Annotation\Inject;
use Kernel\Annotation\Interceptor;
use Kernel\Exception\JSONException;
use Kernel\Waf\Filter;
#[Interceptor([Waf::class, UserSession::class], Interceptor::TYPE_API)]
class AgentMember extends User
{
#[Inject]
private Query $query;
/**
* @return array
*/
public function data(): array
{
$map = $this->request->post();
$get = new Get(\App\Model\User::class);
$get->setOrderBy(...$this->query->getOrderBy($map, "id", "desc"));
$get->setPaginate((int)$this->request->post("page"), (int)$this->request->post("limit"));
$get->setWhere($map);
$get->setColumn("id", "pid", "username", "email", "phone", "qq", "avatar", "create_time", "status", "balance", "recharge");
$data = $this->query->get($get, function (Builder $builder) {
return $builder->where("pid", $this->getUser()->id);
});
return $this->json(data: $data);
}
/**
* @return array
* @throws JSONException
*/
public function transfer(): array
{
$to = $this->request->post("id");
$amount = $this->request->post("amount", Filter::FLOAT);
$userId = $this->getUser()->id;
// --- 核心安全修復:攔截非法金額(徹底堵死負數刷餘額) ---
if ($amount <= 0) {
throw new JSONException("非法操作:轉帳金額必須大於 0!");
}
// --- 核心安全修復:禁止自己給自己轉帳 ---
if ($to == $userId) {
throw new JSONException("非法操作:不能給自己轉帳!");
}
// --- 核心安全修復:移除導致數據庫死鎖的串行化鎖表代碼 ---
// DB::connection()->getPdo()->exec("set session transaction isolation level serializable");
Db::transaction(function () use ($to, $amount, $userId) {
\App\Model\Bill::create($userId, $amount, 0, "轉帳給ID:{$to}", 0, false);
\App\Model\Bill::create($to, $amount, 1, "來自ID:{$userId}的轉帳", 0, false);
});
return $this->json();
}
}
3.2.X 结束
搞定保存后,你的余额系统就安全了,这帮刷子再怎么抓包也只能干瞪眼。强烈建议所有还在跑这个版本的兄弟赶紧动手改!
💡 温馨提示:
如果你的站被改得乱七八糟不知道怎么覆盖,或者需要其他的防御排查,别把站搞白屏了,可以直接来找官方社群或者付费技术支持处理。
感谢您的来访,获取更多精彩文章请收藏本站。
© 版权声明
THE END











![[开源]一款号卡分销管理系统,物联网卡系统,SaaS云端智能架构-彩豆博客](https://img.521cd.cn/i/2024/11/13/77dqa.png)



暂无评论内容