receiveCollateral() can be called by anyone
The receiveCollateral() function in StabilityPool.sol lacks access control, allowing anyone to call it with arbitrary token and amount arguments to update the stability pool's balances. An attacker could manipulate the pool's accounting, potentially causing incorrect balances or denial of service.
Submitted by jayjonah8, also found by dalgarim and kenzo
Impact
In StabilityPool.sol, the receiveCollateral() function should be called by ActivePool per comments, but anyone can call it passing in _tokens and _amounts args to update stability pool balances.
Proof of Concept
Recommended Mitigation Steps
Allow only the ActivePool to call the receiveCollateral() function: require(msg.sender = address(active pool address), “Can only be called by ActivePool”)
kingyetifinance(Yeti finance) confirmed:
@LilYeti: This was also caught by our official auditor, but good catch.
0xtruco (Yeti finance) commented:
Fixed this, #190, #285, already in code https://github.com/code-423n4/2021-12-yetifinance/blob/main/packages/contracts/contracts/StabilityPool.sol#L1144
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
The receiveCollateral() function lacks a check that the caller is the ActivePool contract.
Impact
An attacker could call receiveCollateral() with arbitrary arguments to update the stability pool's balances, potentially causing incorrect accounting or denial of service.
What the attacker needed
None
The fix
The function was fixed by adding a check that only the ActivePool contract can call it.
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.
Smart contracts often have functions that should only be callable by specific other contracts. Here, a function meant to be called only by the ActivePool contract could be called by anyone. This means an attacker could directly change the stability pool's records without going through the proper process.
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.