V3Vault.sol
permit signature does not check receiving token address is USDC
#368
Labels
3 (High Risk)
Assets can be stolen/lost/compromised directly
bug
Something isn't working
H-01
primary issue
Highest quality submission among a set of duplicates
🤖_23_group
AI based duplicate group recommendation
satisfactory
satisfies C4 submission criteria; eligible for awards
selected for report
This submission will be included/highlighted in the audit report
sponsor confirmed
Sponsor agrees this is a problem and intends to fix it (OK to use w/ "disagree with severity")
sufficient quality report
This report is of sufficient quality
Lines of code
https://github.com/code-423n4/2024-03-revert-lend/blob/main/src/V3Vault.sol#L717-L725
https://github.com/code-423n4/2024-03-revert-lend/blob/main/src/V3Vault.sol#L893-L898
https://github.com/code-423n4/2024-03-revert-lend/blob/main/src/V3Vault.sol#L877-L917
Vulnerability details
In
V3Vault.sol
there all 3 instances ofpermit2.permitTransferFrom()
, all 3 does not check token transfered in is USDC token.Allowing user to craft permit signature from any ERC20 token and Vault will accept it as USDC.
Impact
User can steal all USDC from vault using permit signature of any ERC20 token.
Proof of Concept
Here is how Vault accept USDC from user. Vault will accept
Uniswap.Permit2
signature transfer allowance from Permit2 then to vault contract.https://github.com/code-423n4/2024-03-revert-lend/blob/435b054f9ad2404173f36f0f74a5096c894b12b7/src/V3Vault.sol#L877C1-L917C6
Below is permit signature struct that can be decoded from user provided data.
V3Vault.sol
need to checkTokenPermissions.token
is USDC, same as vault main asset.Uniswap.permit2.permitTransferFrom()
only check sign signature is correct. This is meaningless is Vault does not validate input data.This allow user to use any ERC20 token. give allowance and permit to
Uniswap.Permit2
Vault will accept any transfer token from
Permit2
as USDC.Allowing user to deposit any ERC20 token and steal USDC from vault.
Tools Used
Recommended Mitigation Steps
fix missing user input validation in 3 all instances of permit2
https://github.com/code-423n4/2024-03-revert-lend/blob/main/src/V3Vault.sol#L717C1-L725C15
https://github.com/code-423n4/2024-03-revert-lend/blob/main/src/V3Vault.sol#L893C1-L898C15
https://github.com/code-423n4/2024-03-revert-lend/blob/main/src/V3Vault.sol#L877C1-L917C6
Assessed type
ERC20
The text was updated successfully, but these errors were encountered: