Possible DOS in lendToProject()
and toggleLendingNeeded()
function because unbounded loop can run out of gas
#336
Labels
2 (Med Risk)
Assets not at direct risk, but function/availability of the protocol could be impacted or leak value
bug
Something isn't working
old-submission-method
sponsor confirmed
Sponsor agrees this is a problem and intends to fix it (OK to use w/ "disagree with severity")
valid
Lines of code
https://github.com/code-423n4/2022-08-rigor/blob/5ab7ea84a1516cb726421ef690af5bc41029f88f/contracts/Project.sol#L710
Vulnerability details
Impact
In
Project
contract, thelendToProject()
function might not be available to be called if there are a lot of Task intasks[]
list of project. It means that the project cannot be funded by either builder or community owner.This can happen because
lendToProject()
usedprojectCost()
function. And the loop inprojectCost()
did not have a mechanism to stop, it’s only based on the lengthtaskCount
, and may take all the gas limit. If the gas limit is reached, this transaction will fail or revert.Same issue with
toggleLendingNeeded()
function which also callprojectCost()
function.Proof of Concept
Function
projectCost()
did not have a mechanism to stop, only based on thetaskCount
.There is no limit for builder when add task.
And function
lendToProject()
usedprojectCost()
to check the new total lent valueTools Used
Manual Review
Recommended Mitigation Steps
Consider keep value of
projectCost()
in a storage variable and update it when a task is added or updated accordingly.The text was updated successfully, but these errors were encountered: