Level Finance Gets Leveled
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' section 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.
Level Finance is a decentralized perpetual exchange that offers innovative liquidity solutions and risk management for BTC, ETH, BNB, and stablecoins. Recently, the platform suffered an attack where $1.1 million in referral rewards were stolen due to a bug in the LevelReferralControllerV2 contract, allowing for repeated reward claims to be processed. The attacker used flash loans to create referrals and increase their reward tier, draining 214k LVL tokens, which were swapped for 3,345 BNB. Losses were contained to the referral program, with Treasury funds and LP remaining safe. The funds remain in the attacker's address.
About Level Finance
Level is a decentralized perpetual exchange that combines functional risk management and innovative liquidity solutions. The platform allows users to manage their exposure with just 1/50th collateral, and features a virtually zero slippage and low fee perpetual AMM for leveraged trading in BTC, ETH, BNB, and stablecoins. Level also offers user-elected credit exposure frameworks for liquidity providers, complete transparency, and generates revenue from trading and lending natively in cryptocurrency. The platform is designed to be permissionless with fully transparent open-source smart contracts on BNB Chain. The platform has a user-owned decentralized perpetual exchange and two tokens: the LVL utility token, which is earned via participation on the platform and staked for governance, and the LGO governance token, which is used to make major decisions relating to the platform via voting on the Level DAO[1].
"On-Demand Liquidity Meets Bespoke Risk Management. A Decentralized Perpetual Exchange with Functional Risk Management and Innovative Liquidity Solutions."
"Maximize Your Strategy. Manage your exposure with just 1/50th collateral. Best in kind perpetual AMM with virtually zero slippage and low fees."
"Leveraged Trading. Innovative liquidity solution for BTC, ETH, BNB, and stablecoins."
"Programmable Risk. Define your risk. Level offers an innovative user-elected credit exposure framework for liquidity providers."
"Complete Transparency. No custody, no accounts. Level is designed to be permissionless. Fully transparent open source smart contracts on BNB Chain"
"Real Yield. Revenue from trading and lending generates income natively in the cryptocurrency transacted."
"Decentralized Leadership. First of a kind user owned decentralized perpetual exchange."
Smart Contract Audits by Quantstamp and Obelisk Auditing
The project had previously obtained audits by two separate audit firms, Quantstamp[2] and Obelisk Auditing[3]. Both audits included the project's core contracts[4].
Quantstamp performed an audit for the Level Finance project based on the code present in the listed repositories. We also reviewed the on-chain configuration for the deployed contracts around the time of the writing of this report.
[Obelisk] auditors always conducted a manual visual inspection of the code to find security flaws that automatic tests would not find. Comprehensive tests are also conducted in a specific test environment that utilizes exact copies of the published contract. While conducting the audit, the Obelisk security team uses best practices to ensure that the reviewed contracts are thoroughly examined against all angles of attack. This is done by evaluating the codebase and whether it gives rise to significant risks.
The Reality
While auditing can often find common problems with a smart contract, it is not foolproof. Significant additional certainty can occur from seeking additional audits.
Quantstamp describes some limitations of the available documentation on the smart contract interfering with their auditing process[2].
Moreover, although the protocol does come with a documentation website, there is a distinct lack of detailed technical documentation. For a protocol of this size and complexity, it is important for the developers to provide this documentation for an audit. To account for this, we engaged in extensive communication with the Level Finance team to resolve our higher-level questions and concerns. However, this type of communication can never make up for the detailed explanations and guidance commonly provided by thorough technical documentation. The audit was impaired as a result.
"Level Finance’s LevelReferralControllerV2 contract contained a bug which allowed for repeated referral reward claims to be processed within the same epoch."
"The exploiter prepared the attack by creating many referrals and using flash loans to make swaps, thereby increasing their reward tier."
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.
"Yesterday, $1.1M in referral rewards were robbed from the BSC-based perps platform." "Luckily, the losses were contained to the project’s referral programme, with Treasury funds and LP both safe." "The hacker dumping LVL tokens for BNB initially crashed the price by 65%, though this has mostly recovered since."
| Date | Event | Description |
|---|---|---|
| November 6th, 2022 | Obelisk Auditing is Commissioned | Obelisk Auditing is commissioned to perform an audit[3]. |
| November 21st, 2022 | Obelisk Auditing Starts Audit Process | Obelisk Auditing begins the process of conducting their audit[3]. |
| January 9th, 2023 4:17:00 PM MST | Obelisk Auditing Reports Successful Audit | Obelisk auditing announces that they have completed their audit of the Level Finance core contracts[5]. This news is shared with the Level Finance community[6]. |
| February 1st, 2023 12:00:00 AM MST | Quantstamp Starts Auditing | Quantstamps starts the process of auditing the Level Finance smart contract[2]. |
| April 5th, 2023 7:00:00 PM MDT | Quantstamp Reports Successful Audit | Quantstamp announces that they have completed their audit of Level Finance[7]. This news is shared with the Level Finance community[8]. |
| April 23rd, 2023 11:11:16 PM MDT | Attacker Withdraws From TornadoCash | The exploiter withdraws 100 ETH from TornadoCash[9]. |
| April 24th, 2023 7:40:20 AM MDT | Funds Moved Between Wallets | The exploiter moves their funds from the TornadoCash receive wallet to their attack wallet[10][11]. |
| April 24th, 2023 7:43:32 AM MDT | Malicious Smart Contract Created | The attacker creates a smart contract for their initial attack attempt[12]. |
| April 24th, 2023 7:52:59 AM MDT | Initial Attack Attempted | The same attacker[11] attempts a similar attack against the Level Finance protocol[4][13], but failed[14]. "[An] attack was initially attempted over a week ago, but it seems nobody noticed." |
| April 24th, 2023 8:00:05 AM MDT | Attacker Gives Up | After 3 more failed attempts (4 in total) to use the malicious smart contract he'd created, the attacker appears to give up[15]. |
| May 1st, 2023 7:11:15 AM MDT | Guess Who's Back? | The attacker is back active again, with their first transaction upon returning[16]. TBD - Need to understand this transaction better. |
| May 1st, 2023 11:47:32 AM MDT | Malicious Smart Contract Creation | The attacker creates a new version of the smart contract to launch the attack with[17]. TBD what's the difference between the first and second smart contract? |
| May 1st, 2023 11:50:41 AM MDT | First Malicious Transaction | The first malicious attacker transactions occurred[18]. TBD more details. |
| May 1st, 2023 12:53:00 PM MDT | Definalist Tweet About Hack | Twitter user Definalist announces that Level Finance "is currently under attack from hackers" who are "currently withdrawing LVL tokens in increments of 15,000 using the delegate function"[19]. |
| May 1st, 2023 1:33:21 PM MDT | Attacker Moves Funds | The attacker moves his funds to a second wallet[20]. TBD Double check this transaction. |
| May 1st, 2023 2:54:00 PM MDT | Twitter Announcement | Level Finance first posts about the issue on Twitter. They report an exploit that targeted the Referral Controller Contract. The attacker drained 214k LVL tokens, worth approximately $1.1M, and swapped them for 3,345 BNB. The exploit was isolated from other contracts, and LP's and DAO treasury were unaffected. A fix is expected to be deployed in the next 12 hours, and more details will be provided[21]. |
| May 2nd, 2023 12:46:00 PM MDT | Remediation Proposal Announced | The Level Finance team posts a proposed remediation[22]. The team states they have already taken steps to secure the contract, and a fix will be pushed once the timelock expires. The team has proposed three options to minimize the impact on the community, including conducting a special auction to burn LVL tokens, creating a special LVL auction, and committing the DAO's treasury to buy or burn LVL tokens. LGO token holders are eligible to vote on the proposed options. Going forward, the team will place an emphasis on DevOps and OPSEC to minimize future attacks[23]. |
| May 2nd, 2023 2:54:00 PM MDT | Rekt News Report | The incident is reported on Rekt.news[24]. The news report states that on May 2, 2023, the Binance Smart Chain-based DeFi platform, Level Finance, suffered a hack that drained $1.1 million in referral rewards from its LevelReferralControllerV2 contract. The attacker used flash loans to increase their reward tier, and their successful attack went unnoticed for a week. The attack resulted from a bug in the contract that allowed repeated claims within the same epoch. The hack initially caused a 65% drop in LVL's price, but it has mostly recovered since. The incident highlights the need for improved on-chain monitoring systems to prevent future attacks on DeFi protocols[4]. |
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?
"Level Finance’s LevelReferralControllerV2 contract contained a bug which allowed for repeated referral reward claims to be processed within the same epoch."
"In total, 214k LVL tokens were drained by the exploiter, who swapped them for 3,345 BNB, worth approximately $1.1M at the time of writing. The funds currently remain in the attacker’s address."
Total Amount Lost
"In total, 214k LVL tokens were drained by the exploiter, who swapped them for 3,345 BNB, worth approximately $1.1M at the time of writing. The funds currently remain in the attacker’s address."
The total amount lost has been estimated at $1,802,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?
"The alarm was raised by definalist (whilst the attack was still ongoing) and confirmed two hours later by the Level Finance team."
Initial Posts on Twitter By Level Finance
Level Finance announced the exploit on Twitter shortly after it occurred[21].
An exploit targeted our Referral Controller Contract.
- 214k LVL tokens drained to exploiters address.
- Attacker swapped LVL to 3,345 BNB
- Exploit was isolated from other contracts.
- Fix to be deployed in 12 Hrs.
- LP's and DAO treasury UNAFFECTED.
More details to follow.
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?
Individual Prevention Policies
No specific policies for individual prevention have yet been identified in this case.
For the full list of how to protect your funds as an individual, check our Prevention Policies for Individuals guide.
Platform Prevention Policies
Policies for platforms to take to prevent this situation have not yet been selected in this case.
For the full list of how to protect your funds as a financial service, check our Prevention Policies for Platforms guide.
Regulatory Prevention Policies
No specific regulatory policies have yet been identified in this case.
For the full list of regulatory policies that can prevent loss, check our Prevention Policies for Regulators guide.
References
- ↑ Level - Decentralized Perpetual Exchange (May 3, 2023)
- ↑ 2.0 2.1 2.2 Level Finance Audit - Quantstamp (May 8, 2023)
- ↑ 3.0 3.1 3.2 Auditing Report - Obelisk Auditing (May 8, 2023)
- ↑ 4.0 4.1 4.2 Rekt - Level Finance - REKT (May 3, 2023)
- ↑ Obelisk Auditing - Our team has delivered the audit of @Level__Finance Core contracts." - Twitter (May 8, 2023)
- ↑ Level Finance - "We are happy to announce that @ObeliskOrg has published the audit report of #LEVEL core contracts." - Twitter (May 8, 2023)
- ↑ Quantstamp - We’ve completed the audit of @Level__Finance’s level-trading-contracts repo at commit 28b2dc5 and level-core-contracts repo at commit 55bdced." - Twitter (May 8, 2023)
- ↑ Level Finance - "Quantstamp has completed the auditing of #LEVEL smart contracts." - Twitter (May 8, 2023)
- ↑ TornadoCash Withdrawal of 100 ETH By Attacker - BscScan (May 5, 2023)
- ↑ Attacker Shifting Funds To Attack Wallet - BscScan (May 5, 2023)
- ↑ 11.0 11.1 Level Finance Attacker's Address - BscScan (May 5, 2023)
- ↑ Attempted Malicious Smart Contract Creation - BscScan (May 5, 2023)
- ↑ BlockSecTeam - "@Level__Finance was reported to be hacked due to the lack of checks of repeated items for the array argument of the vulnerable function." - Twitter (May 5, 2023)
- ↑ First Attempt At Exploit - BscScan (May 5, 2023)
- ↑ Attacker's Fourth Failed Attempt - BscScan (May 5, 2023)
- ↑ Attacker Returns With Another Transaction - BscScan (May 5, 2023)
- ↑ Attacker Creates Final Smart Contract - BscScan (May 5, 2023)
- ↑ Binance Transaction Of Exploit - BscScan (May 3, 2023)
- ↑ Definalist - "Looks like @Level__Finance is currently under attack from hackers. Hacker created an unverified contract 7 days ago and are currently withdrawing LVL tokens in increments of 15,000 using the delegate function. The hacker's source of funds came from Tornado Cash." - Twitter (May 5, 2023)
- ↑ Attacker Transferring His Funds From The Attack Wallet - BscScan (May 5, 2023)
- ↑ 21.0 21.1 Level__Finance - "An exploit targeted our Referral Controller Contract. 214k LVL tokens drained to exploiters address." - Twitter (May 3, 2023)
- ↑ Level__Finance - "Remediation for Referral reward exploit DAO proposal." - Twitter (May 3, 2023)
- ↑ Remediation for Referral reward exploit - Level DAO - May 2nd, 2023 (May 3, 2023)
- ↑ RektHQ - "@Level__Finance got levelled. $1.1M in referral rewards were robbed from the BSC-based perps platform yesterday." - Twitter (May 3, 2023)