`LendingPool#flashAction` is broken when trying to refinance position across `LendingPools` due to improper access control
The flashAction function in LendingPool calls updateActionTimestampByCreditor on the account, but that function is restricted to the current creditor. During refinancing, the new creditor calls flashAction, so the call reverts, making it impossible to refinance across lending pools.
Source: https://github.com/sherlock-audit/2023-12-arcadia-judging/issues/145
Found by
0x52
Summary
When refinancing an account, LendingPool#flashAction is used to facilitate the transfer. However due to access restrictions on updateActionTimestampByCreditor, the call made from the new creditor will revert, blocking any account transfers. This completely breaks refinancing across lenders which is a core functionality of the protocol.
Vulnerability Detail
IAccount(account).updateActionTimestampByCreditor();
asset.safeTransfer(actionTarget, amountBorrowed);
{
uint256 accountVersion = IAccount(account).flashActionByCreditor(actionTarget, actionData);
if (!isValidVersion[accountVersion]) revert LendingPoolErrors.InvalidVersion();
}
We see above that account#updateActionTimestampByCreditor is called before flashActionByCreditor.
function updateActionTimestampByCreditor() external onlyCreditor updateActionTimestamp { }
When we look at this function, it can only be called by the current creditor. When refinancing a position, this function is actually called by the pending creditor since the flashaction should originate from there. This will cause the call to revert, making it impossible to refinance across lendingPools.
Impact
Refinancing is impossible
Code Snippet
Tool used
Manual Review
Recommendation
Account#updateActionTimestampByCreditor() should be callable by BOTH the current and pending creditor
Discussion
sherlock-admin2
1 comment(s) were left on this issue during the judging contest.
takarez commented:
invalid
sherlock-admin
The protocol team fixed this issue in PR/commit https://github.com/arcadia-finance/lending-v2/pull/133.
Thomas-Smets
Fix consists out of two PR's:
- accounts: https://github.com/arcadia-finance/accounts-v2/pull/173
- lending: https://github.com/arcadia-finance/lending-v2/pull/133
IAm0x52
Fix looks good. Removes the updateActionTimestampByCreditor call and instead uses a callback to enforce nonreentrant and prevent ERC777s from reentering
sherlock-admin4
The Lead Senior Watson signed off on the fix.
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
Root cause
Likely the access control on updateActionTimestampByCreditor only allows the current creditor, but the refinancing flow requires the new creditor to call it.
Impact
Refinancing across lending pools is impossible, breaking a core protocol feature.
What the attacker needed
A lending position; refinancing across pools
The fix
The protocol team fixed this issue by removing the updateActionTimestampByCreditor call and using a callback to enforce nonreentrancy and prevent ERC777 reentrancy.
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.
A lending pool lets users borrow assets against collateral. Refinancing means moving a loan from one pool to another. The code that handles the move calls a function that only the old pool is allowed to call, so the move always fails.
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.