Submitted by hyh, also found by hansfriese
Malicious builder/contractor can change the subcontractor for any task even if all the terms was agreed upon and work was started/finished, but the task wasnt set to completed yet, i.e. its SCConfirmed, getAlerts(_taskID)[2] == true. This condition is not checked by inviteSC().
For example, a contractor can create a subcontractor of her own and front run valid setComplete() call with a sequence of inviteSC(task, own_subcontractor) -> setComplete() with a signatory from the own_subcontractor, stealing the task budget from the subcontractor who did the job. Contractor will not breach any duties with the community as the task will be done, while raiseDispute() will not work for a real subcontractor as the task record will be already changed.
Setting the severity to be high as this creates an attack vector to fully steal task budget from the subcontractor as at the moment of any valid setComplete() call the task budget belongs to subcontractor as the job completion is already verified by all the parties.
inviteSC() requires either builder or contractor to call for the change and verify nothing else:
Project.sol#L295-L316
_inviteSC() only checks non-zero address and calls inviteSubcontractor():
Project.sol#L747-L762
inviteSubcontractor() just sets the new value:
Tasks.sol#L106-L111
Task is paid only on completion by setComplete():
Project.sol#L349-L356
This way the absence of getAlerts(_taskID)[2] check and checkSignatureTask() call in inviteSC() provides a way for builder or contractor to steal task budget from a subcontractor.
Consider calling checkSignatureTask() when getAlerts(_taskID)[2] is true, schematically:
Project.sol#L310-L313
This approach is already implemented in changeOrder() where _newSC is a part of hash that has to be signed by all the parties:
Project.sol#L386-L403
Project.sol#L477-L481
checkSignatureTask() checks all the signatures:
Project.sol#L855-L861
zgorizzo69 (Rigor) disputed and commented:
hyh (warden) commented:
hyh (warden) commented:
parv3213 (Rigor) confirmed, but disagreed with severity and commented:
Jack the Pug (judge) decreased severity to Medium and commented:
