exchangeRate could be zero which allow a user to be solvent even if no collateral was added #1605
Labels
bug
Something isn't working
downgraded by judge
Judge downgraded the risk level of this issue
duplicate-316
grade-b
Q-13
QA (Quality Assurance)
Assets are not at risk. State handling, function incorrect as to spec, issues with clarity, syntax
Lines of code
https://github.com/Tapioca-DAO/tapioca-bar-audit/blob/2286f80f928f41c8bc189d0657d74ba83286c668/contracts/markets/bigBang/BigBang.sol#L101
Vulnerability details
Impact
exchangeRate
can be zero ifupdateExchangeRate()
failed when calling init(), user then can borrow and be solvent even if the user is not solvent or for example didn't add any collateral. This is against how the protocol is intended to work.Proof of Concept
In
init()
,updateExchangeRate()
is being called to read value from oracle to set the state variableexchangeRate
since it's zero and not initialized yet.Code link
basically the functiion
updateExchangeRate()
is trying to read the rate from oracle but if it fails it will just take the old rateCode link
There is a possibility that
exchangeRate
might fail for the first time getting the rate from oracle thus. Thus,exchangeRate
will take the old rate which is zero untilupdateExchangeRate()
called again.During this time, someone could borrow amount without being solvent. Although, this is an edge case, it is still possible. The protocol should simply set a default value for
exchangeRate
. or revert any impacted operation ifexchangeRate
. is still zero.Tools Used
Manual Review
Recommended Mitigation Steps
Set a default value for
exchangeRate
.or revert any impacted operation (e.g. borrow) ifexchangeRate
. is still zero.Assessed type
Other
The text was updated successfully, but these errors were encountered: