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

Approve not compatible with Tether (USDT) implementation #65

Closed
code423n4 opened this issue Jun 14, 2022 · 3 comments
Closed

Approve not compatible with Tether (USDT) implementation #65

code423n4 opened this issue Jun 14, 2022 · 3 comments
Labels
bug Something isn't working duplicate This issue or pull request already exists QA (Quality Assurance) Assets are not at risk. State handling, function incorrect as to spec, issues with clarity, syntax

Comments

@code423n4
Copy link
Contributor

Lines of code

https://github.com/code-423n4/2022-06-connext/blob/20f86d58444d7c8178735ada7e456a3112116e54/contracts/contracts/core/connext/libraries/AssetLogic.sol#L347

Vulnerability details

Impact

Approve not compatible with Tether (USDT) implementation.

Proof of Concept

Some tokens do not implement the ERC20 standard properly but are still accepted by most code that accepts ERC20 tokens. For example Tether (USDT or CVX)'s approve() function will revert if the current approval is not zero, to protect against front-running changes of approvals.

function approve(address _spender, uint _value) public onlyPayloadSize(2 * 32) {

    // To change the approve amount you first have to reduce the addresses`
    //  allowance to zero by calling `approve(_spender, 0)` if it is not
    //  already 0 to mitigate the race condition described here:
    //  https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
    require(!((_value != 0) && (allowed[msg.sender][_spender] != 0)));

    allowed[msg.sender][_spender] = _value;
    Approval(msg.sender, _spender, _value);
}

The code as currently implemented does not handle these sorts of tokens properly, which would prevent USDT or CVX, from being used by this project.

Affected source code:

Recommended Mitigation Steps

Change from:

SafeERC20.safeApprove(IERC20(_assetIn), address(pool), _amountIn);

to:

SafeERC20.safeIncreaseAllowance(IERC20(_assetIn), address(pool), _amountIn);

@code423n4 code423n4 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 Jun 14, 2022
code423n4 added a commit that referenced this issue Jun 14, 2022
@jakekidd
Copy link
Collaborator

Duplicate of #154

@jakekidd jakekidd marked this as a duplicate of #154 Jun 26, 2022
@jakekidd jakekidd added the duplicate This issue or pull request already exists label Jun 26, 2022
@0xleastwood
Copy link
Collaborator

While the warden's finding is valid, they have failed to clearly outline the impact on functions related to the bridge transfer logic. As such, I think QA makes more sense.

@0xleastwood 0xleastwood added QA (Quality Assurance) Assets are not at risk. State handling, function incorrect as to spec, issues with clarity, syntax and removed 2 (Med Risk) Assets not at direct risk, but function/availability of the protocol could be impacted or leak value labels Aug 13, 2022
@0xleastwood
Copy link
Collaborator

Merging with #71.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working duplicate This issue or pull request already exists 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

3 participants