The onlyBeneficiaryWithIsInherited modifier contains an off-by-one error in its loop condition, which leads to an out-of-bounds array access. This can cause the contract to revert unexpectedly, preventing valid beneficiaries from executing restricted functions.
In the following code:
The condition (i < beneficiaries.length + 1) is incorrect because:
THis array is zero-indexed (as i = 0), meaning the last valid index is beneficiaries.length - 1.
When i = beneficiaries.length, the code attempts to access beneficiaries[i], which does not exist, causing a revert due to an out-of-bounds error.
Function Execution Failure: Any function using this modifier may revert unexpectedly, preventing even valid beneficiaries from executing their transactions.
Security Risk: This issue can be exploited to intentionally block contract operations by keeping an empty beneficiary list or controlling execution flow.
Manual review
Fixed out-of-bounds error by changing while (i < beneficiaries.length + 1) to while (i < beneficiaries.length)
The contest is live. Earn rewards by submitting a finding.
This is your time to appeal against judgements on your submissions.
Appeals are being carefully reviewed by our judges.