UNKNOWN

APRIL 2021

GLOBAL

PANTHERSWAP

DESCRIPTION OF EVENTS

"The First Automatic Liquidity Acquisition Yield Farm & AMM on Binance Smart Chain." "PantherSwap is the first automatic liquidity acquisition yield farm and AMM decentralized exchange running on Binance Smart Chain with lots of unique and creative features that let you earn and win."

 

"Each transfer of PANTHER must pay a 2% transfer tax." "The 1% transfer tax will be allocated to automatic liquidity acquisition. And the rest 1% transfer tax will be burned immediately. The whole process is automatic."

 

PantherSwap depended on the same lottery contract code as PancakeSwap. "Whitehat Juno submitted a critical vulnerability in PancakeSwap’s lottery contract on April 27." (Status of contract in Knights Defi.)

 

"Due to insufficient validation, a malicious user could have claimed the same winning ticket at least 255 times in a single transaction, meaning the reward size was 255 times too great. A total of $700,000 in funds could have been lost, had the vulnerability been exploited."

 

"An analysis of this code block reveals that if a ticket is submitted to multiClaim multiple times (that is, the _tickets[] aren’t all unique), the duplicate ticket will be able to be redeemed multiple times. This happens because Lottery.sol checks that the ticket hasn’t been claimed, and it checks all the tickets before marking any of them as claimed. Additionally, LotteryNFT.sol multiClaimReward doesn’t require that the ticket being claimed hasn’t already been marked as claimed."

 

"None of the checks account for the possibility that a malicious user would pass the same ticket multiple times. The result is that the total reward is a function of the reward itself multiplied by the number of times the ticket is claimed."

 

"Step 1: Buy a lottery ticket. Step 2: Win the lottery. The lottery works by allowing you to pick a number between 1 and 14, and you pick four numbers. There are prizes available for matching at least two of the numbers together. If you match four numbers together, you win the grand prize. However, the exploit does not depend on winning the grand prize. The exploit depends on winning at least some amount of money, which is not difficult. Step 3: Submit the malicious transaction, which calls multiClaim(), and pass the winning ticket 255 times, where each ticket is the ID of the NFT lottery ticket. There’s no validation that a user is claiming the same ticket, so that user can effectively claim the same ticket an unlimited number of tickets — with the only limit being the blocksize of the transaction."

 

"PancakeSwap fixed [the] logic bug after it was responsibly disclosed by Juno." "Immunefi began the process of disclosure assistance, contacting every project on Binance Smart Chain that had forked PancakeSwap’s lottery contract to inform them of the vulnerability as well. ApeSwap, PantherSwap, and Knights DeFi were vulnerable. All three decided to pay a bounty to the whitehat as well."

 

"PancakeSwap paid $70,000 in CAKE tokens. ApeSwap paid $2,700. PantherSwap paid 10,290 PANTHER tokens. Knights DeFi paid 7,000 KNIGHT tokens. All affected projects have fixed the vulnerability."

 

"After Juno reported the vulnerability through Immunefi, PancakeSwap withdrew all funds out of the contract." "PantherSwap, however, kept the lottery contract active and applied a fix as suggested by Immunefi’s CTO Duncan Townsend. The fix was to rewrite the multiClaim() function." "ApeSwap shut down its lottery contract. Knights DeFi took down the contract and migrated to a new one."

The PancakeSwap smart contract included a lottery. While the lottery was not actively running, the smart contract was still live and there may have been funds in the smart contract hot wallet.

 

Due to having a bug bounty program, a white hat hacker uncovered the issue and claimed the reward. The PantherSwap smart contract was upgraded before an exploit could occur.

HOW COULD THIS HAVE BEEN PREVENTED?

There were no losses in this case, due to the bug bounty program.

 

The lottery would have been more secure if the funds were in an offline multi-signature wallet. The drawing could still be run through the blockchain for process transparency.

 

Lotteries may also be possible with smart contract insurance.

 

Check Our Framework For Safe Secure Exchange Platforms

Sources And Further Reading

 For questions or enquiries, email info@quadrigainitiative.com.

Get Social

  • email
  • reddit
  • telegram
  • Twitter

© 2021 Quadriga Initiative. Your use of this site/service accepts the Terms of Use and Privacy Policy. This site is not associated with Ernst & Young, Miller Thompson, or the Official Committee of Affected Users. Hosted in Canada by HosterBox.