Skip to content
Business logic Audit finding Intermediate

TransmuterBuffer’s setAlchemist will freeze deposited funds

The setAlchemist function does not check for open positions with the old Alchemist before switching to a new one. If an admin changes the Alchemist while funds remain deposited, those funds become frozen and require manual recovery.

hyh Follow

Originally disclosed on Code4rena

Submitted by hyh

Currently setAlchemist doesn’t check whether there are any open positions left with the old Alchemist before switching to the new one.

As this require a number of checks the probability of operational mistake isn’t low and it’s prudent to introduce the main controls directly to the code to minimize it. In the case if the system go on with new Alchemist before realizing that there are some funds left in the old one, tedious and error prone manual recovery will be needed. There is also going to be a corresponding reputational damage.

Setting the severity to medium as while the function is admin only, the impact is up to massive user fund freeze, i.e. this is system breaking with external assumptions.

Proof of Concept

Alchemist implementation change can happen while there are open deposits remaining with the current contract. As there looks to be no process to transfer them in the code, such TransmuterBuffer’s funds will be frozen with old alchemist:

TransmuterBuffer.sol#L230-L232

    function setAlchemist(address _alchemist) external override onlyAdmin {
        sources[alchemist] = false;
        sources[_alchemist] = true;

Recommended Mitigation Steps

Consider requiring that all exposure to the old Alchemist is closed, for example both getAvailableFlow and getTotalCredit is zero.

TransmuterBuffer.sol#L230-L231

    function setAlchemist(address _alchemist) external override onlyAdmin {
+		  require(getTotalCredit() == 0, "Credit exists with old Alchemist");
+       for (uint256 j = 0; j < registeredUnderlyings.length; j++) {
+           require(getTotalUnderlyingBuffered[registeredUnderlyings[j]] == 0, "Buffer exists with old Alchemist");
+       }
        sources[alchemist] = false;

0xfoobar (Alchemix) confirmed

0xleastwood (judge) commented:

This is useful in preventing loss of funds when changing the protocol’s alchemist contract.


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

Impact

If the admin switches to a new Alchemist while deposits remain, user funds could be frozen and require manual recovery, though the function is admin-only.

What the attacker needed

Admin privileges; open deposits with old Alchemist

The fix

The function should require that all exposure to the old Alchemist is closed, for example by checking that getAvailableFlow and getTotalCredit are zero.

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 smart contract has an admin function to point to a new version of another contract. If the old version still holds user money, switching without checking leaves that money stuck because the new version does not know about it. The fix is to require that all balances with the old contract are zero before allowing the switch.

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 hyh

View all

137 more disclosed reports, best first.

More from Alchemix 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.