Skip to content
Business logic Audit finding Intermediate

Title: Inadequate Allowance Handling in convertAndForward Function of `OCT_DAO` & `OCT_YDL`

The convertAndForward functions in OCT_DAO and OCT_YDL set a token allowance for the 1inch router but do not reset it after the swap. If the router does not use the full allowance, the leftover allowance causes an assertion that the allowance is zero to fail, reverting the transaction.

0xBhumii Follow with recursiveEth

Originally disclosed on Sherlock

Source: https://github.com/sherlock-audit/2024-03-zivoe-judging/issues/609

Found by

0xBhumii, recursiveEth

Summary

The OCT_DAO:convertAndForward and OCT_YDL:convertAndForward function suffers from inadequate handling of token allowances for the 1inch router. Although allowances are set correctly before converting assets, they are not reset afterward. This can lead to failed transactions if the 1inch router does not utilize the entire allowance due to slippage or other factors.

Vulnerability Detail

the issue arises from the lack of allowance reset after interacting with the 1inch router. If the router does not utilize the entire allowance specified due to slippage or other reasons, the allowance will remain unchanged, potentially causing the assertion to fail and the transaction to revert.

Impact

The impact of this vulnerability is that transactions may fail due to incorrect allowance management. This could result in inefficiencies in liquidity provision, loss of gas fees because due to asset statement it consume all the gas and won't return anything and convertandTransfer will never be able to transfer asset to DAO.

Code Snippet

https://github.com/sherlock-audit/2024-03-zivoe/blob/main/zivoe-core-foundry/src/lockers/OCT/OCT_DAO.sol#L87 https://github.com/sherlock-audit/2024-03-zivoe/blob/main/zivoe-core-foundry/src/lockers/OCT/OCT_YDL.sol#L97

JavaScript
assert(IERC20(asset).allowance(address(this), router1INCH_V5) == 0);

Tool used

Manual Review

Recommendation

Reset Allowances After Use: After interacting with the Uniswap router and completing the liquidity provision, reset the allowances for the pair assets and ZVE tokens to zero to ensure they are not left with excessive allowances.

Discussion

pseudonaut

Valid

sherlock-admin3

1 comment(s) were left on this issue during the judging contest.

panprog commented:

borderline low/medium, the report has just generic suggestion without specific POC (exact scenario) when this can actually happen. Normally, when doing a swap, full allowance is used to do it. It appears that 1inch's fillOrderRFQ might not use full allowance if there is no matching order in the orderbook, but I'm not 100% sure. Watson should have provided the POC to prove his point.

BiasedMerc

This seems like it should be invalid, as mentioned by lead judge, there is no POC or explanation as to how any allowance can be left after interaction with the router, and all explanations and suggestions are generic.

I feel like for this type of issue some sort of written POC should be required to prove the issue, as currently there is no way to prove if this scenario can actually happen. And judge also is unsure if this is really a valid issue from the comment, so it seems the warden has not done an adequate job at proving the issue due to lack of POC.

E.g. #18 describes a similar issue for UniSwap and outlines the exact scenario of how leftover allowance can occur with code-snippets.

IronsideSec

In the vulnerability section, watson says If the router does not utilize the entire allowance specified due to slippage or other reasons submit a POC to prove that 1inch will operate in a way that allowance will be > 0 in any of the success swap paths, then issue might be valid.

swaps will revert if the slippage did not match. If swap fails, whole transaction will revert, hence chances for allownce to be > 0 after a successful swap is not possible

Afriaudit

As far as I understand here. There was a flaw in the protocol's implementation when engaging with a third party.(in this case uniswap, curve, sushi, 1inch) and the flaw is: -give allowance to the third party -Third party withdraws from the protocol -Protocol fails to reduce allowance left -Protocol proceeds to assert allowance = 0

This implementation will cause recurring reversion when interacting these third parties.

According to sherlock rules; ''In case the same vulnerability appears across multiple places in different contracts, they can be considered duplicates. The exception to this would be if underlying code implementations, impact, and the fixes are different, then they can be treated separately.'' As far as I know the impact and fixes are same making It a dup of #18. Though the implementation logic is same the exact code Is different, one being uniswap the other being one inch. It will be Interesting to see how this turns out as it will help understand the interpretation of the above sherlock rule.

sherlock-admin2

The protocol team fixed this issue in the following PRs/commits: https://github.com/Zivoe/zivoe-core-foundry/pull/262

armormadeofwoe

There are currently 2 separate issues regarding vulnerable assert statements in swaps: #18 with UniSwap and this one for 1inch. Since the root cause is the same (flawed dev design choice of using assert) why are they considered as separate bugs?

sherlock-admin2

The Lead Senior Watson signed off on the fix.

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

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 contract asserts that the router's allowance is zero after the swap without resetting any unused allowance, so any leftover allowance causes a revert.

Impact

Transactions may fail, wasting gas and preventing the conversion and transfer of assets to the DAO.

What the attacker needed

1inch router leaves leftover allowance

The fix

The issue was fixed by resetting the allowance to zero after interacting with the router.

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.

When a smart contract lets another contract (like a swap router) spend its tokens, it gives an 'allowance'. The code here checks that the allowance is zero after the swap, but it never resets it. If the router does not spend everything, the check fails and the transaction is cancelled.

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 from Zivoe

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.