Revert Lend - cryptphi's results

A lending protocol specifically designed for liquidity providers on Uniswap v3.

General Information

Platform: Code4rena

Start Date: 04/03/2024

Pot Size: $88,500 USDC

Total HM: 31

Participants: 105

Period: 11 days

Judge: ronnyx2017

Total Solo HM: 7

Id: 342

League: ETH

Revert

Findings Distribution

Researcher Performance

Rank: 6/105

Findings: 2

Award: $1,620.06

🌟 Selected for report: 1

πŸš€ Solo Findings: 1

Findings Information

🌟 Selected for report: cryptphi

Labels

bug
2 (Med Risk)
satisfactory
selected for report
sponsor acknowledged
sufficient quality report
:robot:_71_group
M-13

Awards

1577.2848 USDC - $1,577.28

External Links

Lines of code

https://github.com/code-423n4/2024-03-revert-lend/blob/main/src/transformers/AutoRange.sol#L276-L297

Vulnerability details

Impact

The AutoRange.configToken() function updates the state variable positionConfigs for a tokenId and callable by the owner of the tokenId. However, in the call to AutoRange.execute(), the state variable positionConfigs for the tokenid is used in setting the local variable PositionConfig memory config without any further check to ensure the config has been set by the current owner of the tokenId

This in some way could affect the swapcall on the token position such that the protocol does not receive any incentive.

Proof of Concept

  1. Alice is an operator and owns token 1 and sets the configToken() to configure token to be used before calling executeWithVault()

https://github.com/code-423n4/2024-03-revert-lend/blob/main/src/transformers/AutoRange.sol#L276-L297

positionConfigs state variable for tokenId is set in configToken() by token owner.

function configToken(uint256 tokenId, address vault, PositionConfig calldata config) external { _validateOwner(tokenId, vault); // lower tick must be always below or equal to upper tick - if they are equal - range adjustment is deactivated if (config.lowerTickDelta > config.upperTickDelta) { revert InvalidConfig(); } positionConfigs[tokenId] = config;
  1. After a while and eventually Alice no longer has any position on token and transfers the token to Bob.

  2. Bob is another operator and calls executeWithVault(), the calls happen using the old token config set by Alice. https://github.com/code-423n4/2024-03-revert-lend/blob/main/src/transformers/AutoRange.sol#L111-L116

positionConfigs[tokenId] set by a previous tokenId owner being used.

function execute(ExecuteParams calldata params) external { if (!operators[msg.sender] && !vaults[msg.sender]) { revert Unauthorized(); } ExecuteState memory state; PositionConfig memory config = positionConfigs[params.tokenId];

Tools Used

Manual

Using an enumerable set or additional mapping parameter to set the current owner in the positionConfigs state variable and an additional check in execute() to ensure the config was set by token owner.

Assessed type

Other

#0 - c4-pre-sort

2024-03-21T15:12:29Z

0xEVom marked the issue as duplicate of #370

#1 - c4-pre-sort

2024-03-21T15:12:32Z

0xEVom marked the issue as sufficient quality report

#2 - c4-pre-sort

2024-03-22T16:06:31Z

0xEVom marked the issue as not a duplicate

#3 - c4-pre-sort

2024-03-22T16:06:37Z

0xEVom marked the issue as duplicate of #55

#4 - c4-pre-sort

2024-03-22T16:12:15Z

0xEVom marked the issue as not a duplicate

#5 - kalinbas

2024-03-26T16:21:53Z

Position config is not reset when transfering a position to someone else, but the operator approval / approvalforall is reset. So the position cant be automated anymore, and if it is given approval the revert UI will also let the user set the new config. So this is valid but not a problem.

#6 - c4-sponsor

2024-03-26T16:21:57Z

kalinbas (sponsor) acknowledged

#7 - jhsagd76

2024-03-31T09:30:14Z

makes sense, and I also believe that frontend security checks are unreliable, so I'm still maintaining it as an M.

#8 - c4-judge

2024-03-31T09:30:21Z

jhsagd76 marked the issue as satisfactory

#9 - c4-judge

2024-04-01T15:33:46Z

jhsagd76 marked the issue as selected for report

Awards

42.7786 USDC - $42.78

Labels

bug
disagree with severity
downgraded by judge
grade-a
insufficient quality report
QA (Quality Assurance)
sponsor acknowledged
edited-by-warden
:robot:_17_group
Q-01

External Links

Lines of code

https://github.com/code-423n4/2024-03-revert-lend/blob/435b054f9ad2404173f36f0f74a5096c894b12b7/src/transformers/LeverageTransformer.sol#L124

Vulnerability details

Impact

The leverageDown functions in LeverageTransformer contract are expected to be called by V3Vault. However, there is no access control to check that the caller is an authorized V3Vault address.

Due to this, it is possible for any user owned contract to be approved for erc20 tokens and steal tokens held in the contract https://github.com/code-423n4/2024-03-revert-lend/blob/435b054f9ad2404173f36f0f74a5096c894b12b7/src/transformers/LeverageTransformer.sol#L165C9-L166C65

Proof of Concept

https://github.com/code-423n4/2024-03-revert-lend/blob/435b054f9ad2404173f36f0f74a5096c894b12b7/src/transformers/LeverageTransformer.sol#L165C9-L166C65

Tools Used

Manual

Add a check to ensure caller is approved vault address

Assessed type

ERC20

#0 - c4-pre-sort

2024-03-16T10:10:54Z

0xEVom marked the issue as duplicate of #366

#1 - c4-pre-sort

2024-03-18T09:14:48Z

0xEVom marked the issue as sufficient quality report

#2 - c4-pre-sort

2024-03-23T19:34:36Z

0xEVom marked the issue as not a duplicate

#3 - c4-pre-sort

2024-03-23T19:34:40Z

0xEVom marked the issue as insufficient quality report

#4 - 0xEVom

2024-03-23T19:35:00Z

LeverageTransformer does not hold any tokens.

#5 - c4-sponsor

2024-03-26T14:21:18Z

kalinbas (sponsor) disputed

#6 - c4-sponsor

2024-03-26T14:21:34Z

kalinbas (sponsor) acknowledged

#7 - c4-sponsor

2024-03-26T14:21:48Z

kalinbas marked the issue as disagree with severity

#8 - kalinbas

2024-03-26T14:24:26Z

Will add check for allow list of vault, but it is no risk because the contract doesn't hold any tokens.

#9 - jhsagd76

2024-03-29T00:42:22Z

I mark this as a Low, because there are many many same things in the mainnet dapps. Losses are always dust (even though by design we shouldn't have any tokens in this contract), so it's still something to be mindful of.

#10 - c4-judge

2024-03-29T00:42:35Z

jhsagd76 changed the severity to QA (Quality Assurance)

#11 - jhsagd76

2024-03-29T00:42:57Z

L-A

#12 - c4-judge

2024-03-29T00:43:01Z

jhsagd76 marked the issue as grade-a

#13 - kalinbas

2024-04-11T00:26:56Z

AuditHub

A portfolio for auditors, a security profile for protocols, a hub for web3 security.

Built bymalatrax Β© 2024

Auditors

Browse

Contests

Browse

Get in touch

ContactTwitter