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

`WETH` token doesn't have `permit` function

Summary

The TokenSupportFacet::permitERC20 function is designed to support ERC-20 tokens that implement the IERC20Permit interface. However, the Wrapped Ether (WETH) token does not implement the permit function. This could allow a malicious user to call the function without a valid signature, leading to potential security vulnerabilities.

Vulnerability Details

The TokenSupportFacet::permitERC20 function calls the ERC20::permit function and the goal of the function is to support the contracts that inherit ERC20Permit contract.

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);
}

The problem is that not all ERC20 tokens have permit function in their token contracts. The WETH token is one of them and this token is used from the protocol. If a token like WETH, which does not implement permit, is passed, the function will not revert, potentially allowing unauthorized approvals:

Most ERC20 have the permit function to approve a spender if a valid signature is provided.
However WETH does not. Surprisingly, when permit is called on WETH, the function call will execute without any errors.
This is because the fallback inside WETH is execute when permit is called.

Link: https://solidity-by-example.org/hacks/weth-permit/

Impact

Malicious users could call the permitERC20 function with an empry signature and WETH token that does not implement permit function, bypassing signature verification and gaining approval to transfer tokens from the victim's account without their consent. This leads to loss of tokens for the victim.

Tools Used

Manual Review

Recommendations

Implement a check to ensure the token contract supports the permit function before calling it.

Updates

Lead Judging Commences

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

Protocol will be incompatible with WETH token due to WETH lacking permit function

Appeal created

bube Submitter
11 months ago
inallhonesty Lead Judge 10 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.