MatthewJiang-Rustle - 2023RustChinaCon.pdf

編號:132026 PDF 28頁 4.49MB 下載積分:VIP專享
下載報告請您先登錄!

MatthewJiang-Rustle - 2023RustChinaCon.pdf

1、第三屆中國Rust開發者大會Rustle:the first static analyzer for smart contracts in RustMatthew JiangDirector of Security Team BlockSecMotivationBackgroundDesign123Capability UsabilityConclusion456OutlineMotivationWhy do we develop Rustle?Emerging chains with Rust as smart contracts language MotivationLimitations

2、 of manual auditTime-consumingExpensiveSkilled auditorsError-proneMotivationMotivationCurrent tools:Dont support contracts in RustBackgroundLLVM IRDesignC;C+RustGoFront-endClangRustcGollvmLLVM IRBack-endx86ARMBPFWASMLLVM Pass:rich APIs to analysis the LLVM IR BackgroundNearBlockchains with smart con

3、tracts in RustRustWebAssemblySolanaRustBPFThough they are compiled into bytecode in different formats,we can analyze the logic on the LLVM IRRich experience in auditing smart contracts in RustBackgroundDesignWorkflowDesignCompileSmart ContractsLLVMIRLLVM PassExtractedPatternsPattern MatchAnalysisRes

4、ultsDesign#private pub fn callback_withdraw(&mut self,amount:U128)match env:promise_result(0)PromiseResult:NotReady=unreachable!(),PromiseResult:Successful(_)=self.balance-=amount.0;PromiseResult:Failed=;pub fn withdraw(&mut self,amount:U128)-Promise assert!(self.balance=amount.into(),insufficient b

5、alance);ext_ft_core:ext(self.token_id.clone().with_attached_deposit(1).with_static_gas(GAS_FOR_FT_TRANSFER_CALL).ft_transfer_call(self.depositor.clone(),amount,None,.to_string().then(ext_self:ext(env:current_account_id().with_static_gas(GAS_FOR_FT_RESOLVE_TRANSFER).with_attached_deposit(0).callback_

6、withdraw(amount),)ExampleReentrancy point,hand over control flow to external contractself.balance hasnt been modified upon second entranceft_transfer_call()Reentrancy AttackState changeDesignpub fn callback_withdraw(&mut self,amount:U128)match env:promise_result(0)PromiseResult:NotReady=unreachable!

7、(),PromiseResult:Successful(_)=self.balance-=amount.0;PromiseResult:Failed=;call void _ZN8near_sdk11environment3env14promise_result17hdbc39eb9958e6bdcE(ptr sret(%near_sdk:types:vm_types:PromiseResult)%_21,i64 0)#9,!dbg!4685%_22=load i32,ptr%_21,align 4,!dbg!4685,!range!2246,!noundef!35switch i32%_22

8、,label%bb9 i32 0,label%bb10i32 1,label%bb11i32 2,label%bb13,!dbg!4686bb10:;call core:panicking:paniccall void _ZN4core9panicking5panic17h364c37174a08a6a4E(ptr align 1 alloc438,i32 40,ptr align 4 alloc440)#10,!dbg!4687unreachable,!dbg!4687bb11:%6=load i128,ptr%self,align 8,!dbg!4688%_25.0=sub i128%6,

9、%amount,!dbg!4688%_25.1=icmp ult i128%6,%amount,!dbg!4688%7=call i1 llvm.expect.i1(i1%_25.1,i1 false),!dbg!4688br i1%7,label%panic,label%bb12,!dbg!4688bb13:;call core:ptr:drop_in_placecall void _ZN4core3ptr61drop_in_place$LT$near_sdk.types.vm_types.PromiseResult$GT$17hc8d1a50a856c2b05E(ptr%_21)#9,!d

10、bg!4689ret void,!dbg!4690bb12:store i128%_25.0,ptr%self,align 8,!dbg!4688br label%bb13,!dbg!4691NotReadySuccessfulFailedAdvantages Support different chains with smart contracts in Rust Support to add new detectors for extension Support different platforms/OSsDesignCapability Being able to locate 30

11、different types of vulnerabilities Being able to find real world vulnerabilitiesRich DetectorsEach detector can locate one specific type of security issuesRustle currently supports 30 different detectorsFor the complete list,refer to https:/ caseCapabilityRustles Result:SPL-LendingIncorrect rounding

12、rounding can be manipulatedAssume collateral_amount is 3,self.0 is 2,then liquidity_amout will be round(3/2)=2the returned collateral_amount will be round(2*2)=4 3,you can get more than you collateralizedReal caseNearX-$830KSelf-transferCapability(both ft_transferand ft_transfer_call invoke internal

13、_neax_transfer)Rustles Result:sender_acc and receiver_acc can be the sameReal caseCapabilityRustles Result:Wormhole-$321MLack of owner-checksecp_ix can be controlled with a fake accs.instruction_accUsabilityWith complex technology stack,Rustle is easy to useEasy to useEasy to set up:run a few comman

14、ds to installEasy to launch:./Rustle hEasy to deploy:Linux,macOS,DockerLaunch Rustle with a single command in multiple platformsUsabilityCLI,CSV,Notion,and etc.UsabilityResults in different formatsExtend Rustle to support locating new vulnerabilitiesWrite an LLVM pass as detector pluginAdd compiling

15、 option in MakefileSpecify severity in RustleComplete documentation and samples is preferredWelcome to ContributeUsabilityConclusion Rustle is the first static analyzer for smart contracts in Rust and has been integrated into our workflow Rustle supports checking various types of security vulnerabilities and can identify them in the wild Rustle is highly scalable and can be easily extended to support new features Rustle is open source(https:/ powered by BlockSec(https:/ you!Q&A Email: Website:https:/ Medium:https:/

友情提示

1、下載報告失敗解決辦法
2、PDF文件下載后,可能會被瀏覽器默認打開,此種情況可以點擊瀏覽器菜單,保存網頁到桌面,就可以正常下載了。
3、本站不支持迅雷下載,請使用電腦自帶的IE瀏覽器,或者360瀏覽器、谷歌瀏覽器下載即可。
4、本站報告下載后的文檔和圖紙-無水印,預覽文檔經過壓縮,下載后原文更清晰。

本文(MatthewJiang-Rustle - 2023RustChinaCon.pdf)為本站 (2200) 主動上傳,三個皮匠報告文庫僅提供信息存儲空間,僅對用戶上傳內容的表現方式做保護處理,對上載內容本身不做任何修改或編輯。 若此文所含內容侵犯了您的版權或隱私,請立即通知三個皮匠報告文庫(點擊聯系客服),我們立即給予刪除!

溫馨提示:如果因為網速或其他原因下載失敗請重新下載,重復下載不扣分。
客服
商務合作
小程序
服務號
折疊
午夜网日韩中文字幕,日韩Av中文字幕久久,亚洲中文字幕在线一区二区,最新中文字幕在线视频网站