KyberSwap 被黑简单分析

币圈资讯 阅读:41 2024-04-22 12:23:07 评论:0
美化布局示例

欧易(OKX)最新版本

【遇到注册下载问题请加文章最下面的客服微信】永久享受返佣20%手续费!

APP下载   全球官网 大陆官网

币安(Binance)最新版本

币安交易所app【遇到注册下载问题请加文章最下面的客服微信】永久享受返佣20%手续费!

APP下载   官网地址

火币HTX最新版本

火币老牌交易所【遇到注册下载问题请加文章最下面的客服微信】永久享受返佣20%手续费!

APP下载   官网地址

前言

KyberSwap 被黑的事情挺大的,被搞了45m,一开始是以为是4月份的那个问题,因为操纵痕迹上很像。但是仔细分析后发现不是。所以这里简单记录下方便回溯。

简单技术分析

TDLR;

核心问题:tick 操控导致的流动重复添加。原因为池本身的 reinvest计算导致tick的计算方式出了问题

分析样本:https://etherscan.io/tx/0x485e08dc2b6a4b3aeadcb89c3d18a37666dc7d9424961a2091d6b3696792f0f3

4月份问题 ref:https://100proof.org/kyberswap-post-mortem.html

攻击流程&原理分析

  1. 攻击者首先耗光了池的流动性,把流动性(价格)打到一边。

  2. KyberSwap Pool 区别于正常的 UniswapV3 Pool,创新性地把兑换产生的手续费计入流动性中,使手续费本身在兑换中也可以产生利息

  3. 基于第二点的问题, 攻击者基于第一点的情况进行小额反向兑换,但兑换不触发 cross tick,根据代码逻辑,流程如下图: 

  4. 由于错误的计算了 currentTick,导致兑换结束后池的更新出现问题


    The foreword was hacked. At first, it was thought to be the problem of the month. Because the traces of manipulation were similar, but after careful analysis, it was found that it was not. Therefore, here is a simple record to facilitate backtracking. Simple technical analysis of the core problem. The reason for the repeated addition of the flow caused by manipulation is that there is a problem with the calculation method caused by the calculation of the pool itself. Analysis of the sample month problem, analysis of the principle of attack flow, the attacker first consumed the liquidity of the pool and pushed the liquidity price aside, which is different from the normal innovation. The handling fee generated by the exchange is included in the liquidity, so that the handling fee itself can also generate interest during the exchange. Based on the second point, the attacker makes a small amount of reverse exchange based on the first point, but the exchange does not trigger. According to the logical flow of the code, the following figure shows that there is a problem in the update of the pool after the exchange is completed due to wrong calculation. 比特币今日价格行情网_okx交易所app_永续合约_比特币怎么买卖交易_虚拟币交易所平台

  5. 通过结合具体的 trace 可以验证我们的想法

核心问题函数分析

核心的问题在于 computeSwapStep 函数中,直接看图 

再看

最后这个得出来的价格再通过 getTickAtSqrtRatio 函数一算,tick就完全错了。

文字格式和图片示例

注册有任何问题请添加 微信:MVIP619 拉你进入群

弹窗与图片大小一致 文章转载注明 网址:https://netpsp.com/?id=62950

美化布局示例

欧易(OKX)最新版本

【遇到注册下载问题请加文章最下面的客服微信】永久享受返佣20%手续费!

APP下载   全球官网 大陆官网

币安(Binance)最新版本

币安交易所app【遇到注册下载问题请加文章最下面的客服微信】永久享受返佣20%手续费!

APP下载   官网地址

火币HTX最新版本

火币老牌交易所【遇到注册下载问题请加文章最下面的客服微信】永久享受返佣20%手续费!

APP下载   官网地址
可以去百度分享获取分享代码输入这里。
声明

1.本站遵循行业规范,任何转载的稿件都会明确标注作者和来源;2.本站的原创文章,请转载时务必注明文章作者和来源,不尊重原创的行为我们将追究责任;3.作者投稿可能会经我们编辑修改或补充。

发表评论
平台列表
美化布局示例

欧易(OKX)

  全球官网 大陆官网

币安(Binance)

  官网

火币(HTX)

  官网

Gate.io

  官网

Bitget

  官网

deepcoin

  官网
关注我们

若遇到问题,加微信客服---清歌

搜索
排行榜
扫一扫,加我为微信好友加我为微信好友