Yearn Finance Legacy Contract Exploited
Notice: This page is a freshly imported case study from the original repository. The original content was in a different format, and may not have relevant information for all sections. Please help restructure the content by moving information from the 'About' and 'General Prevention' sections to other sections, and add any missing information or sources you can find. If you are new here, please read General Tutorial on Wikis or Anatomy of a Case Study for help getting started.
Yearn is a decentralized finance (DeFi) protocol that allows individuals, DAOs, and other protocols to earn yield on their digital assets. One of Yearn's core products is its Vaults, which are capital pools that generate yield based on market opportunities. Yearn's governance process is controlled by YFI token holders who submit and vote on off-chain proposals, with proposals that generate majority support being implemented by a 9-member multi-signature wallet. Recently, Yearn's yUSDT token contract was hacked due to a misconfiguration that had been present for over three years. The attacker was able to exploit the misconfiguration to manipulate the underlying share prices of yUSDT and mint a large quantity of yUSDT using just 10k USDT. The attacker was funded via Tornado Cash and deposited 1000 ETH for laundering. The attacker's first two addresses contain approximately $1.5M of assets each, and the third address contains 7.4M DAI.
About Yearn Finance
Yearn is a decentralized suite of DeFi products that enables individuals, DAOs, and other protocols to earn yield on their digital assets. The platform offers Yearn Vaults, which are capital pools that automatically generate yield based on market opportunities, automating the yield generation and rebalancing process while also socializing gas costs and automatically shifting capital as opportunities arise. End users do not need to have proficient knowledge of underlying protocols or DeFi to use the Vaults, making them a passive-investing strategy. Yearn Finance is DeFi's leading yield aggregator and is governed by YFI token holders who submit and vote on off-chain proposals that govern the ecosystem. Proposals that generate majority support are implemented by a 9-member multi-signature wallet, and changes must be signed by 6 out of the 9 wallet signers to be implemented[1][2][3].
"Considered by many as one of DeFi’s most reliable, secure platforms, Yearn made it’s name by offering some of the sector’s simplest farming opportunities."
"Yearn is a decentralized suite of products helping individuals, DAOs, and other protocols earn yield on their digital assets."
"Yearn Finance is DeFi’s premier yield aggregator. Giving individuals, DAOs and other protocols a way to deposit digital assets and receive yield."
"The protocol is maintained by various independent developers and is governed by YFI holders. You can find brief descriptions of Yearn's core products, the governance process, and links to active communication channels below."
"Vaults. Yearn Vaults are capital pools that automatically generate yield based on opportunities present in the market. Vaults benefit users by socializing gas costs, automating the yield generation and rebalancing process, and automatically shifting capital as opportunities arise. End users also do not need to have proficient knowledge of the underlying protocols involved or DeFi, thus the Vaults represent a passive-investing strategy."
"Governance. The Yearn ecosystem is controlled by YFI token holders who submit and vote on off-chain proposals that govern the ecosystem. Proposals that generate majority support (>50% of the vote) are implemented by a 9-member multi-signature wallet. Changes must be signed by 6 out of the 9 wallet signers to be implemented. The members of the multi-signature wallet were voted in by YFI holders and are subject to change from future governance votes. Please refer to the multisig documentation for the list of multisig signers. For more info about the governance process, please consult the Governance FAQ and YIP-61: Governance 2.0."
The Reality
This sections is included if a case involved deception or information that was unknown at the time. Examples include:
- When the service was actually started (if different than the "official story").
- Who actually ran a service and their own personal history.
- How the service was structured behind the scenes. (For example, there was no "trading bot".)
- Details of what audits reported and how vulnerabilities were missed during auditing.
What Happened
The specific events of the loss and how it came about. What actually happened to cause the loss and some of the events leading up to it.
Date | Event | Description |
---|---|---|
April 12th, 2023 11:52:35 PM MDT | First Attack Transaction | One of the attack transactions[4]. |
April 13th, 2023 1:42:00 AM MDT | BlockSec Twitter Analysis | BlockSec publishes an analysis of the exploit to Twitter[5]. |
April 13th, 2023 2:54:00 AM MDT | Yearn Finance Announcement | Yearn Finance shares an initial announcement about the exploit on Twitter, and states that users should "stay tuned" as they are still investigating the situation[6]. |
April 13th, 2023 3:14:00 AM MDT | MetaSleuth Shares Analysis | Twitter user MetaSleuth shares an analysis to Twitter[7], including a Google Sheet which he set up to track the total protocol loss[8]. |
April 13th, 2023 5:08:00 AM MDT | Beosin Security Tweet | Beosin Security offered "attack event analysis"[9]. |
April 13th, 2023 12:27:00 PM MDT | RektHQ Published Article | RektHQ publishes an article on the exploit[10][11]. |
April 13th, 2023 4:40:00 PM MDT | Yearn Finance Further Analysis | Yearn Finance posts a further analysis of the effects of the attack[12]. |
Technical Details
This section includes specific detailed technical analysis of any security breaches which happened. What specific software vulnerabilities contributed to the problem and how were they exploited?
BlockSecTeam Analysis
BlockSecTeam posted an initial analysis to Twitter[5].
"@iearnfinance was hacked with two consecutive attack transactions. The root cause is due to an (on-purpose?) misconfiguration which makes the rebalance of the pools rely on an incorrect underlying token. This misconfiguration has been there for more than three years."
MetaSleuth Analysis
Yearn Finance Analysis
Yearn Finance released a statement on Twitter which described the effects[6][12].
We're looking into an issue with iearn, an outdated contract from before Vaults v1 and v2.
This problem seems exclusive to iearn and does not impact current Yearn contracts or protocols.
iearn is an immutable contract predating YFI, it was deprecated in 2020.
Vaults v1, with upgradeable strategies, was also deprecated in 2021. There's no indication it's affected.
The current version, Yearn v2 Vaults (written in Vyper), remains unaffected as well.
Stay tuned for updates as our team investigates further.
As previously pointed out, the root cause of this morning's iEarn exploit was a bug in the legacy iEarn USDT (yUSDT) token contract.
This bug persisted in several versions and led to multiple Curve pools (y, busd, pax) being exploited and drained. Liquidity providers who deposited their LP tokens into downstream protocols are still impacted.
This includes users of the Yearn v2 vaults (2) and legacy v1 vaults (2) which wrapped these affected LPs.
Other Analysis
TBD need to attribute these[10].
"The immutable yUSDT contract that was attacked was deployed over three years ago, back when Yearn was Andre Cronje’s iearn finance.
While the strategy was superceded by newer versions, plenty of funds still remained in the original contract. Later Yearn vault contracts are not affected."
"Despite a last-minute warning on Twitter, immutable contracts can’t be saved."
"Team member storming0x acknowledged the attack before Yearn reassured users that current contracts were unaffected."
"1156 days to spot a multimillion dollar vulnerability in one of DeFi’s longest established protocols."
"The attacker exploited a misconfiguration in the iearn yUSDT token contract.
The token generated yield via an underlying basket of yield-bearing tokens, including USDT positions on Aave, Compound, DYDX and BzX’s Fulcrum.
However, since launch, the yUSDT has contained what appears to be a copy/paste error whereby the Fulcrum USDC address was used instead of the Fulcrum USDT contract.
The exploiter was able to take advantage of the misconfiguration to vastly manipulate the underlying share prices of yUSDT, and mint a large quantity (1.2 quadrillion) of yUSDT using just 10k USDT."
"The attacker was funded via Tornado Cash and redeposited 1000 ETH for laundering. At the time of writing, the first two exploiter addresses contain approximately $1.5M of assets each, and address 3 contains 7.4M DAI."
Total Amount Lost
The total amount lost has been estimated at $11,400,000 USD.
How much was lost and how was it calculated? If there are conflicting reports, which are accurate and where does the discrepancy lie?
Immediate Reactions
How did the various parties involved (firm, platform, management, and/or affected individual(s)) deal with the events? Were services shut down? Were announcements made? Were groups formed?
Yearn Finance Twitter Announcement
Yearn Finance announced the exploit on Twitter, and that they were performing an investigation[6].
We're looking into an issue with iearn, an outdated contract from before Vaults v1 and v2.
This problem seems exclusive to iearn and does not impact current Yearn contracts or protocols.
iearn is an immutable contract predating YFI, it was deprecated in 2020.
Vaults v1, with upgradeable strategies, was also deprecated in 2021. There's no indication it's affected.
The current version, Yearn v2 Vaults (written in Vyper), remains unaffected as well.
Stay tuned for updates as our team investigates further.
A few hours later, the full effects of the exploit were provided[12].
As previously pointed out, the root cause of this morning's iEarn exploit was a bug in the legacy iEarn USDT (yUSDT) token contract.
This bug persisted in several versions and led to multiple Curve pools (y, busd, pax) being exploited and drained. Liquidity providers who deposited their LP tokens into downstream protocols are still impacted.
This includes users of the Yearn v2 vaults (2) and legacy v1 vaults (2) which wrapped these affected LPs.
Beosin Security Offer Of Help
Beosin Security reached out to offer assistance[9].
Hi, This is Beosin Security. Our security monitoring product has detected that your contract may be under attack. If you need any assistance, we are ready to help. We can provide attack event analysis
Other Reactions From Twitter Community
User Marty seems to be out of luck as well[13].
I put in after the hack not realising about the hack. Is my money gone too?
Ultimate Outcome
What was the end result? Was any investigation done? Were any individuals prosecuted? Was there a lawsuit? Was any tracing done?
Total Amount Recovered
There do not appear to have been any funds recovered in this case.
What funds were recovered? What funds were reimbursed for those affected users?
Ongoing Developments
What parts of this case are still remaining to be concluded?
General Prevention Policies
The vulnerabilities were known for multiple years. Better education and awareness is needed to stop using vulnerable smart contracts.
Individual Prevention Policies
Avoid the use of smart contracts unless necessary. Minimize the level of exposure by removing or withdrawing assets whenever possible. Aim to choose smart contracts which have obtained third party security audits, preferably having been audited by at least three separate reputable firms. Pay attention to the audit reports, which smart contracts are covered, and whether the smart contract has been upgraded or modified since the report. Ensure that any administrative functions with the ability to remove funds from the smart contract are under the authority of a multi-signature wallet which is controlled by at least three separate and reputable entities.
For the full list of how to protect your funds as an individual, check our Prevention Policies for Individuals guide.
Platform Prevention Policies
All platforms should undergo published security and risk assessments by independent third parties. Two assessments are required at founding or major upgrade, one after 3 months, and one every 6 months thereafter. The third parties must not repeat within the past 14 months. A risk assessment needs to include what assets back customer deposits and the risk of default from any third parties being lent to. The security assessment must include ensuring a proper multi-signature wallet, and that all signatories are properly trained. Assessments must be performed on social media, databases, and DNS security.
For the full list of how to protect your funds as a financial service, check our Prevention Policies for Platforms guide.
Regulatory Prevention Policies
While the contract was immutable, it remained actively available (and promoted? TBD) for usage. This should have been avoided.
All platforms should undergo published security and risk assessments by independent third parties. Two assessments are required at founding or major upgrade, one after 3 months, and one every 6 months thereafter. The third parties must not repeat within the past 14 months. A risk assessment needs to include what assets back customer deposits and the risk of default from any third parties being lent to. The security assessment must include ensuring a proper multi-signature wallet, and that all signatories are properly trained. Assessments must be performed on social media, databases, and DNS security.
For the full list of regulatory policies that can prevent loss, check our Prevention Policies for Regulators guide.
References
- ↑ Yearn Finance Homepage (May 3, 2023)
- ↑ Yearn.finance Docs - Yearn Finance (May 3, 2023)
- ↑ Introduction - Yearn Finance Documents (Jan 8, 2022)
- ↑ Ethereum Attack Transaction - Etherscan (May 3, 2023)
- ↑ 5.0 5.1 BlockSecTeam - "The root cause is due to an (on-purpose?) misconfiguration which makes the rebalance of the pools rely on an incorrect underlying token." - Twitter (May 3, 2023)
- ↑ 6.0 6.1 6.2 YearnFi - "We're looking into an issue with iearn, an outdated contract from before Vaults v1 and v2." - Twitter (May 17, 2023)
- ↑ MetaSleuth - "@iearnfinance was hacked and the loss is around 11.4 million USD. The exploiter is actively converting the profits into stablecoins and has already laundered 1000 Ether into @TornadoCash." - Twitter (May 3, 2023)
- ↑ iearn yUSD exploit loss and current status - Google Sheets (May 3, 2023)
- ↑ 9.0 9.1 Beosin Security - "Hi, This is Beosin Security. Our security monitoring product has detected that your contract may be under attack. If you need any assistance, we are ready to help. We can provide attack event analysis" - Twitter (May 17, 2023)
- ↑ 10.0 10.1 Rekt - Yearn - REKT 2 (May 3, 2023)
- ↑ RektHQ - "1156 days to spot an eight-figure vulnerability in one of DeFi’s best known protocols." - Twitter (May 3, 2023)
- ↑ 12.0 12.1 12.2 Yearn Finance - "As previously pointed out, the root cause of this morning's iEarn exploit was a bug in the legacy iEarn USDT (yUSDT) token contract." - Twitter (May 17, 2023)
- ↑ Marty - "I put in after the hack not realising about the hack. Is my money gone too?" - Twitter (May 17, 2023)
Cite error: <ref>
tag with name "metasleuthtwitter-10758" defined in <references>
is not used in prior text.