Malicious delegated contractor can block funding tasks or mark tasks as complete
A delegated contractor can add many tasks or one with a huge cost, preventing funding in allocateFunds(), and can complete tasks to transfer funds to subcontractors. The builder cannot replace the contractor, only remove delegation.
Submitted by indijanc
Project.sol#L219 Project.sol#L655 Project.sol#L807
A malicious delegated contractor can add a huge number of tasks (or one task with a huge cost). This would then pose problems in allocateFunds() as tasks could not be funded. Builder could remove delegation for the contractor but couldn’t replace the contractor and so couldn’t remove the malicious contractor. The contractor is required to sign various state changes in Project.sol. A delegated contractor can also for example complete tasks which results in transferring funds to subcontractors.
This sounds very problematic and would be critical, but reading through the documentation and the code, I’m assuming there is certain trust incorporated and required for the system to work. Hence I’m assuming the system considers a delegated contractor is trustworthy as is the builder. So while the impact may be big I consider the likelihood quite small.
Proof of Concept
When a contractor is delegated, various operations only need his signature. Project.sol L807
Tools Used
Visual Studio Code
Recommended Mitigation Steps
There’s a couple of improvements you could consider:
- Create a function to update
lastAllocatedTask. This could be restricted toDisputescontract or the builder. This could be used against maliciously inserted tasks. - Add functionality for
Disputescontract to be able to remove or replace the contractor. This would be a guard against malicious contractors.
parv3213 (Rigor) acknowledged, but disagreed with severity
Jack the Pug (judge) commented:
I like this finding, but this is probably a design choice. The suggestions make sense to me. I’ll keep this as a Medium.
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
Root cause
Likely the design assumes the delegated contractor is trustworthy, so there is no mechanism for the builder or disputes contract to replace a malicious contractor or to override the last allocated task.
Impact
A malicious contractor could block funding tasks or mark tasks complete to transfer funds to subcontractors; the builder can only remove delegation, not replace the contractor.
What the attacker needed
Attacker is a delegated contractor; builder has delegated to the contractor
The fix
The report suggests adding a function to update lastAllocatedTask (restricted to Disputes or builder) and allowing the Disputes contract to remove or replace the contractor.
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.
In this smart contract system, a builder delegates work to a contractor. The contractor can add tasks and mark them complete, which moves money. If the contractor is malicious, they can add so many tasks that the funding function breaks, or mark tasks complete to send money to subcontractors. The builder can stop the contractor from acting but cannot remove them entirely.
What is Access control?
A user can do something their role should not allow: reach an admin function, act on a feature they have not paid for, or skip a permission check. IDOR is the special case where the object belongs to someone else.