Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

If past subcontractor has been kicked, he can steal funds from new subcontractor for task completed. #128

Closed
code423n4 opened this issue Aug 5, 2022 · 3 comments
Labels
3 (High Risk) Assets can be stolen/lost/compromised directly bug Something isn't working duplicate This issue or pull request already exists valid

Comments

@code423n4
Copy link
Contributor

Lines of code

https://github.com/code-423n4/2022-08-rigor/blob/5ab7ea84a1516cb726421ef690af5bc41029f88f/contracts/Project.sol#L386-L490
https://github.com/code-423n4/2022-08-rigor/blob/5ab7ea84a1516cb726421ef690af5bc41029f88f/contracts/Project.sol#L330-L359

Vulnerability details

Impact

I have already commited the issue with the repeated calls of Project.changeOrder() by anyone.
Here is a worse usecase - past subcontractor can steal funds from new subcontractor for task completed.

Subcontractor's fund for completion can be stolen by a previous subcontractor (if any). Bad subcontractor can frontrun setComplete() transaction, if he calls Project.changeOrder() with already disclosed data+signature, set himself an active subcontractor and receives funds from task completed.

Proof of Concept

Project.changeOrder() is used to change subcontractors for tasks and costs for tasks.
Once this transaction is in history - it can be repeated by anyone using the same data+signature.
And here is setComplete() function.
https://github.com/code-423n4/2022-08-rigor/blob/5ab7ea84a1516cb726421ef690af5bc41029f88f/contracts/Project.sol#L330-L359
It makes a task completed and transfers money to a subcontractor.
The attack is:

  1. setComplete() is called to pay to new subcontractor for his completed task, transaction is in mempool
  2. past subcontractor (previously kicked) picks some changeOrder() in history, where he was a subcontractor
  3. past subcontractor frontruns Agreements & Disclosures #1, he transact with changeOrder()
  4. past subcontractor is now an active subcontractor
  5. setComplete() happens, bad-subcontractor-fronrunner receives funds

Tools Used

Hardhat

Recommended Mitigation Steps

Add nonce in data or store used data+signature

@code423n4 code423n4 added 3 (High Risk) Assets can be stolen/lost/compromised directly bug Something isn't working labels Aug 5, 2022
code423n4 added a commit that referenced this issue Aug 5, 2022
@0xA5DF
Copy link

0xA5DF commented Aug 11, 2022

Similar to #95, but not a dupe (only reusing signature, not re-completing a task).
Sidenote: this will only work if you have the signature of current SC, i.e. current SC was the SC when the changeOrder() was called in the first place.

Disclosure: #95 is my bug

@parv3213
Copy link
Collaborator

I say it a duplicate of #95

@itsmetechjay itsmetechjay added the duplicate This issue or pull request already exists label Aug 18, 2022
@parv3213
Copy link
Collaborator

Duplicate of #339

@parv3213 parv3213 marked this as a duplicate of #339 Aug 25, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
3 (High Risk) Assets can be stolen/lost/compromised directly bug Something isn't working duplicate This issue or pull request already exists valid
Projects
None yet
Development

No branches or pull requests

5 participants