code-423n4 / 2022-12-prepo-findings

0 stars 1 forks source link

Collateral deposit function can break when fee is amount are too small #248

Closed code423n4 closed 1 year ago

code423n4 commented 1 year ago

Lines of code

https://github.com/prepo-io/prepo-monorepo/blob/3541bc704ab185a969f300e96e2f744a572a3640/apps/smart-contracts/core/contracts/Collateral.sol#L47

Vulnerability details

Impact

When the deposit() function is called, the function confirms that, if a depositFee is set, the resulting fee is greater than zero.

if (depositFee > 0) { require(_fee > 0, "fee = 0"); }

However, deposits are likely to be made in USDC, which only has 6 decimals. Meanwhile, the depositFee is recorded as a value out of 1 million.

As a result, if depositFee is set to a very small value, then the function will revert for small USDC deposits.

Proof of Concept

Let's say the depositFee is set to 1:

Tools Used

Manual Review

Recommended Mitigation Steps

There's no need to require that fee > 0. Instead, simplify to only check that _amount > 0.

Picodes commented 1 year ago

Duplicate #275

c4-judge commented 1 year ago

Duplicate of https://github.com/code-423n4/2022-12-prepo-findings/issues/256