Billy
    • Create new note
    • Create a note from template
      • 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
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Write
        • Only me
        • Signed-in users
        • Everyone
        Only me 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

      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.
      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
    • Engagement control
    • Transfer ownership
    • Delete this note
    • Save as template
    • Insert from template
    • Import from
      • Dropbox
      • Google Drive
      • Gist
      • Clipboard
    • Export to
      • Dropbox
      • Google Drive
      • Gist
    • Download
      • Markdown
      • HTML
      • Raw HTML
Menu Note settings Versions and GitHub Sync Note Insights Sharing URL Create Help
Create Create new note Create a note from template
Menu
Options
Engagement control 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
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Write
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me 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

    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.
    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
    Subscribed
    • Any changes
      Be notified of any changes
    • Mention me
      Be notified of mention me
    • Unsubscribe
    Subscribe
    [toc] # Synthetix Oracle ## Intro a Synthetix 是一個DeFi合成資產的 protocol,允許用戶 mint 和交易各種與現實世界資產(RWA)掛鉤的合成代幣 (Synth) - 法幣 - 加密貨幣 - 例如 sKRW (韓元), sETH以及原生token SNX - 大宗商品 整個系統的合成資產價格來自於**預言機 (Oracle) 提供的外部資料**,例如匯率、商品或加密貨幣的價格。 > https://kermankohli.substack.com/p/defi-audit-1-synthetix > https://medium.com/cortexlabs/defi科普系列之-三-深入理解synthetix如何玩转合成资产-47c4f585563e <br> ## Root Cause Synthetix在2019 年中發生了一次 [Oracle 報價錯誤](https://blog.synthetix.io/response-to-oracle-incident/),大致可以歸因於 - Synthetix Oracle 供應商的`sKRW` price feed出現了價格錯誤 - Synthetix 只使用了兩個private oracle feed 此次價格錯誤讓`sKRW/sETH`的匯率從 `360,000 sKRW:1 sETH` -> 變成了高價 `720 sKRW:1 sETH` 導致持有`sKRW`的套利機器人帳戶的明面資產被膨脹 攻擊者隨後將"被通膨"的`sKRW`轉換成 `sETH`實現套利 > Two API’s had different independent outages simultaneously, and our error handling and aggregation logic failed to handle this. > The pricing error was intermittently setting the rate for KRW to 1000x more than it actually was. https://blog.synthetix.io/response-to-oracle-incident/ <br> ## Attack Procedure 攻擊流程相對簡單,攻擊者(套利機器人)只是在對的時間點實行`exchange` function進行兌換 https://etherscan.io/tx/0x93819f6bbea390d7709fa033f5733d16418674e99c43b9ed23adb4110d657f0c ![截圖 2024-12-24 上午10.34.25](https://hackmd.io/_uploads/Syp3aqDHJx.png) <br> 此次事件,攻擊者同意reserve這筆交易以換取bounty > We have since been in contact with the owner of the bot, who has agreed to reverse the trades in exchange for a bug bounty. ## Remediation 文中Synthetix提及將Oracle換成Chainlink,但也建議增加下列defense - Real time monitoring price feed - Circuit breaker - 當Oracle價格出現失準,合約應該要能暫停交易以避免被套利 - 更多的Oracle供應商避免SPoF (single point of failure) <br> # BedRock Flash Loan Attack ## Introduction [Bedrock](https://docs.bedrock.technology/) is a multiple asset liquid restaking protocol, that backed by non-custodial solution designed in partnership with RockX, a longstanding blockchain infrastructure company with strong roots in crypto staking. Bedrock support multiple assets to do both restaking / staking including: * uniBTC: A restaking protocol that accept wrapped BTC tokens partnership with the BTC staking protocol Babylon chain, the first supported wrapped BTC is wBTC token on Ethereum blockchain, so all the wBTC token holders will enjoy both yield on staking BTC tokens plus the security of Ethereum network. <br> ## Reference - [DefiHackedLabs Poc](https://github.com/SunWeb3Sec/DeFiHackLabs/blob/main/src/test/2024-09/Bedrock_DeFi_exp.sol) - [Certik Alert Twitter](https://x.com/certikalert/status/1839403126694326374) - [Verichain Medium](https://blog.verichains.io/p/bedrock-defi-incident-analysis) - [Lunaray Medium](https://lunaray.medium.com/bedrock-unibtc-hack-analysis-7808902e5a7c) - [QuillAudits](https://www.quillaudits.com/blog/hack-analysis/bedrock-2million-exploit) - [New uniBTC](https://github.com/Bedrock-Technology/uniBTC/blob/main/contracts/contracts/uniBTC.sol) ## Contract links - [Attacker contract](https://etherscan.io/address/0x2bFB373017349820dda2Da8230E6b66739BE9F96) - [Exploit contract](https://etherscan.io/address/0x1e1d02d663228e5d47f1de64030b39632a3b787d#internaltx) - [uniBTC contract](https://etherscan.io/token/0x004e9c3ef86bc1ca1f0bb5c7662861ee93350568) Already fixed - [Exploit transaction](https://etherscan.io/tx/0x725f0d65340c859e0f64e72ca8260220c526c3e0ccde530004160809f6177940) - [Blocksec On-chain analysis](https://app.blocksec.com/explorer/tx/eth/0x725f0d65340c859e0f64e72ca8260220c526c3e0ccde530004160809f6177940) ## Attack Steps 1. Borrowed 30.8 WETH through Balancer using flashloan ![image](https://hackmd.io/_uploads/r18yKxYSyx.png) 2. The attacker called the mint function of Bedrock Vault and transferred 30.8 ETH to Bedrock Vault ![image](https://hackmd.io/_uploads/B1EJsgFByl.png) Checking the source code of the Vault contract, we can clearly see that this contract expects the native token to be BTC. However, since this contract is deployed on the Ethereum chain, it produces an incorrect conversion ratio (1:1) between uniBTC and ETH, which is a simple but critical error 3. Attacker used 30.8 ETH to mint 30.8 uniBTC![image](https://hackmd.io/_uploads/rJ0acxYBkl.png) 4. Attacker exchanged 30.8 uniBTC for 27.8 WBTC through Uniswap V3![Uniswap](https://hackmd.io/_uploads/B11a1WKHyg.png) 5. Attacker exchanged the 27.8 WBTC for 680.4 WETH through Uniswap V3![Uniswap](https://hackmd.io/_uploads/rkCflbKHJe.png) 6. 30.8 WETH was repaid to Balancer![Balancer](https://hackmd.io/_uploads/rJI9Z-Yrkx.png) 7. Attacker finally made a profit of 649.6 WETH, which is about 1.7M USD ## Summary The cause of this vulnerability is that the exchange ratio of WETH and uniBTC was not properly handled, resulting in WETH and uniBTC being exchanged at 1:1, and the value of WETH was magnified tens of thousands of times. The attacker used the distorted price to make a profit through lending, and eventually the attacker used the borrowed WETH to empty the project’s uniBTC tokens. ## Lesson Learned For contracts that control the minting or holding of tokens, even a minor error can result in significant security vulnerabilities. Therefore, conducting a security audit before deploying contracts in the production environment is critically important.

    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

    By clicking below, you agree to our terms of service.

    Sign in via Facebook Sign in via Twitter Sign in via GitHub Sign in via Dropbox Sign in with Wallet
    Wallet ( )
    Connect another wallet

    New to HackMD? Sign up

    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