SafeMoon — Is it safe though? A detailed explanation of frictionless yield bug

Demonstration of the bug in the SafeMoon smart contract on BSC mainnet
Figure-1: Logic map of the gasless holder yield feature. The smart contract provides the distribution of holder rewards by following these steps after each on-chain transaction.
Figure-2: Functions used to exclude accounts from receiving SafeMoon gasless holder yields. _tOwned represents the balance of excluded accounts where _rOwned is the balance of accounts that are not excluded. currentRate is the weighting coefficient, k as we mentioned earlier.
Figure-3: During the inclusion of accounts, the rate of “currentRate = _rOwned / _tOwned” is lost due to the missing of 2 lines of code that should update the value of _rOwned.
Some of the projects involving the same bug in their smart contracts. The projects we have included in the list here are those with the highest daily volume and number of holders amongst the other projects that integrated the same RFI structure into their smart contracts. Since the exploitation of this bug causes holders to lose their funds, more users will be affected by this bug for projects with a higher number of holders.
Implementation of exclude and include functions in the PERA smart contract.

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store