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

QA Report #277

Open
code423n4 opened this issue Jun 19, 2022 · 1 comment
Open

QA Report #277

code423n4 opened this issue Jun 19, 2022 · 1 comment
Labels
bug Something isn't working QA (Quality Assurance) Assets are not at risk. State handling, function incorrect as to spec, issues with clarity, syntax

Comments

@code423n4
Copy link
Contributor

[QA-1] _router is not used in repayAavePortalFor function

repayAavePortalFor function says This allows anyone to repay the portal in the adopted asset for a given router and transfer but the argument _router is not used at all.

https://github.com/code-423n4/2022-06-connext/blob/main/contracts/contracts/core/connext/facets/PortalFacet.sol#L115-L126


[QA-2] repayAavePortal function can set underflown value at s.routerBalances[msg.sender][_local]

Random people can call repayAavePortal function and set underflown value at s.routerBalances[msg.sender][_local].

This part decrements balance in the unchecked statement.

https://github.com/code-423n4/2022-06-connext/blob/main/contracts/contracts/core/connext/facets/PortalFacet.sol#L107-L109

    unchecked {
      s.routerBalances[msg.sender][_local] -= amountIn;
    }

When adopted is local asset and AssetLogic.swapFromLocalAssetIfNeededForExactOut returns (true, _amount, _asset), it may reach to s.routerBalances[msg.sender][_local] -= amountIn.

https://github.com/code-423n4/2022-06-connext/blob/4dd6149748b635f95460d4c3924c7e3fb6716967/contracts/contracts/core/connext/libraries/AssetLogic.sol#L244-L247

As a result, when s.routerBalances[msg.sender][_local] is 0 or small value, it is possible that the underflow happens at s.routerBalances[msg.sender][_local] -= amountIn which results in having giant value at s.routerBalances[msg.sender][_local] which seems not ideal. Removing unchecked from this part can prevent such situations.

@code423n4 code423n4 added bug Something isn't working QA (Quality Assurance) Assets are not at risk. State handling, function incorrect as to spec, issues with clarity, syntax labels Jun 19, 2022
code423n4 added a commit that referenced this issue Jun 19, 2022
@LayneHaber
Copy link
Collaborator

LayneHaber commented Jun 21, 2022

QA-1 -- valid.

QA-2 -- invalid -- there are other high severity issues that reference this (and this is a bit more than a QA issue since routers can then withdraw and effectively steal from the contract). See #68 #211

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working QA (Quality Assurance) Assets are not at risk. State handling, function incorrect as to spec, issues with clarity, syntax
Projects
None yet
Development

No branches or pull requests

2 participants