MochiVault.flashFee()
May Truncate Result
#171
Labels
1 (Low Risk)
Assets are not at risk. State handling, function incorrect as to spec, issues with comments
bug
Something isn't working
Handle
leastwood
Vulnerability details
Impact
The
flashFee()
function differs to the implementation found inusdm.flashFee()
due to a missingSCALE
variable which ensures the result is not truncated. The end result forMochiVault.flashFee()
is that users could end up paying a slightly lower fee than intended if_amount
is somewhat small.This could abused by calling
flashLoan()
with a small_amount
input and continually reentering the contract before using the actual funds. This enables a user to pay marginally less in fees as compared to a typical user.If the asset being held in the vault is configured with a low
decimals
value, the degree of truncation could be significant, potentially resulting in little to no fees paid back intoMochiVault.sol
.Proof of Concept
https://github.com/code-423n4/2021-10-mochi/blob/main/projects/mochi-core/contracts/vault/MochiVault.sol#L345-L354
Tools Used
Manual code review
Recommended Mitigation Steps
Consider updating
return (_amount * 1337) / 1000000;
inMochiVault.flashLoan()
toreturn (_amount * ((1337 * SCALE) / 1000000)) / SCALE;
whereSCALE = 1e18
.The text was updated successfully, but these errors were encountered: