Project.addTasks() wouldn’t work properly when it’s called from disputes contract.
The addTasks function requires the caller-supplied task count to match the current task count, but a dispute resolution can take time during which new tasks are added, causing the dispute resolution call to revert. An attacker could not exploit this directly, but it causes a denial of service for dispute resolution.
Originally disclosed on Code4rena
Submitted by hansfriese, also found by Lambda
addTasks() function checks this require() to make sure _taskCount is correct.
But it might revert when this function is called after a dispute because it takes a certain time to resolve disputes and other tasks might be added meanwhile.
Proof of Concept
The below scenario would be possible.
- A project contains 10 active tasks(taskCount = 10) and a builder and contractor are going to add one more task.
- There were some disagreements between a builder and contractor so they raised a dispute with _taskCount = 10 using raiseDispute().
- Normally it would take a certain time(like 1 day or more) to resolve the dispute as it must be done by HomeFi owner.
- Meanwhile, if the builder and contractor need to add another task, they should set
_taskCount = 10andtaskCountwill be 11 after addition here. - After that, the HomeFi admin agreed to add a task with
_taskCount = 10, but it will revert here.
So currently, the project builder and contractor shouldn’t add new tasks to make their previous dispute valid.
I think it’s reasonable to modify that they can add other tasks even though there is an active dispute.
Tools Used
Solidity Visual Developer of VSCode
Recommended Mitigation Steps
I think we can modify not to compare taskCount when it’s called from disputes contract.
So we can modify this part like below.
if (_msgSender() != disputes) {
require(_taskCount == taskCount, "Project::!taskCount");
}
else {
_taskCount = taskCount;
}
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
Impact
The dispute resolution call reverts, preventing the dispute from being resolved until no new tasks are added, effectively blocking dispute resolution.
What the attacker needed
An active dispute; new tasks added during dispute
How it was found
- A project has 10 active tasks and a dispute is raised with _taskCount = 10.
- While the dispute is pending, the builder and contractor add another task, setting _taskCount = 10 and increasing taskCount to 11.
- The HomeFi admin tries to resolve the dispute by calling addTasks with _taskCount = 10, but the require check fails because taskCount is now 11.
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.
A smart contract function checks that the number of tasks passed in matches the current number of tasks. If tasks are added while a dispute is being resolved, the dispute resolution call will fail because the numbers no longer match. This means the dispute cannot be resolved until no new tasks are added.
What is DoS?
A request that exhausts resources or crashes a component. Many programs forbid testing it; reports usually show it from code, not by attacking.