hats-finance / Proof-Of-Humanity-V2-0xef0709445d394a22704850c772a28a863bb780b0

Proof of Humanity Protocol v2
2 stars 1 forks source link

Exploit Allows Malicious Actors to Withdraw Crowdfunded Deposits Without Initial Contribution in ProofOfHumanity #70

Open hats-bug-reporter[bot] opened 2 weeks ago

hats-bug-reporter[bot] commented 2 weeks ago

Github username: -- Twitter username: -- Submission hash (on-chain): 0x2417167ee47301faee01ca53707bf93627f82bcd486a2f5113d455f08f409ee6 Severity: high

Description: Description\ There is a potential exploit in the ProofOfHumanity contract that allows a malicious actor to create a humanity request without depositing any amount, have the request crowdfunded by others, and then withdraw the request to claim the funds. This exploit arises due to the lack of a minimum deposit requirement when creating a humanity request and the ability to withdraw the request while it is still in the Vouching state.

Attack Scenario\

  1. Creating Humanity Without Deposit:
3. Withdrawing the Request:

* The withdrawRequest function allows the requester to withdraw the request if it is in the Vouching state.
* This function deletes the request count, sets the request status to Resolved, and calls withdrawFeesAndRewards to withdraw the fees and rewards to the requester.
```solidity
function withdrawRequest() external {
    bytes20 humanityId = accountHumanity[msg.sender];
    Humanity storage humanity = humanityData[humanityId];
    uint256 requestId = humanity.requestCount[msg.sender] - 1;
    Request storage request = humanity.requests[requestId];
    require(request.status == Status.Vouching);

    delete humanity.requestCount[msg.sender];
    request.status = Status.Resolved;

    withdrawFeesAndRewards(payable(msg.sender), humanityId, requestId, 0, 0);

    emit RequestWithdrawn(humanityId, requestId);
}

Attachments

  1. Proof of Concept (PoC) File

Step 1: Malicious actor calls claimHumanity with msg.value set to zero.

claimHumanity(0x1234567890abcdef1234567890abcdef12345678, "evidence_link", "Malicious Actor");

Step 2: Crowd funds the request by calling fundRequest.

fundRequest(0x1234567890abcdef1234567890abcdef12345678, 0);

Step 3: Malicious actor calls withdrawRequest to withdraw the request and claim the funds.

withdrawRequest();
  1. Revised Code File (Optional)
clesaege commented 2 weeks ago

Similar to https://github.com/hats-finance/Proof-Of-Humanity-V2-0xef0709445d394a22704850c772a28a863bb780b0/issues/15