owned this note changed 5 years ago
Linked with GitHub

金錢樂高遊戲的潛在風險:從 DeFi 攻擊事件簿中可以學到什麼? - Charles

tags: COSCUP2020 入門 TR413-1

歡迎來到 https://hackmd.io/@coscup/2020 共筆

Image Not Showing Possible Reasons
  • The image file may be corrupted
  • The server hosting the image is unavailable
  • The image path is incorrect
  • The image format is not supported
Learn More →

點擊本頁上方的 開始用 Markdown 一起寫筆記!
手機版請點選上方 按鈕展開議程列表。

請從這裡開始

Slides

DeFi x Security

了解原理後防止再次發生 secuirty issue

Type1: Re-entrancy Attack

smart contact's race confition issue

variable handle problem

How to defense?

可以使用現有的 library

Type2: Flash Loan

  • 無抵押貸款
  • 利息低、額度高
  • 借款及還款必須在同一筆 tx 完成,否則 revert()

相關的 document 不夠完備

Flash lender and borrower

  • 提供 liquidator & arbitrager 利用

AAVE protocol

案例

bZx hack

  • 首次 Flash Loan 的攻擊案例
  • 短期內連續被攻擊兩次
    • 套利
    • 操縱價格波動

Flash attacker will be the new normal
因為可以快速且可以獲得大量的資金,所以攻擊變得容易

How to defense?

因為 Flash Loan 不是 bug,而是邏輯上的問題
避免單一 tx 內,大量資金操作後被revert掉所造成的價差

Type3: Front Running

  • 搶單交易
  • 來自於底層 protocol 的特性(廣播交易、15 秒區塊時間)
  • Tracsaction order DOES matters
  • 較難偵測與區分惡意行為

競爭交易順序

Class of Front Running

Priority Gas Auction

拍賣競標 Gas Price 的行為

Arbitrage market price

Bot profit

參考論文

MEV

Miner-extractable value

  • 區塊鏈獎勵以外的潛在收益
  • 來源之一:透過操縱交易順序,礦工可以得到的報酬

What if MEV > block reard?

  • 上層應用危及底層protocol
  • 礦工會嘗試fork
    • Undercutting attacks
    • Time-bandit attacks
      挖礦獎勵變少,交易手續價值提高

How to defense

要從 protocol 方面下手

要更動 protocol 沒有這麼快,
但還是可以從 commit-reveal 下手。(可以使用既有的 library)

Summary

樂高疊下去有可能有新的風險

Permissionless 下的安全隱憂:

Select a repo