Submitted by b0g0
Any account holding a position inside V3Vault can transform any NFT position outside the vault that has been delegated to Revert operators for transformation (AutoRange, AutoCompound and all other transformers that manage positions outside of the vault).
The exploiter can pass any params at any time, affecting positions they do not own and their funds critically.
In order to borrow from V3Vault, an account must first create a collateralized position by sending his position NFT through the create() function
Any account that has a position inside the vault can use the transform() function to manage the NFT, while it is owned by the vault:
https://github.com/code-423n4/2024-03-revert-lend/blob/435b054f9ad2404173f36f0f74a5096c894b12b7/src/V3Vault.sol#L497
The user passes an approved transformer address and the calldata to execute on it. The problem here is that the function only validates the ownership of the uint256 tokenId input parameter. However, it never checks if the tokenId encoded inside bytes calldata data parameter belongs to msg.sender.
This allows any vault position holder to call an allowed transformer with arbitrary params encoded as calldata and change any position delegated to that transformer.
This will impact all current and future transformers that manage Vault positions. To prove the exploit, Im providing a coded POC using the AutoCompound transformer.
A short explanation of the POC:
You can add the following test to V3Vault.t.sol and run forge test --contracts /test/V3Vault.t.sol --mt testTransformExploit -vvvv.
Since the exploiter can control the calldata send to the transformer, he can impact any approved position in various ways. In the case of AutoCompound it can be:
Those are only a couple of ideas. The impact can be quite severe depending on the transformer and parameters passed.
Foundry
Consider adding a check inside transform() to make sure the provided tokenId and the one encoded as calldata are the same. This way the caller will not be able to manipulate other accounts positions.
Invalid Validation
kalinbas (Revert) confirmed
Revert mitigated:
Status: Mitigation confirmed. Full details in reports from ktg, thank_you and b0g0.
