The onlyBeneficiaryWithIsInherited
modifier in the InheritanceManager
contract does not implement a proper access control. Instead of explicitly checking permissions and reverting when unauthorized, it relies on an array out-of-bounds error to halt execution for unauthorized callers, and has an additional vulnerability that allows complete bypass under certain conditions.
This modifier has two issues:
It relies on an array out-of-bounds error to prevent unauthorized access, rather than explicitly checking permissions and properly revert the transaction in case of failure.
It can be completely bypassed by transactions originating from address(0) when there are empty slots in the beneficiaries array. This can occur for example when a contract owner deletes a beneficiary, leaving the slot empty.
Unreliable access control: The modifier relies on an implicit array out-of-bounds error to prevent unauthorized access rather than explicit checks. This is not a proper security practice and may behave unpredictably across different EVM implementations.
Modifier Bypass: If a beneficiary is removed using removeBeneficiary()
, it leaves address(0)
in the array. Any transaction from address(0)
can then match this entry and bypass access control, allowing attacker to call protected functions.
The following code demonstrates both vulnerabilities in the modifier:
Place the test in the test folder and run it with the following command
The PoC confirms that the onlyBeneficiaryWithIsInherited
modifier suffers from a broken access control vulnerability.
The inherit()
function should ensure that only beneficiaries can call this function and that the ownership cannot be taken over by an attacker.
The removeBeneficiary
should also probably be reviewed to avoid leaving empty slots when removing beneficiaries.
Consider a scenario where an attacker exploits this vulnerability:
The contract manages cryptocurrency worth 2B$
Owner adds two beneficiaries, then removes one, leaving address(0) at index 0
After 90 days of inactivity, an attacker sets up a contract that can call from address(0) (possible through specific contract creation techniques)
Then, the attacker uses this to appoint himself as trustee, giving them control over asset revaluation
The attacker can manipulate asset values to gain benefits in various buyout scenarios
This scenario highlights the broken access control issue on this modifier.
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.