Both totalSupply_ and _balanceOf use assembly { return(...) } to return values.
In the EVM, a raw return opcode exits the entire current call frame, not just the internal helper. When these helpers are used inside another function within the same contract, execution jumps straight out of the calling function and returns to the external caller. Any Solidity statements after the helper call are skipped entirely.
This becomes a problem only inside the ERC20 contract or in contracts that inherit from it. External callers will see the expected return value, because the early return ends only the token’s call frame, not theirs. However, if an inheriting contract expects to perform additional computation after calling _balanceOf or totalSupply_, that logic will never run.
Likelihood:
This issue occurs when inheriting contracts call _balanceOf or totalSupply_ inside a function that performs additional logic afterward. In such cases, the early assembly return causes the caller function to exit prematurely. This is a realistic scenario in extended ERC20 implementations, though inheriting contracts can technically access the storage variables directly instead of using these helpers.
Impact:
The calling function inside the ERC20 or its child contract will silently skip all logic after _balanceOf or totalSupply_.
Therefore, any inheriting contracts that have functions that use _balanceOf or totalSupply_ could have broken calculations, incorrect return values, and skip state updates.
While external integrations such as DeFi protocols calling balanceOf() or totalSupply() are unaffected, any extended logic inside the ERC20 contract itself becomes unsafe.
ExtendedToken inherits from the ERC20 contract and uses totalSupply_ and _balanceOf inside functions that perform additional logic.
Because these internal helpers perform a raw assembly return, the parent functions exit early and return only the helper value, not the computed result.
This change eliminates the early-exit behavior by removing the assembly return opcode and allowing Solidity to perform the function return normally.
The contest is live. Earn rewards by submitting a finding.
This is your time to appeal against judgements on your submissions.
Appeals are being carefully reviewed by our judges.
The contest is complete and the rewards are being distributed.