DeFiHardhatFoundry
250,000 USDC
View results
Submission Details
Severity: low
Valid

Permit functions will not work with certain tokens

Summary

The protocol aims to work with all ERC20 tokens which are accepted in farm contracts, based on the information provided in the readme, however, the permit functions will not work with certain tokens like DAI, which do not follow the EIP2612 standard.

Vulnerability Details

From TokenFacet.sol and TokenSupportFacet.sol , the permit functions can be seem which is intended to allow users to access the permit functionalities of the tokens they'd like to approve. The problem is that the function signature provided doesn't account for tokens with Dai like permit signature which features a nonce in addition to the other parameters.

In TokenFacet.sol, permitToken calls LibTokenPermit.permit using the owner, spender, token, value, deadline, v, r, s parameters.

function permitToken(
address owner,
address spender,
address token,
uint256 value,
uint256 deadline,
uint8 v,
bytes32 r,
bytes32 s
) external payable fundsSafu noNetFlow noSupplyChange nonReentrant {
LibTokenPermit.permit(owner, spender, token, value, deadline, v, r, s);
LibTokenApprove.approve(owner, spender, IERC20(token), value);
}

The same can be observed In TokenSupportFacet.sol, in which the token's permit function is queried using then owner, spender, value, deadline, v, r, s parameters.

function permitERC20(
IERC20Permit token,
address owner,
address spender,
uint256 value,
uint256 deadline,
uint8 v,
bytes32 r,
bytes32 s
) public payable fundsSafu noNetFlow noSupplyChange {
token.permit(owner, spender, value, deadline, v, r, s);
}

However, Dai and its equivalents have a permit function that looks like this.

function permit(address holder, address spender, uint256 nonce, uint256 expiry,
bool allowed, uint8 v, bytes32 r, bytes32 s) external
{

This means that due to the missing nonce field, DAI, a token that allows permit based interactions, cannot be used with signed messages as the permit transactions will revert.

Some tokens also have phantom permits, WETH for example, which do not revert on call to the permit function even though the tokens lack the permit function, which can lead to malicious approvals on behalf of the token owners.

Impact

Unexpected behaviour due to tokens with non standard permits, including failures and phantom approvals.

Tools Used

Manual Code Review, Reference

Recommendations

Consider introducing a different implementation of the permit functions which allows a nonce variable. An implementation like that of Uniswap Permit2 may also help.

Updates

Lead Judging Commences

inallhonesty Lead Judge 11 months ago
Submission Judgement Published
Invalidated
Reason: Non-acceptable severity
Assigned finding tags:

Permit function doesn't work with some tokens like DAI

Appeal created

inallhonesty Lead Judge 11 months ago
Submission Judgement Published
Validated
Assigned finding tags:

Permit is incompatible with some tokens.

Support

FAQs

Can't find an answer? Chat with us on Discord, Twitter or Linkedin.