{"content":{"title":"Rikkei Finance事件分析","body":"# 1、Rikkei Finance事件简介\r\nhttps://rikkeifinance.medium.com/rikkei-finance-incident-investigation-report-b5b1745b0155\r\n\r\n![1.png](https://img.learnblockchain.cn/attachments/2022/10/Md4tUgnA635e4dcf06296.png)\r\n# 2、攻击分析\r\n交易：https://phalcon.blocksec.com/tx/bsc/0x93a9b022df260f1953420cd3e18789e7d1e095459e36fe2eb534918ed1687492\r\n\r\n![2.png](https://img.learnblockchain.cn/attachments/2022/10/m9PXs8cG635e4e1844ee8.png)\r\n# 3、获利分析\r\n\r\n![3.png](https://img.learnblockchain.cn/attachments/2022/10/8KAViH5d635e4e36d4abf.png)\r\n# 4、攻击过程分析\r\n\r\n![4.png](https://img.learnblockchain.cn/attachments/2022/10/e3Vm0PJB635e4e51644bf.png)\r\n1、\t攻击合约先使用0.0001 BNB 在Rifi BNB中抵押出499553304430711102439309 rBNB代币；\r\n2、\t根据交易过程中的 JumpRateModel、AccrueInterest、mintAllowed 等合约或函数名称可看出，Rifi BNB 是一个类似Compound 的抵押贷款交易所；\r\n3、\t问题在于第3 步中，攻击合约调用了 SimplePriceOracle 合约的setOracleData 函数，这是用于设置价格预言机地址的函数，但是函数可见性却为external ；可被任何合约调用并设置任意值，意味着价格也可被任意设置；\r\n\r\n![5.png](https://img.learnblockchain.cn/attachments/2022/10/8tZpHlFj635e4e6b7c068.png)\r\n4、\t可看到价格预言机被设置为 0xA36F6F78B2170a29359C74cEFcB8751E452116f9 ，反编译查看其代码，发现存在一个极大的数\r\n\r\n![6.png](https://img.learnblockchain.cn/attachments/2022/10/DlesqGHj635e4e80619ae.png)\r\n\r\n5、\t分析SimplePriceOracle 合约的 getUnderlyingPrice 函数返回的值，可发现修改前其值为 416247538680000000000 ，修改预言机后为 416881147930000000000000000000000\r\n\r\n![7.png](https://img.learnblockchain.cn/attachments/2022/10/5qWa6UG6635e4e9e3aea1.png)\r\n# 5、漏洞复现\r\n漏洞复现代码参考：https://github.com/SunWeb3Sec/DeFiHackLabs/blob/main/src/test/Rikkei_exp.sol"},"author":{"user":"https://learnblockchain.cn/people/10579","address":null},"history":null,"timestamp":1667125030,"version":1}