Skip to content
Access control Audit finding Beginner

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.

jayjonah8 Follow

Originally disclosed on Code4rena

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

https://github.com/code-423n4/2021-12-yetifinance/blob/main/packages/contracts/contracts/StabilityPool.sol#L1143

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

The original report as published on Code4rena, by jayjonah8. Images and videos are our own copies; raw HTML is shown as text. View it on Code4rena.

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.

More by jayjonah8

View all

18 more disclosed reports, best first.

More from Yeti Finance contest

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Broken access control

The lesson behind this report.

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.