Anyone who approved quote tokens to a pool can be forced to take
The take functions in ERC20Pool and ERC721Pool allow anyone to specify a callee_ address that has approved quote token spending to the pool, causing that address to pay quote tokens and receive collateral. An attacker can force any user who approved quote tokens to take on collateral, potentially of low value, while paying the quote tokens.
Source: https://github.com/sherlock-audit/2023-01-ajna-judging/issues/145
Found by
Jeiwan
Summary
Taking may be executed on behalf of any address who approved spending of quote tokens to a pool: such address will pay quote tokens and will receive collateral.
Vulnerability Detail
ERC20Pool and ERC721Pool implement the take functions, which buy collateral from auction in exchange for quote tokens. The address to pull quote tokens from is specified in the callee_ argument, which allows anyone to call the functions and pass an address that has previously approved spending of the quote token to the pool. As a result, such an address will pay for the liquidation and will receive the collateral.
Impact
Anyone can initiate a take on behalf of another user. Such user can be a lender who has previously approved spending of the quote token to the pool. Calling take with the user's address specified as the callee_ argument will result in:
- the user receiving collateral, which may have low value;
- the user paying the quote token to repay the debt being taken.
Code Snippet
ERC20Pool.sol#L460 ERC721Pool.sol#L463
Tool used
Manual Review
Recommendation
In the ERC20Pool.take and ERC721Pool.take functions, consider transferring collateral only from msg.sender. Alternatively, consider checking that callee_ has approved spending quote tokens to msg.sender.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
How it worked
Impact
Any user who has approved quote tokens to the pool can be forced to pay quote tokens and receive collateral, which may have low value.
What the attacker needed
Victim has approved quote tokens to the pool; attacker can call take function
The fix
The take functions should transfer collateral only from msg.sender, or check that callee_ has approved spending quote tokens to msg.sender.
Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
In a lending pool, users approve the pool to spend their tokens so they can participate. The take function lets someone buy collateral from an auction using quote tokens. The problem is that the function lets the caller choose whose tokens to use, so anyone can make another user pay for the purchase and receive the collateral, even if that user didn't want to.
What is Access control?
A user can do something their role should not allow: reach an admin function, act on a feature they have not paid for, or skip a permission check. IDOR is the special case where the object belongs to someone else.