×
Array
(
[fid] => 6980
[description] =>
[password] =>
[icon] =>
[redirect] =>
[attachextensions] =>
[creditspolicy] => Array
(
[post] => Array
(
[usecustom] => 1
[cycletype] => 1
[cycletime] => 0
[rewardnum] => 75
[extcredits1] => 0
[extcredits2] => 0
[extcredits3] => 0
[extcredits4] => 0
[extcredits5] => 0
[extcredits6] => 0
[extcredits7] => 0
[extcredits8] => 0
[rid] => 1
[fid] => 6980
[rulename] => 发表主题
[action] => post
[fids] => 32,52,67,447,1120,1151,1156,6750,6762,6763,6766,6769,6772,6773,6787,6796,6808,6809,6810,6813,6814,6820,6829,6830,6846,6856,6864,6865,6827,6930,6931,6776,6858,6880,6764,6932,6871,6758,6905,1116,6788,6812,6798,6736,6759,6842,6966,6767,6828,6924,6935,6936,6938,6940,6941,6826,6909,6803,6919,6911,6908,6881,6920,6912,6913,6921,6925,6922,6789,6818,6819,6872,6928,6969,6889,6888,6917,6939,6947,6961,6937,6943,6970,6869,6900,6902,6783,6817,1111,6870,6821,6951,6876,6952,6954,6960,6942,6910,6949,6962,6963,6964,6927,6926,6973,6728,6929,6874,6894,6896,6885,6857,6868,1113,6778,56,6844,6878,6802,6933,6811,6923,6877,6875,6918,6892,6757,6832,6833,6795,6793,6848,6837,6849,6850,6851,6852,6853,6854,6863,6882,6836,6790,6838,6794,6791,6873,555,6895,6934,6958,6944,6945,6907,6779,6886,6950,6904,6956,6862,6957,6855,6955,6959,6914,6965,6971,6972,6953,6975,6976,6799,6974,6824,6815,6891,6866,6979,6977,6765,6903,6948,6845,6879,1121,6980
)
[reply] => Array
(
[usecustom] => 1
[cycletype] => 4
[cycletime] => 0
[rewardnum] => 0
[extcredits1] => 0
[extcredits2] => 0
[extcredits3] => 0
[extcredits4] => 0
[extcredits5] => 0
[extcredits6] => 0
[extcredits7] => 0
[extcredits8] => 0
[rid] => 2
[fid] => 6980
[rulename] => 发表回复
[action] => reply
)
[digest] => Array
(
[usecustom] => 1
[cycletype] => 4
[cycletime] => 0
[rewardnum] => 0
[extcredits1] => 0
[extcredits2] => 0
[extcredits3] => 0
[extcredits4] => 0
[extcredits5] => 0
[extcredits6] => 0
[extcredits7] => 0
[extcredits8] => 0
[rid] => 3
[fid] => 6980
[rulename] => 加精华
[action] => digest
)
)
[formulaperm] => a:5:{i:0;s:0:"";i:1;s:0:"";s:7:"message";s:0:"";s:5:"medal";N;s:5:"users";s:0:"";}
[moderators] =>
[rules] =>
[threadtypes] => Array
(
[status] => 1
[required] => 0
[listable] => 0
[types] => Array
(
)
)
[threadsorts] => Array
(
)
[viewperm] =>
[postperm] =>
[replyperm] =>
[getattachperm] =>
[postattachperm] =>
[postimageperm] =>
[spviewperm] =>
[seotitle] =>
[keywords] =>
[seodescription] =>
[supe_pushsetting] =>
[modrecommend] => Array
(
[open] => 0
[num] => 10
[imagenum] => 0
[imagewidth] => 300
[imageheight] => 250
[maxlength] => 0
[cachelife] => 0
[dateline] => 0
)
[threadplugin] => Array
(
)
[replybg] =>
[extra] => a:2:{s:9:"namecolor";s:0:"";s:9:"iconwidth";s:0:"";}
[jointype] => 0
[gviewperm] => 0
[membernum] => 0
[dateline] => 0
[lastupdate] => 0
[activity] => 0
[founderuid] => 0
[foundername] =>
[banner] =>
[groupnum] => 0
[commentitem] =>
[relatedgroup] =>
[picstyle] => 0
[widthauto] => 0
[noantitheft] => 0
[noforumhidewater] => 0
[noforumrecommend] => 0
[livetid] => 0
[price] => 0
[fup] => 6974
[type] => sub
[name] => 币圈资讯
[status] => 1
[displayorder] => 0
[styleid] => 0
[threads] => 50922
[posts] => 50990
[todayposts] => 0
[yesterdayposts] => 0
[rank] => 60
[oldrank] => 61
[lastpost] => 2688723 美国2024年大选已花费147亿美元,或为史上最贵 1730688420 比推快讯
[domain] =>
[allowsmilies] => 1
[allowhtml] => 1
[allowbbcode] => 1
[allowimgcode] => 1
[allowmediacode] => 0
[allowanonymous] => 0
[allowpostspecial] => 1
[allowspecialonly] => 0
[allowappend] => 0
[alloweditrules] => 0
[allowfeed] => 0
[allowside] => 0
[recyclebin] => 1
[modnewposts] => 0
[jammer] => 0
[disablewatermark] => 0
[inheritedmod] => 0
[autoclose] => 0
[forumcolumns] => 0
[catforumcolumns] => 0
[threadcaches] => 0
[alloweditpost] => 1
[simple] => 16
[modworks] => 0
[allowglobalstick] => 1
[level] => 0
[commoncredits] => 0
[archive] => 0
[recommend] => 0
[favtimes] => 0
[sharetimes] => 0
[disablethumb] => 0
[disablecollect] => 0
[ismoderator] => 0
[threadtableid] => 0
[allowreply] =>
[allowpost] =>
[allowpostattach] =>
)
慢雾:XCarnival NFT借贷协议漏洞分析
[复制链接]
|
当前离线
经验:
天策币:
活跃币:
策小分:
总在线: 分钟
本月在线: 分钟
|
|
原文作者:九九,慢雾安全团队 2022 年 6 月 27 日,据慢雾区消息,XCarnival 项目被曝出严重漏洞遭黑客攻击并盗走 3,087 个 ETH(约 380 万美元)。XCarnival 是一个 ETH 链上的 NFT 借贷项目,目前项目团队正在修复漏洞并承诺会对受影响的用户提供解决方案。慢雾安全团队第一时间介入分析,并将结果分享如下: 相关信息核心合约地址 P2Controller: 0x34ca24ddcdaf00105a3bf10ba5aae67953178b85 XNFT: 0x39360AC1239a0b98Cb8076d4135d0F72B7fd9909 xToken: 0x5417da20aC8157Dd5c07230Cfc2b226fDCFc5663 攻击者 EOA 地址 0xb7cbb4d43f1e08327a90b32a8417688c9d0b800a 攻击合约地址 0xf70F691D30ce23786cfb3a1522CFD76D159AcA8d 0x234e4B5FeC50646D1D4868331F29368fa9286238 0x7B5A2F7cd1cc4eEf1a75d473e1210509C55265d8 0xc45876C90530cF0EE936c93FDc8991534F8A6962 漏洞核心点分析1.攻击者通过 XNFT 合约中的 pledgeAndBorrow 函数来进行抵押 NFT 并借出 xToken。 在 pledgeInternal 函数中转入 NFT 并生成订单: 2. 接着调用 withdrawNFT 函数提取出质押的 NFT,其中首先判断该订单是否被清算状态,如果不是则判断该订单的状态是否为 NFT 还未被提取且借款金额为 0(无负债),如果通过即可提取抵押的 NFT。 3. 以上为攻击前生成订单的准备操作,接着攻击者开始利用生成的订单直接调用 xToken 合约中的 borrow 函数进行借款。 在 borrowInternal 函数中,会外部调用 controller 合约中的 borrowAllowed 函数来判断是否可以借款。 可以看到在 borrowAllowed 函数会调用 orderAllowed 函数进行订单相关信息的判断,但是在这两个函数中均没有进行 _order.isWithdraw 状态的判断。因此攻击者可以利用之前生成的订单(订单里的抵押的 NFT 已经被提走)来调用 XToken 的 borrow 函数来借款,而因为抵押的 NFT 在之前已经被提出,故攻击者可以不用还款来实现获利。 攻击交易分析此处仅展示其中一笔攻击交易的细节,其余攻击交易的手法均一致,不再赘述。 攻击前准备——生成订单的交易: 0x61a6a8936afab47a3f2750e1ea40ac63430a01dd4f53a933e1c25e737dd32b2f 1. 首先攻击者将 NFT 转入攻击合约并进行授权,接着调用 xNFT 合约中的 pledgeAndBorrow 函数在进行抵押 NFT 生成订单并借款的操作,此处需要注意一点是该函数可以控制传入的 xToken,攻击者传入了自己构造的 xToken 合约地址,并且让借款数量为 0,目的是为了满足后续能成功提出 NFT 时的不被清算且负债为 0 的条件。 2. 攻击者紧接着调用 withdrawNFT 函数来进行提取抵押的 NFT: 正式攻击交易: 0x51cbfd46f21afb44da4fa971f220bd28a14530e1d5da5009cfbdfee012e57e35 攻击者调用 xToken 合约的 borrow 函数,传入之前生成的订单的 orderID,重复了该操作 22 次(orderID: 45 - 66),而因为 NFT 在准备阶段已经提走,估计无需还款以此来获利。 总结本次漏洞的核心在于借款的时候,没有进行订单中 NFT 是否被提走的状态的判断,导致攻击者可以在把 NFT 提走之后再利用之前生成的订单来借款而无需还款,以此来获利。针对此类漏洞,慢雾安全团队建议在进行借款操作时应做好订单状态中是否已经提走抵押品的判断,避免再次出现此类问题。 来源:金色财经 |
|
|
|
|
|
|