-
Notifications
You must be signed in to change notification settings - Fork 0
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
Did Not Approve To Zero First Causing Certain Token Transfer To Fail #154
Comments
I gave this one a ❤️ for noting the special case of USDT. Since USDT's |
This should be higher severity as the funds could get stuck. |
Fixed by connext/monorepo@f981975 |
I'm actually going to disagree with the request to raise the severity of this issue because of a few main reasons:
I think based on this, it is safe to say that certain assumptions about the behaviour of these contracts must be broken in order for funds to be at risk. Due to this, I think |
Lines of code
https://github.com/code-423n4/2022-06-connext/blob/4dd6149748b635f95460d4c3924c7e3fb6716967/contracts/contracts/core/connext/facets/BridgeFacet.sol#L984
https://github.com/code-423n4/2022-06-connext/blob/4dd6149748b635f95460d4c3924c7e3fb6716967/contracts/contracts/core/connext/libraries/AssetLogic.sol#L347
Vulnerability details
Proof-of-Concept
Some tokens (like USDT) do not work when changing the allowance from an existing non-zero allowance value. For example Tether (USDT)'s
approve()
function will revert if the current approval is not zero, to protect against front-running changes of approvals.Instance 1 -
BridgeFacet._reconcileProcessPortal
The following function must be approved by zero first, and then the
SafeERC20.safeIncreaseAllowance
function can be called. Otherwise, the_reconcileProcessPortal
function will revert everytime it handles such kind of tokens. Understood from the comment that after the backUnbacked call there could be a remaining allowance.https://github.com/code-423n4/2022-06-connext/blob/4dd6149748b635f95460d4c3924c7e3fb6716967/contracts/contracts/core/connext/facets/BridgeFacet.sol#L984
Instance 2 -
BridgeFacet_swapAssetOut
The following fucntion must first be approved by zero, follow by the actual allowance to be approved. Otherwise, the
_swapAssetOut
function will revert everytime it handles such kind of tokens.https://github.com/code-423n4/2022-06-connext/blob/4dd6149748b635f95460d4c3924c7e3fb6716967/contracts/contracts/core/connext/libraries/AssetLogic.sol#L347
Impact
Both the
_reconcileProcessPortal
and_swapAssetOut
functions are called during repayment to Aave Portal if the fast-transfer was executed using portal liquidity. Thus, it is core part of the token transfer process within Connext, and failure of any of these functions would disrupt the AAVE repayment process.Since both functions affect the AAVE repayment process, I'm grouping them as one issue.
Recommended Mitigation Steps
As Connext bridges/routers deal with all sort of tokens existed in various domains/chains, the protocol should try to implement measure to ensure that it is compatible with as much tokens as possible for future growth and availability of the protocol.
Instance 1 -
BridgeFacet._reconcileProcessPortal
It is recommended to set the allowance to zero before increasing the allowance
Instance 2 -
BridgeFacet_swapAssetOut
It is recommended to set the allowance to zero before each approve call.
The text was updated successfully, but these errors were encountered: