Decoding Team Finance Contract Vulnerability

3 min read
Team Finance Contract Vulnerability

Team Finance, a security toolkit was exploited for approximately $14.5 million worth of tokens.

TL;DR#

On October 27, 2022, Team Finance was exploited for approximately $14.5 million worth of tokens.

Introduction to Team Finance#

Team Finance is a security toolkit for founders who want to create a token and raise funds from a community of investors.

Vulnerability Assessment#

The root cause of this vulnerability is a lack of proper validation in the contract's function, which resulted in the addition of a fake token to the contract, which was then used as a parameter to migrate the tokens from the pool.

Steps#

Step 1:

Here’s the reference to the attack contract, and one of the exploiter’s addresses hosting the stolen funds.

Step 2:

It is reported that the exploit was caused by the audited v2 to v3 migration function.

Step 3:

The migrate function of the LockToken contract doesn’t properly validate the _id and other parameters of the said function.



Step 4:

The contract only verified that the contract's caller has a valid deposit address, meaning that any amount of tokens can be locked by a potential hacker.

Step 5:

A fake token is locked in this attack transaction.



Step 6:

The attacker can arbitrarily specify the token pair to migrate the liquidity amount of the locked fake token.

Step 7:

The actual number of tokens to migrate is determined by the user-controlled parameter in params, and the migrated LP is returned to the caller in its entirety.

Step 8:

The initialize price of V3 liquidity pool is also disrupted by sqrtPriceX96. By doing so, the attacker is able to obtain a large amount of refund during the migration process.

Step 9:

The perpetrator took this opportunity to illegally migrate $WTH, $CAW, $USDC, $TSUKA tokens from V2 to V3 liquidity pool.

Aftermath#

The team announced via Twitter that they have temporarily paused all activity on their platform until they are certain that the exploit has been remedied. They have also urged the exploiter to contact them in order to receive a bounty payment.

The exploiter started communicating with the team through a series of decoded messages as seen in this transaction. According to reports, the exploited funds have begun flowing back to the project, with the hacker keeping a portion of the proceeds as a bug bounty reward.

How to Prevent Such an Attack Vector#

The failure to validate parameters or instructions can have disastrous consequences for a project team. It is recommended that strict test cases be used to validate the overall workflow of the smart contract functionalities.

Protocol, and Platform Security#

Our security team at Neptune Mutual can validate your platform for DNS and web-based security, smart contract reviews, as well as frontend and backend security. We can offer you a solution to scan your platform and safeguard your protocol for known and unknown vulnerabilities that have the potential to have catastrophic long-term effects. Contact us on social media if you are serious about security and have the budget, desire, and feeling of responsibility to do so.

By

Tags