Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

handleExecutedDecreaseInvestOrder may revert in some cases #471

Open
c4-submissions opened this issue Sep 14, 2023 · 5 comments
Open

handleExecutedDecreaseInvestOrder may revert in some cases #471

c4-submissions opened this issue Sep 14, 2023 · 5 comments
Labels
bug Something isn't working downgraded by judge Judge downgraded the risk level of this issue duplicate-32 grade-b Q-22 QA (Quality Assurance) Assets are not at risk. State handling, function incorrect as to spec, issues with clarity, syntax sufficient quality report This report is of sufficient quality

Comments

@c4-submissions
Copy link
Contributor

Lines of code

https://github.com/code-423n4/2023-09-centrifuge/blob/main/src/InvestmentManager.sol#L291

Vulnerability details

Impact

Users can request decreasing the outstanding deposit orders via decreaseDepositRequest which will send a cross-chain message to the Centrifuge chain. After the message is processed, Centrifuge's bot will decrease the outstanding deposit orders and send another cross-chain message back to the source chain to notify that the request has been processed. This will eventually call handleExecutedDecreaseInvestOrder, which internally transfers the asset from escrow to user via asset.transferFrom. Assets can be tokens with blacklist mechanisms such as USDC and USDT. If the user is blacklisted, it will cause USDC.transferFrom revert. Therefore, the message cannot be successfully processed, which means that the user cannot obtain the decreased asset, resulting in a loss of funds.

Proof of Concept

When a message of type Call.ExecutedDecreaseInvestOrder is executed by relayer, the whole flow is as follows:

Router.execute	//src\gateway\routers\axelar\Router.sol
  gateway.handle
    investmentManager.handleExecutedDecreaseInvestOrder
      ......some checks skipped
      SafeTransferLib.safeTransferFrom(_currency, address(escrow), user, currencyPayout)

Let's take a look at the code of handleExecutedDecreaseInvestOrder:

File: src\InvestmentManager.sol
277:     function handleExecutedDecreaseInvestOrder(
278:         uint64 poolId,
279:         bytes16 trancheId,
280:         address user,
281:         uint128 currency,
282:         uint128 currencyPayout
283:     ) public onlyGateway {
284:         require(currencyPayout != 0, "InvestmentManager/zero-payout");
285: 
286:         address _currency = poolManager.currencyIdToAddress(currency);
287:         address liquidityPool = poolManager.getLiquidityPool(poolId, trancheId, _currency);
288:         require(liquidityPool != address(0), "InvestmentManager/tranche-does-not-exist");
289:         require(_currency == LiquidityPoolLike(liquidityPool).asset(), "InvestmentManager/not-tranche-currency");
290: 
291:->       SafeTransferLib.safeTransferFrom(_currency, address(escrow), user, currencyPayout);
292:     }

L291, if _currency is USDC or USDT and user is blacklisted, tx will revert.

Tools Used

Manual Review

Recommended Mitigation Steps

It is recommended not to transfer the asset directly to the user, but to record the amount of the asset and provide the claim function to allow the user to specify the receiver.

Assessed type

DoS

@c4-submissions c4-submissions added 2 (Med Risk) Assets not at direct risk, but function/availability of the protocol could be impacted or leak value bug Something isn't working labels Sep 14, 2023
c4-submissions added a commit that referenced this issue Sep 14, 2023
@c4-pre-sort
Copy link

raymondfam marked the issue as sufficient quality report

@c4-pre-sort c4-pre-sort added the sufficient quality report This report is of sufficient quality label Sep 15, 2023
@c4-pre-sort
Copy link

raymondfam marked the issue as duplicate of #32

@c4-judge
Copy link

gzeon-c4 changed the severity to QA (Quality Assurance)

@c4-judge c4-judge added downgraded by judge Judge downgraded the risk level of this issue QA (Quality Assurance) Assets are not at risk. State handling, function incorrect as to spec, issues with clarity, syntax grade-c unsatisfactory does not satisfy C4 submission criteria; not eligible for awards and removed 2 (Med Risk) Assets not at direct risk, but function/availability of the protocol could be impacted or leak value labels Sep 25, 2023
@c4-judge
Copy link

gzeon-c4 marked the issue as grade-c

@c4-judge
Copy link

gzeon-c4 marked the issue as grade-b

@c4-judge c4-judge added grade-b and removed grade-c unsatisfactory does not satisfy C4 submission criteria; not eligible for awards labels Sep 29, 2023
@C4-Staff C4-Staff reopened this Oct 2, 2023
@C4-Staff C4-Staff added the Q-22 label Oct 2, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working downgraded by judge Judge downgraded the risk level of this issue duplicate-32 grade-b Q-22 QA (Quality Assurance) Assets are not at risk. State handling, function incorrect as to spec, issues with clarity, syntax sufficient quality report This report is of sufficient quality
Projects
None yet
Development

No branches or pull requests

4 participants