Grim Finance Reentrancy Attack

From Quadriga Initiative Cryptocurrency Hacks, Scams, and Frauds Repository
Revision as of 15:36, 7 May 2023 by Azoundria (talk | contribs)
Jump to navigation Jump to search

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.

Notice: This page contains sources which are not attributed to any text. The unattributed sources follow the initial description. Please assist by visiting each source, reviewing the content, and placing that reference next to any text it can be used to support. Feel free to add any information that you come across which isn't present already. Sources which don't contain any relevant information can be removed. Broken links can be replaced with versions from the Internet Archive. See General Tutorial on Wikis, Anatomy of a Case Study, and/or Citing Your Sources Guide for additional information. Thanks for your help!

Grim Finance

Despite an audit, Grim Finance's smart contract hot wallets suffered an exploit where they allowed an attacker to add a malicious smart contract, gaining extra shares. The attacker appears to have gotten away with roughly $30m in Fantom. Grim Finance is working on a compensation plan for affected users. Solidity Finance, who provided the audit, deflected blame to a junior developer who they hired to perform that particular audit.

This is a global/international case not involving a specific country.[1][2][3][4][5][6][7][8][9][10][11][12][13][14][15][16][17][18][19][20][21][22][23][24][25][26][27]

About Grim Finance

"Compounding Yield Optimizer Built on Fantom Opera. Allowing users to reap more crypto with crypto."

"Grim Finance is a Smart Yield Optimizer Platform that allows users to stake LP-Tokens issued from AMMs (Automated Market Makers) in Grim Vaults, which automatically harvest and re-stake their rewards as LP-Tokens for a compounding effect. Helping users reap more rewards, hassle-free."

"Grim Finance is a fork from Beefy Finance, Convex Finance, hybrid of different complex strategies and with an enhanced user experience and expansive selection of Fantom pools spanning the entire ecosystem. Grim users have access to Liquid Boost Vaults, which were designed to boost liquidity to a designated pool in the AMM’s."

"When [Solidity Finance was] conducting the Grim Finance audit ~4 months ago, [their] firm was experiencing rapid growth and hiring. This audit was performed by an analyst who was new to the team & while [their] CTO was on vacation; and unfortunately this issue was not caught in [their] peer review process."

"Grim Finance vaults were exploited today by unknown 3rd party." "It is with heavy hearts that we inform you that our platform was exploited today by an external attacker roughly 6 hours ago. The attackers address has been identified with over 30 million dollars worth of theft."

"The root cause of the issue was the ability of users to input arbitrary addresses and have them called within the depositFor function. Via reentrancy, the issue allowed users to falsely increase their shares in Grim's vaults and subsequently withdraw more than they had deposited."

"This was an advanced attack. The attacker attacked using the function titled beforeDeposit() from our vault strategy entering a malicious token contract." "The malicious contract was used as the token input parameter to the depositFor() function in the Vault."

"The malicious token contract can start 5 reentrancy loops from safeTransferFrom(), where in all 5 rentrancies, the _pool value is set to the current balance(). On the last safeTransferFrom(), the rentrancy loop is broken, and some want can be transferred to the strategy, which will increase the _amount to put the vault in a state to mint shares."

"On the unwinding of the 5 rentrancies, each loop will see that the _amount is not 0, and mint the corresponding shares, mint the same share count 5x (the number of rentrancy loops)." "The code which was exploited was present in multiple vaults, resulting in a loss of funds across the platform's vaults."

"Both the Grim Team and our external auditing firm Solidity Finance failed to detect an external threat in our code in the Grim Vault contract. The attacker used a malicious token contract to mint shares of the vaults and dilute the pools, allowing them to steal funds within the vaults."

"We have paused all of the vaults to prevent any future funds from being placed at risk, please withdraw all of your funds IMMEDIATLY as Nikar0 mentioned in the previous post." "They will need to be unpaused for users to remove their funds. More info on that asap. Do try to keep withdrawing, as the vaults will have to be unpaused 1 by 1 for funds to be withdrawn."

