s2b
  • NEW!
    NEW!  Connect Ideas Across Notes
    Save time and share insights. With Paragraph Citation, you can quote others’ work with source info built in. If someone cites your note, you’ll see a card showing where it’s used—bringing notes closer together.
    Got it
        • Sharing URL Link copied
        • /edit
        • View mode
          • Edit mode
          • View mode
          • Book mode
          • Slide mode
          Edit mode View mode Book mode Slide mode
        • Customize slides
        • Note Permission
        • Read
          • Owners
          • Signed-in users
          • Everyone
          Owners Signed-in users Everyone
        • Write
          • Owners
          • Signed-in users
          • Everyone
          Owners Signed-in users Everyone
        • Engagement control Commenting, Suggest edit, Emoji Reply
      • Invite by email
        Invitee

        This note has no invitees

      • Publish Note

        Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note No publishing access yet

        Your note will be visible on your profile and discoverable by anyone.
        Your note is now live.
        This note is visible on your profile and discoverable online.
        Everyone on the web can find and read all notes of this public team.

        Your account was recently created. Publishing will be available soon, allowing you to share notes on your public page and in search results.

        Your team account was recently created. Publishing will be available soon, allowing you to share notes on your public page and in search results.

        Explore these features while you wait
        Complete general settings
        Bookmark and like published notes
        Write a few more notes
        Complete general settings
        Write a few more notes
        See published notes
        Unpublish note
        Please check the box to agree to the Community Guidelines.
        View profile
      • Commenting
        Permission
        Disabled Forbidden Owners Signed-in users Everyone
      • Enable
      • Permission
        • Forbidden
        • Owners
        • Signed-in users
        • Everyone
      • Suggest edit
        Permission
        Disabled Forbidden Owners Signed-in users Everyone
      • Enable
      • Permission
        • Forbidden
        • Owners
        • Signed-in users
      • Emoji Reply
      • Enable
      • Versions and GitHub Sync
      • Note settings
      • Note Insights New
      • Engagement control
      • Make a copy
      • Transfer ownership
      • Delete this note
      • Insert from template
      • Import from
        • Dropbox
        • Google Drive
        • Gist
        • Clipboard
      • Export to
        • Dropbox
        • Google Drive
        • Gist
      • Download
        • Markdown
        • HTML
        • Raw HTML
    Menu Note settings Note Insights Versions and GitHub Sync Sharing URL Help
    Menu
    Options
    Engagement control Make a copy Transfer ownership Delete this note
    Import from
    Dropbox Google Drive Gist Clipboard
    Export to
    Dropbox Google Drive Gist
    Download
    Markdown HTML Raw HTML
    Back
    Sharing URL Link copied
    /edit
    View mode
    • Edit mode
    • View mode
    • Book mode
    • Slide mode
    Edit mode View mode Book mode Slide mode
    Customize slides
    Note Permission
    Read
    Owners
    • Owners
    • Signed-in users
    • Everyone
    Owners Signed-in users Everyone
    Write
    Owners
    • Owners
    • Signed-in users
    • Everyone
    Owners Signed-in users Everyone
    Engagement control Commenting, Suggest edit, Emoji Reply
  • Invite by email
    Invitee

    This note has no invitees

  • Publish Note

    Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note No publishing access yet

    Your note will be visible on your profile and discoverable by anyone.
    Your note is now live.
    This note is visible on your profile and discoverable online.
    Everyone on the web can find and read all notes of this public team.

    Your account was recently created. Publishing will be available soon, allowing you to share notes on your public page and in search results.

    Your team account was recently created. Publishing will be available soon, allowing you to share notes on your public page and in search results.

    Explore these features while you wait
    Complete general settings
    Bookmark and like published notes
    Write a few more notes
    Complete general settings
    Write a few more notes
    See published notes
    Unpublish note
    Please check the box to agree to the Community Guidelines.
    View profile
    Engagement control
    Commenting
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    • Everyone
    Suggest edit
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    Emoji Reply
    Enable
    Import from Dropbox Google Drive Gist Clipboard
       Owned this note    Owned this note      
    Published Linked with GitHub
    • Any changes
      Be notified of any changes
    • Mention me
      Be notified of mention me
    • Unsubscribe
    --- title: 오라클 해킹 - Inverse Finance tags: security description: --- <style> html, body, .ui-content { background-color: #333; color: #ddd; } .markdown-body h1, .markdown-body h2, .markdown-body h3, .markdown-body h4, .markdown-body h5, .markdown-body h6 { color: #ddd; } .markdown-body h1, .markdown-body h2 { border-bottom-color: #ffffff69; } .markdown-body h1 .octicon-link, .markdown-body h2 .octicon-link, .markdown-body h3 .octicon-link, .markdown-body h4 .octicon-link, .markdown-body h5 .octicon-link, .markdown-body h6 .octicon-link { color: #fff; } .markdown-body img { background-color: transparent; } .ui-toc-dropdown .nav>.active:focus>a, .ui-toc-dropdown .nav>.active:hover>a, .ui-toc-dropdown .nav>.active>a { color: white; border-left: 2px solid white; } .expand-toggle:hover, .expand-toggle:focus, .back-to-top:hover, .back-to-top:focus, .go-to-bottom:hover, .go-to-bottom:focus { color: white; } .ui-toc-dropdown { background-color: #333; } .ui-toc-label.btn { background-color: #191919; color: white; } .ui-toc-dropdown .nav>li>a:focus, .ui-toc-dropdown .nav>li>a:hover { color: white; border-left: 1px solid white; } .markdown-body blockquote { color: #bcbcbc; } .markdown-body table tr { background-color: #5f5f5f; } .markdown-body table tr:nth-child(2n) { background-color: #4f4f4f; } .markdown-body code, .markdown-body tt { color: #eee; background-color: rgba(230, 230, 230, 0.36); } a, .open-files-container li.selected a { color: #5EB7E0; } </style> 오라클 해킹 - Inverse Finance === 오라클이란 --- - 오라클이란, 블록체인의 on-chain 데이터와 블록체인 외부의 off-chain 데이터를 연결해주는 역할이다. 대표적으로 ChainLink 가 있는데, 예를 들어, 이더리움에서 랜덤 함수를 사용할 때 ChainLink 를 사용한다. 참고로, 랜덤 함수를 블록체인에서 하지 못하는 이유는 랜덤 함수의 seed는 예측할 수 없어야 하는 정보이기 때문에 모든 사람이 볼 수 있는 블록체인에서는 관리할 수 없다. - 오라클의 또다른 사례로는 Defi 에서 볼 수 있다. Defi 는 각자 보유하고 있는 유동성 풀의 비율이 다를 수 있다. A라는 거래소와 B라는 거래소가 동일한 BTC/ETH 비율을 유지할 것이라고 기대하기는 어렵다. 따라서, 이러한 Defi들은 오라클을 두고, 이 오라클을 통해서 기준이 되는 외부 거래소의 정보를 통해 가격을 조정한다. - 대부분의 Defi들은 ChainLink와 같은 검증된 오라클을 사용하는데, 때때로, 검증되지 않은 오라클을 사용하는 경우도 있는데, 그런 경우는 기존에 존재하는 오라클이 지원하지 않는 추가적인 기능이 필요할 때는 자체적으로 오라클을 개발해서 사용하는 경우이다. 예를 들어, 이번 사건의 Inverse Finance 의 경우 Keep3r 이라는 자체 오라클을 사용하고 있었다. 해킹 과정 --- 해커는 오라클 설계의 취약점을 이용하여 다음과 같은 작업을 하였다. 참고: https://twitter.com/FrankResearcher/status/1510239113756168194 1. 토네이도 캐시*에서 901 ETH 를 출금함. 2. Disperse** 를 통해 241개의 이더리움 계좌에 각각 1.5 ETH 씩 총 361.5 ETH 를 송금함. 3. 241개의 계좌는 DDoS 공격처럼 5개의 Smart Contract를 수행할 준비를 함. 이 중 하나만이 공격용 Contract이고, 나머지는 혼란을 주기 위한 연막용 Contract 였음. 4. 공격에 앞서, 해커는 스시스왑에서 500 ETH를 1700 INV 로 스왑하여 일시적으로 유동성 풀의 비율을 변경시켜버림. 5. 일반적인 경우, 이렇게 풀의 비율은 급변한 경우 Arbitrage bot이 이를 바로잡는 역할을 하지만, 이번 경우는 241개의 계정이 수행한 스팸성 Smart Contract들때문에 Arbitrage bot 이 정상적으로 가격 조정하지 못함. 6. Inverse Finance의 자체 오라클인 Keep3r은 스시스왑의 오라클인 TWAP을 사용하고 있었고, TWAP은 짧은 시간 샘플을 기반으로 가격을 결정하는 취약점이 있었음. 7. 해커는 이를 이용하여 일시적으로 풀의 비율을 변경시킨 것이고, 스팸성 Smart Contract를 통해 가격이 정상화되는 것을 막은 것임. 8. 따라서, 오라클은 일시적으로 INV의 가치를 높게 평가하는 착각을 하게 됨. 9. 해커는 Anchor 라는 Inverse Finance 에서 제공하는 Defi를 활용하여 높게 평가된 1700 INV 를 담보로 영구적으로 ETH로 대출 받았음. 10. 그 결과, 일시적으로 가치를 높인 INV를 담보로 처음에 스왑했던 500ETH 보다 더 많은 가치의 ETH의 시세차익을 볼 수 있었음. 11. 흥미로운 것은, 해커 또한 오라클이 예상보다 빨리 가격을 조정했으면 막대한 손실을 볼 수 있던 해킹 수법이었음. *PeckShield 에서 공개한 Attack Flow* ![](https://i.imgur.com/JPWknvW.png) 사건에 대한 언급들 --- [ChainLinkGod](https://twitter.com/chainlinkgod/status/1510298134202572800?s=21&t=mYGxl3w-OSq78TqYpc-zgg) > "짧은 시간동안 거래가 많지 않은 단일 DEX 트레이딩 페어에서 만들어진 TWAP 오라클에 의존하는 것은 시장 조작의 위험성을 엄청나게 높일 수 있습니다." *INV는 Inverse Finance 와 스시스왑에서 밖에 거래가 되지 않았기 때문에 low volume, thinly traded 되고 있는 토큰이라고 볼 수 있었음.* > "거래량이 많지 않은 토큰 (thinly traded) 담보로 대출해주는 것은 사용자들을 위험에 노출시키는 것입니다" > "TWAP 의 문제점은 가격 결정에 대해서 너무 짧은 time sample을 사용한 것입니다." (참고: [TWAP vs ChainLink VWAP](https://smartcontentpublication.medium.com/twap-oracles-vs-chainlink-price-feeds-a-comparative-analysis-8155a3483cbd)) [Michael Bentley](https://twitter.com/euler_mab/status/1510243496015368193) > 1. "Thinly traded 한 토큰을 담보로 해주지 마라" > 2. Arbitrage Bot 은 Arbitrage opportuinity 가 있을 때만 동작한다. > 3. 해커들 또한 자칫하면 많은 돈을 잃을 수 있는 해킹 수법이다. 결론 --- - Waves 폭락 사건과 마찬가지로 대출 시 자체 토큰에 대해 안정적인 토큰 (BTC, ETH 등) 의 담보 비율을 너무 높게 잡은 것이 첫 번째 문제라고 한다. - 두 번째 문제는, 오라클이 일시적인 가격 변동에 대해서 착각하지 않도록 설계가 잘 되었어야 했는데 그렇지 못했다는 것이다. ChainLink 는 스시스왑의 이러한 설계 문제점을 지적했는데, 이 두 가지 문제점에서 발생하는 취약점을 이용한 해킹은 Defi 에서 비일비재하기 때문에 Lending Protocol 을 개발해야할 때 유의해야 한다. 추가자료 --- \* 토네이도 캐시 (Tornado Cash): Transaction 을 마구 섞어서 누가 누구한테 보낸 것인지 찾을 수 없도록 만든 private transaction 을 위한 툴. [자세히](/oJR-Q8N_R8-pMq_WM5OrGA) \** Disperse: 여러 개의 이더리움 계좌에서 Transaction 을 발생시킬 수 있도록 하는 자동화 툴. [자세히](https://www.daomasters.xyz/tools/disperse ) 참고자료 --- [1] https://rekt.news/ko/inverse-finance-rekt/ [2] https://twitter.com/FrankResearcher/status/1510239113756168194 [3] https://twitter.com/bertcmiller/status/1510246695929532417?s=21&t=TKrULBbJo5NiglPzNffQyw

    Import from clipboard

    Paste your markdown or webpage here...

    Advanced permission required

    Your current role can only read. Ask the system administrator to acquire write and comment permission.

    This team is disabled

    Sorry, this team is disabled. You can't edit this note.

    This note is locked

    Sorry, only owner can edit this note.

    Reach the limit

    Sorry, you've reached the max length this note can be.
    Please reduce the content or divide it to more notes, thank you!

    Import from Gist

    Import from Snippet

    or

    Export to Snippet

    Are you sure?

    Do you really want to delete this note?
    All users will lose their connection.

    Create a note from template

    Create a note from template

    Oops...
    This template has been removed or transferred.
    Upgrade
    All
    • All
    • Team
    No template.

    Create a template

    Upgrade

    Delete template

    Do you really want to delete this template?
    Turn this template into a regular note and keep its content, versions, and comments.

    This page need refresh

    You have an incompatible client version.
    Refresh to update.
    New version available!
    See releases notes here
    Refresh to enjoy new features.
    Your user state has changed.
    Refresh to load new user state.

    Sign in

    Forgot password
    or
    Sign in via Google Sign in via Facebook Sign in via X(Twitter) Sign in via GitHub Sign in via Dropbox Sign in with Wallet
    Wallet ( )
    Connect another wallet

    New to HackMD? Sign up

    By signing in, you agree to our terms of service.

    Help

    • English
    • 中文
    • Français
    • Deutsch
    • 日本語
    • Español
    • Català
    • Ελληνικά
    • Português
    • italiano
    • Türkçe
    • Русский
    • Nederlands
    • hrvatski jezik
    • język polski
    • Українська
    • हिन्दी
    • svenska
    • Esperanto
    • dansk

    Documents

    Help & Tutorial

    How to use Book mode

    Slide Example

    API Docs

    Edit in VSCode

    Install browser extension

    Contacts

    Feedback

    Discord

    Send us email

    Resources

    Releases

    Pricing

    Blog

    Policy

    Terms

    Privacy

    Cheatsheet

    Syntax Example Reference
    # Header Header 基本排版
    - Unordered List
    • Unordered List
    1. Ordered List
    1. Ordered List
    - [ ] Todo List
    • Todo List
    > Blockquote
    Blockquote
    **Bold font** Bold font
    *Italics font* Italics font
    ~~Strikethrough~~ Strikethrough
    19^th^ 19th
    H~2~O H2O
    ++Inserted text++ Inserted text
    ==Marked text== Marked text
    [link text](https:// "title") Link
    ![image alt](https:// "title") Image
    `Code` Code 在筆記中貼入程式碼
    ```javascript
    var i = 0;
    ```
    var i = 0;
    :smile: :smile: Emoji list
    {%youtube youtube_id %} Externals
    $L^aT_eX$ LaTeX
    :::info
    This is a alert area.
    :::

    This is a alert area.

    Versions and GitHub Sync
    Get Full History Access

    • Edit version name
    • Delete

    revision author avatar     named on  

    More Less

    Note content is identical to the latest version.
    Compare
      Choose a version
      No search result
      Version not found
    Sign in to link this note to GitHub
    Learn more
    This note is not linked with GitHub
     

    Feedback

    Submission failed, please try again

    Thanks for your support.

    On a scale of 0-10, how likely is it that you would recommend HackMD to your friends, family or business associates?

    Please give us some advice and help us improve HackMD.

     

    Thanks for your feedback

    Remove version name

    Do you want to remove this version name and description?

    Transfer ownership

    Transfer to
      Warning: is a public team. If you transfer note to this team, everyone on the web can find and read this note.

        Link with GitHub

        Please authorize HackMD on GitHub
        • Please sign in to GitHub and install the HackMD app on your GitHub repo.
        • HackMD links with GitHub through a GitHub App. You can choose which repo to install our App.
        Learn more  Sign in to GitHub

        Push the note to GitHub Push to GitHub Pull a file from GitHub

          Authorize again
         

        Choose which file to push to

        Select repo
        Refresh Authorize more repos
        Select branch
        Select file
        Select branch
        Choose version(s) to push
        • Save a new version and push
        • Choose from existing versions
        Include title and tags
        Available push count

        Pull from GitHub

         
        File from GitHub
        File from HackMD

        GitHub Link Settings

        File linked

        Linked by
        File path
        Last synced branch
        Available push count

        Danger Zone

        Unlink
        You will no longer receive notification when GitHub file changes after unlink.

        Syncing

        Push failed

        Push successfully