In Project.setComplete() , the signature can be reused when the first call is reverted for some reason
The approveHash function only allows setting an approval to true, with no way to cancel it. A signature approved for setComplete can be reused later after a dispute changes the task cost, letting the service contractor complete the task without additional work.
Originally disclosed on Code4rena
Submitted by hansfriese, also found by cccz
setComplete() function might be called successfully using the past signature when it shouldn’t work.
As a result, a task might be completed when a builder doesn’t want it.
Proof of Concept
approveHash() function can set only true so there is no method to cancel already approved hash without passing validation here.
So the below scenario would be possible.
- A builder, GC, and SC started a task and SC finished the task.
- They are approved to complete the task and signed the signature.
- But right before to call setComplete() using the signature, the SC felt the cost is too low and raised a dispute to change the order using raiseDispute().
- As I suggested with another medium issue, the task can’t be completed when there is an ongoing dispute from this document - “If there is no ongoing dispute about that project, task status is updated and payment is made.”. So
setComplete()might revert. - Even if it doesn’t check active disputes as now,
setComplete()might revert when the funds haven’t been allocated and a builder signed by fault. - After that, the HomeFi admin accepted the dispute, and the cost of the task was increased as SC wanted.
- Then the builder would hope to get more results (or scores) from this task as the cost is increased rather than completed right away.
- But SC can call
setComplete()using the previous signature and complete the task without additional work. - A builder might know about that before and try to update task hash but it will revert because SC doesn’t agree to updateTaskHash().
- In this case, it’s logical to cancel the approved hash here but there is no such option.
I don’t know if there would be similar problems with other functions that use signature and I think it would reduce the risk a little if we add an option to cancel the approved hash.
Tools Used
Solidity Visual Developer of VSCode
Recommended Mitigation Steps
Recommend modifying approveHash() like below.
function approveHash(bytes32 _hash, bool _bool) external override { //++++++++++++++++++++
address _sender = _msgSender();
// Allowing anyone to sign, as its hard to add restrictions here.
// Store _hash as signed for sender.
approvedHashes[_sender][_hash] = _bool; //+++++++++++++++++++
emit ApproveHash(_hash, _sender, _bool); //++++++++++++++++++++++
}
I am not so sure that a similar scenario would be possible in the Community contract also and recommend to change both functions together.
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 approveHash function only sets approvals to true and provides no way to revoke an approved hash, so a previously signed message remains valid indefinitely.
Impact
A task could be completed when the builder does not want it, potentially without the additional work expected after a cost increase.
What the attacker needed
A task with builder, GC, and SC; SC has signed the completion signature; SC raises a dispute before setComplete
The fix
The approveHash function should be modified to accept a boolean parameter so that an approved hash can be cancelled.
How it was found
- A builder, GC, and SC start a task and SC finishes it.
- They approve completion and sign the signature.
- Before setComplete is called, SC raises a dispute to change the order.
- The admin accepts the dispute and increases the task cost.
- SC calls setComplete using the previous signature, completing the task without additional work.
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 lets people approve a digital signature that says 'yes, complete this task'. The problem is that once approved, that approval can never be cancelled. So if the situation changes (for example, a dispute raises the payment), the old approval still works and can be used to finish the task without doing the extra work.
What is Business logic?
The application works as coded but not as intended: a negative price, a skipped payment step, a limit that can be crossed.