赞
踩
2023 年 5 月 6 日,由于智能合约漏洞,Deus DAO 协议在 Arbitrum、以太坊和 BNB 链上被利用。在这次攻击中,黑客窃取了大约 650 万美元。
虽然这个漏洞很久远,但可以学习下
Deus 是一个去中心化的点对点基础设施平台,允许数字衍生品、期权和掉期的场外交易。使用 Deus,用户可以创建自定义衍生品并与平台上的其他人进行交易。
DEI 是一种部分储备稳定币,可用作基于 DEUS 基础设施层构建的协议的衍生品交易的记账单位。
说白了,就是Deus平台中使用智能合约分化出一个新的币种(合约维持的)名为DEI
根本漏洞是函数中的限额配置错误。而不是_allowances[account][_msgSender()] ,它被设置为 _allowances[_msgSender()][account]
function burnFrom(address account, uint256 amount) public virtual {
uint256 currentAllowance = _allowances[_msgSender()][account];
_approve(account, _msgSender(), currentAllowance - amount);
_burn(account, amount);
}
攻击者首先识别了一个持有大量$DEI代币的地址。然后,攻击者使用受害者的地址调用 burnFrom() 函数,将 amount 参数传递为零。
该合约现在允许批准从指定地址到攻击者地址的所有令牌。这意味着攻击者现在可以访问与该地址关联的所有令牌。
然后,他们调用对 transferFrom() 函数的调用,以拿走资产以获取利润。该攻击者在 Arbitrum 上获利超过 500 万美元,在以太坊上获利超过 135 美元。
在BNB链中,这个漏洞是抢先进行的。他们向 Deus Deployer 发送了一条链上消息,打算退还资金。
攻击者将所有 USDC 换成 ETH,并将其从 Arbitrum 桥接到以太坊链。在撰写此博客时,攻击者的钱包中有价值约 103 万美元的资产。
理论上只要将_allowances[_msgSender()][account]->_allowances[account][_msgSender()]即可
function burnFrom(address account, uint256 amount) public virtual {
uint256 currentAllowance = _allowances[account][_msgSender()];
_approve(account, _msgSender(), currentAllowance - amount);
_burn(account, amount);
}
现在去查看deus的git源码,官方是这样修改的
function burnFrom(address account, uint256 amount) public virtual {
uint256 decreasedAllowance = allowance(account, _msgSender()).sub(amount, "ERC20: burn amount exceeds allowance");
_approve(account, _msgSender(), decreasedAllowance);
_burn(account, amount);
}
参考:https://consensys.io/diligence/blog/2023/08/reproducing-the-deusdao-exploit-with-diligence-fuzzing/
本人并没有复现成功,有成功可以评论出来
https://quillaudits.medium.com/decoding-deus-dao-6-5-million-exploit-quillaudits-588bbecec61f
https://consensys.io/diligence/blog/2023/08/reproducing-the-deusdao-exploit-with-diligence-fuzzing/
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。