Decoding SkywardFinance $3 Million Exploit | QuillAudits
On the 2nd of November, 2022, Skyward Finance ( token issuance platform on NEAR blockchain that helped users with initial token distribution) was attacked. The cause of the attack was incorrect input checks in skyward.near contract that resulted in the draining of around 1.1 Million $NEAR tokens i.e. around $3.2 Million by the hackers.
Introduction to Skyward Finance:
Skyward Finance is a project based on NEAR Blockchain which is a fully permission-less open-sourced launchpad that allows Projects to launch their tokens without any liquidity with the best price discovery mechanism that’s resistant to bots and Sybil attacks.
Read more about the protocol here.
The Cause of the Attack:
The root cause of the attack was due to insufficient checks in the redeem_skyward function of skyward.near contract. This function was used to redeem the reward from the treasury.
If we look at the function redeem_skyward, it takes 2 input parameters i.e. skyward_amount and token_account_ids. In skyward_amount we input the amount we want to claim for reward and in token_account_ids we input ValidAccountIds.
In lines 169–170, the reward amount is calculated and skyward_burned_amount is updated.
If we look at the code above, there isn’t any check for duplicate token_account_ids. It can allow an attacker to pass the same ids again and again while calling the function and allow attackers to claim rewards multiple times.
- The exploiter effectively withdraws the wrap.near multiple times within one transaction. He called the redeem_skyward function passing the value in skyward_amount and token_account_ids parameters.
- The attacker inserted the wrap.near address multiple times in the token_account_ids parameter. See below:
3. Here, As there was no check for duplicated token_account_ids, the attacker easily claimed reward multiple times and stole around $1.1 Million NEAR Token i.e. around $3.2 Million from this attack.
How this attack could have been prevented?
The attack could have been prevented by adding checks for duplicated token_account_ids in the redeem_skyward function at wrap.near contract. This would prevent attackers from claiming rewards multiple times.
After the Exploit :
On 3rd November, Skyward Finance announced the exploit and further communicated that their native token $SKYWARD became worthless
They recommended users withdraw their funds safely where they can. Also, they asked the community to no longer interact with Skyward.
The price of the $skyward token fell from $14 to $0.8 after the attack.
Web3 security- Need of the hour
Why QuillAudits for Web3 Security?
QuillAudits is well-equipped with tools and expertise to provide cybersecurity solutions saving the loss of millions in funds.
Want more Such Security Blogs & Reports?
Partner with QuillAudits :
- QuillAudits Partnership Programme ( Venture funds, launchpads, development companies, marketing firms, web2 cybersecurity firms, web3 products )