"We have contacted and notified Circle (USDC), DAI, and AnySwap regarding the attacker address to potentially freeze any further fund transfers." "Reached out to CoinHomes, DAI, USDC anyswap etc to report the theft, main account has been flagged and we are tracking additional accounts via the form above."

"The depositFor exploited function has been removed from the vault contract. Sentinel contract (killswitch) created to remotely lock all vaults to help stop any future attack. TVL monitor for vaults routinely checking for abnormal TVL movements to notify team."

"Releasing new token which will be proportionally airdropped to all users impacted by the exploit based on the amount of funds lost. The token will receive 50% of all platform revenues indefinitely and the goal is to have the token appreciate to a level that will be sufficient compensation to the impacted users by creating wealth."

"With GRIM ATH $2 with 10M tokens (ATH market cap of 20 million) we believe that this has the potential to reimburse users significantly Existing GRIM tokens will be able to mint new tokens with existing Grim tokens at an (estimated) 10:1 ratio for the new token, resulting in a capped total supply under 2 million tokens."

"0.2% of all platform fees will be sent to an untouched insurance wallet that will be used to compensate users for the current loss and for any potential future exploits indefinitely." "We are continuing to reach out to project leads from other projects for further avenues to provide restitution to our users via partnerships and any additional means."

"We are working with auditing firms to have our contracts audited fully reviewed." "Solidity finance will be providing a free full review of all of our new contracts by a senior member of their staff AND will be paying for an additional audit from another firm (in contact with QuantStamp and Certik but open to suggestions and contact from other established and reputable agencies)." "@certik_io has officially on boarded @financegrim!"

Solidity Finance said "We have scanned all prior audits and can confirm the issue in Grim is not present in any other codebase we've reviewed. Our team has conducted 900+ audits and Grim is the 2nd exploit that has slipped past our process since the firm's founding in 2020 (an exploit rate of ~0.22%)."

"A google form will be released soon requesting detailed information about each user’s scenario to collect information from all impacted users on our platform. In conjunction with our automation, this information will help us in identifying which users were impacted and to what levels and will help us determine the share of the new tokens to be minted along with the total dollar value of compensation required to become whole again through all additional avenues as we continue to explore other means of compensation in depth." "The submission deadline for the form has been set to January 7th allowing just over 2 weeks to submit your claims at which time in coordination with our automation to identify impacted users and the allocation of tokens they will receive as compensation."

"The team has been hard at work at implementing our restitution plan. Our number one priority during this time has been removing the exploit, applying new upgrades and deploying new vaults (154 new vaults to be precise) in order to establish an income allocated to the impacted users of our platform. So far we have completed the implementation of the platforms listed below, and the subsequent list of vaults are awaiting implementation."

"The entire team sincerely apologizes to all of the victims for their loss during the exploit and we will continue to update you on the situation in the coming days."

This is a global/international case not involving a specific country.

The background of the exchange platform, service, or individuals involved, as it would have been seen or understood at the time of the events.

Include:

  • Known history of when and how the service was started.
  • What problems does the company or service claim to solve?
  • What marketing materials were used by the firm or business?
  • Audits performed, and excerpts that may have been included.
  • Business registration documents shown (fake or legitimate).
  • How were people recruited to participate?
  • Public warnings and announcements prior to the event.

Don't Include:

  • Any wording which directly states or implies that the business is/was illegitimate, or that a vulnerability existed.
  • Anything that wasn't reasonably knowable at the time of the event.

There could be more than one section here. If the same platform is involved with multiple incidents, then it can be linked to a main article page.

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.

Key Event Timeline - Grim Finance Reentrancy Attack
Date Event Description
December 20th, 2021 Main Event Expand this into a brief description of what happened and the impact. If multiple lines are necessary, add them here.

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?

Total Amount Lost

The total amount lost has been estimated at $30,000,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?

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

Our framework has two reviews prior to launch, which should come from independent experts. In the case of a smart contract, this would be different firms. However, it's important to understand that smart contract hot wallets can never be certain to be completely secure, and it's best to have most funds in cold storage protected by multi-signature authorization.

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