Skip to content
Access control Audit finding Intermediate

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.

cmichel Follow

Originally disclosed on Code4rena

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 _beforeTokenTransfer is 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 from will be the account the tokens are being moved from

Given the context and info I have this is a way to sidestep the guestList, hence a medium severity attack

The original report as published on Code4rena, by cmichel. Images and videos are our own copies; raw HTML is shown as text. View it on Code4rena.

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.

More by cmichel

View all

196 more disclosed reports, best first.

More from Union Finance contest

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Broken access control

The lesson behind this report.

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.