Critical Lottery Bug Found in PancakeSwap, PantherSwap, ApeSwap, and Knights BSC

Pancakeswap has named and congratulated the whitehat who found the coding error and helped multiple projects. The savior was awarded a large sum of money for their efforts.

By
John Tunney
on
July 7, 2021
Category:
BSC News

A Bug in the Lottery 

A whitehat by the name of Juno successfully alerted PancakeSwap of a serious error in their lottery coding. A whitehat in the crypto world typically refers to a virtuous and ethical hacker who finds exploits in projects and then alerts the projects of the exploitation. News broke of the successful exploit patch up on July 3rd via a Tweet from Immunefi, a crypto platform that offers bounty rewards for finding and alerting projects of errors in their coding. 

Depending on how serious an error they find, the project usually will pay large sums of money. In this case, Juno was paid a well-deserved $70,000 from PancakeSwap for alerting them of the error shown above. If a malicious hacker had found the bug, they could have easily exploited $700,000 from PancakeSwap’s lottery feature. 

The Error Itself

The bug uncovered was reported to PancakeSwap on April 27th. According to Immunefi’s post-mortem Medium post, it had to do with a logic error in the protocol’s lottery. The post states that a hacker could have claimed a winning ticket up to 255 times, thus multiplying the earnings of a regular lottery winning ticket by 255. 

The issue resulted from a lack of validation for ensuring the user claimed a single ticket, which meant, in theory, a malefactor could claim the same ticket infinitely. The only limitation was PancakeSwap’s block size, which would have limited a hacker to claim the same ticket 255 times. 

Shown below is the coding from PancakeSwap’s old bugged lottery contract: 

Source

PancakeSwap shut down their lottery feature prior to the bug being reported. However, they left $700,000 of outstanding winning lottery tickets to be claimed. Once Juno reported the bug, PancakeSwap withdrew all the funds preventing a malicious hacker from exploiting the logic.


E Pluribus Unum

Yet that’s not all. PantherSwap, ApeSwap, and Knights BSC had all forked their lottery feature from PancakeSwap, which meant all their protocols were also at risk. Once the bug was fixed, ApeSwap, PantherSwap, and Knights BSC all sent the whitehat money and tokens for alerting them of the error.

Since the error in coding was made known, all projects named above have fixed the exploitation. Immunefi thanked all parties involved for their quick response. All other curious whitehats are encouraged to bring their findings forward and receive awards. The world of Decentralized Finance will only get better as more groups and individuals work together toward a common goal. 


What is PancakeSwap

PancakeSwap is the leading decentralized exchange on Binance Smart Chain, with the highest trading volumes in the market. PancakeSwap runs on Binance Smart Chain, a blockchain with much lower transaction costs than Ethereum or Bitcoin. As a result, trading fees are lower than other top decentralized exchanges, and the protocol offers a secure place to farm yields thanks to their Syrup pools.

Where to find PancakeSwap: Website | Twitter | Medium | GitHub

Tags:
John Tunney

John Tunney is an accomplished analyst and crypto enthusiast. The UCLA alum has been actively reporting and blogging for 3 years, and has a passion for all things finance.

Text Link

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Suspendisse varius enim in eros elementum tristique. Duis cursus, mi quis viverra ornare, eros dolor interdum nulla, ut commodo diam libero vitae erat. Aenean faucibus nibh et justo cursus id rutrum lorem imperdiet. Nunc ut sem vitae risus tristique posuere.