SuperTokens are vulnerable to attacker frontrunning and minting free tokens
Description:
SpiritToken::initialize() is vulnerable to an attacker frontrunning the initialization with a malicious implementation, minting tokens for themselves, and then setting the implementation to address(0) again.
The inherited UUPSProxy allows this because it has no access control, and although it checks for initialAddress != address(0), this check won't exist on the new attacker implementation, so they can just reset it to 0 after minting free tokens.
function initializeProxy(address initialAddress) external {
require(initialAddress != address(0), "UUPSProxy: zero address");
require(UUPSUtils.implementation() == address(0), "UUPSProxy: already initialized");
UUPSUtils.setImplementation(initialAddress);
}Impact:
Spirit and Child tokens can be stolen.
Recommended Mitigation:
Add a deployer contract or make it access controlled by a trusted address in the constructor.
0xSimao:
Fixed in PR #6.