Skip to content
Business logic Audit finding Intermediate

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.

Anurag Jain Follow

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

  1. Navigate to https://github.com/code-423n4/2021-10-union/blob/main/contracts/market/MarketRegistry.sol
  2. Check the addUToken function
function addUToken(address token, address uToken) public newToken(token) onlyAdmin {
    uTokenList.push(uToken);
    tokens[token].uToken = uToken;
    emit LogAddUToken(token, uToken);
}
  1. 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
  2. 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

The original report as published on Code4rena, by csanuragjain. 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 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

  1. Navigate to the MarketRegistry.sol contract on GitHub.
  2. Check the addUToken function.
  3. Observe that there is no check for duplicate utoken entries.
  4. 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.

More by Anurag Jain

View all

63 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.

Business logic flaws

The lesson behind this report.

The application works as coded but not as intended: a negative price, a skipped payment step, a limit that can be crossed.