UnionToken should check whitelist on from ?
The UnionToken whitelist check in the transfer hook tested the caller rather than the account the tokens were moved from. A single whitelisted account acting as an operator could therefore move tokens for non-whitelisted holders, sidestepping the whitelist.
Submitted by cmichel
The UnionToken can check for a whitelist on each transfer in _beforeTokenTransfer:
if (whitelistEnabled) {
require(isWhitelisted(msg.sender) || to == address(0), "Whitelistable: address not whitelisted");
}
This whitelist is checked on msg.sender not on from, the token owner.
Impact
A single whitelisted account can act as an operator (everyone calls unionToken.allow(operator, max) where the operator is a whitelisted trusted smart contract) for all other accounts. This essentially bypasses the whitelist.
Recommended Mitigation Steps
Think about if the whitelist on msg.sender is correct or if it should be on from.
GeraldHost (Union Finance) confirmed
GalloDaSballo (judge) commented:
Agree with the warden findings, since
_beforeTokenTransferis called on all transfers (transfer and transferFrom)[https://github.com/OpenZeppelin/openzeppelin-contracts/blob/e63b09c9ad3a45484b6dc304e0e99640a9dc3036/contracts/token/ERC20/ERC20.sol#L229]In order to enforce the whitelist you need to check against from and not msg.sender
msg.sender could be a relayer or another contract, while
fromwill be the account the tokens are being moved fromGiven the context and info I have this is a way to sidestep the guestList, hence a medium severity attack
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
How it worked
Root cause
Likely the transfer hook validated the wrong address, checking the caller instead of the token owner being debited.
Impact
A single whitelisted account could act as an operator for all other accounts and effectively bypass the whitelist; the judge rated this a medium severity attack.
What the attacker needed
One whitelisted account; other holders grant it allowance
The fix
The whitelist check should be applied to the account the tokens are moved from rather than the caller.
Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
A whitelist is a list of addresses allowed to do something. This token checked whether the person starting the transfer was on the list, instead of checking whose tokens were being moved. So one approved account could move other people's tokens even though those people were never approved.
What is Access control?
A user can do something their role should not allow: reach an admin function, act on a feature they have not paid for, or skip a permission check. IDOR is the special case where the object belongs to someone else.