Open hats-bug-reporter[bot] opened 2 months ago
poh.advanceState(user, new address[](0), new ProofOfHumanity.SignatureVouch[](0));
In your example, you try to advance without providing vouches. It should indeed fail.
So this is the desired behaviour.
@clesaege calling the advanceState() without vouches is intended because it is expected as per the natspec:
- @param _claimer The address of the human whose request status to advance.
- @param _vouches Array of users whose vouches to count (optional).
- @param _signatureVouches Array of EIP-712 signatures of struct IsHumanVoucher (optional). here
you can see _vouches
& _signatureVouches
are optional.
Each are optional, but providing neither will not exhibit enough vouches so would fail. This is the desired behaviour.
Github username: @itsabinashb Twitter username: itsabinashb Submission hash (on-chain): 0x2d01d062fe5390dc97abb64265ca00f9596b5c5b0d8ab95a7f60f84e5d5eb434 Severity: high
Description: Description\ The
ProofOfHumanity::advanceState()
is expected to work properly without 2 arguments - 1. address[] calldata _vouches & 2. SignatureVouch[] calldata _sigantureVouches. But if the function is called like this i.e without these 2 arguments then the call will revert by 'array out-of-bound access'. The reason behind this is at firstrequest.vouches.length
is 0, if we consider therequiredNumberOfVouches
1 so it will iterate 1 time, so in first itereation as we did not pass the_signatureVouches
thenbSignatureVouches
will be 0, so as 0 is not less than 0 so theif
block will not execute, theelse
part will execute, inelse
partvoucherAccount = _vouches[i - nbSignatureVouches] = _vouches[0]
, so as there is no element in 0th index so it will revert by out of bound access error.Attack Scenario\
None attack is required, it will DoS automatically. Attachments
import {Test, console} from "forge-std/Test.sol"; import "../contracts/ProofOfHumanity.sol"; import "../contracts/test-helpers/MockArbitrator.sol"; import "../contracts/test-helpers/MockUpgradableProxy.sol"; import "@kleros/erc-792/contracts/IArbitrator.sol";
contract pohTest is Test { address wNative; IArbitrator arbitrator; // ARBITRATOR_EXTRA_DATA set in setUp() string registrationMetaEvidence; string clearingMetaEvidence; uint256 requestBaseDeposit; uint40 humanityLifespan; uint40 renewalPeriodDuration; uint40 challengePeriodDuration; uint40 failedRevocationCooldown; uint256[3] multipliers = [10000, 10000, 20000]; uint32 requiredNumberOfVouches; MockUpgradableProxy proxy; ProofOfHumanity poh; address CCPOH; // crossChainProofOfHumanity string MAINNET_RPC;
}
// assert(1 == 2); voucherAccount = _vouches[i - nbSignatureVouches]; assert(1 == 2);