Duplicate utoken and usermanager can be added which cannot be deleted
The smart contract's addUToken and addUserManager functions allow duplicate entries to be added to their respective lists. If an admin later tries to delete a market, only the first instance is removed, leaving duplicates and meaning the market is not fully deleted.
Originally disclosed on Code4rena
Submitted by csanuragjain
If Admin decides to delete the market, only the first instance of utoken and usermanager gets deleted. This means duplicate instance remains and Admin has actually not deleted the market
Proof of Concept
- Navigate to https://github.com/code-423n4/2021-10-union/blob/main/contracts/market/MarketRegistry.sol
- Check the
addUTokenfunction
function addUToken(address token, address uToken) public newToken(token) onlyAdmin {
uTokenList.push(uToken);
tokens[token].uToken = uToken;
emit LogAddUToken(token, uToken);
}
- As we can see there is no check to see if the utoken already existed in uTokenList which means now uTokenList can have now duplicate entries
- Same case goes for userManagerList
Recommended Mitigation Steps
Modify addUToken and addUserManager function to check if the usermanager/utoken already existed
GalloDaSballo (judge) commented:
Agree with the finding, since the warden showed a specific attack with stated conditions, this a medium severity finding
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 addUToken and addUserManager functions lack a check to prevent duplicate entries in their respective lists.
Impact
An admin could fail to fully delete a market because duplicate entries remain, potentially leaving the market partially active or causing inconsistencies.
What the attacker needed
Admin privileges
The fix
The addUToken and addUserManager functions should be modified to check if the utoken or usermanager already exists before adding.
How it was found
- Navigate to the MarketRegistry.sol contract on GitHub.
- Check the addUToken function.
- Observe that there is no check for duplicate utoken entries.
- Note that the same issue applies to userManagerList.
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.
This is a smart contract bug where the same item can be added to a list more than once. When someone tries to remove it, only one copy is removed, so the item still exists. This could cause confusion or unexpected behaviour in the system.
What is Business logic?
The application works as coded but not as intended: a negative price, a skipped payment step, a limit that can be crossed.