If one of beneficieries addresses is a malitious smart contract, then this will couse Denial-of-Service of function withdrawInheritedFunds(). This will make that function impossible to use.
Function withdrawInheritedFunds is vulnerable to DoS attack
If one address in beneficiaries[] array point to malitious smart contract like that below:
It will couse function withdrawInheritedFunds() to revert every time its called
Foundry test:
Foundry test's result
[FAIL: revert: something went wrong] test_DoS() (gas: 416303)
Traces:
[416303] InheritanceManagerTest::test_DoS()
├─ [0] VM::addr(````) [staticcall]
│ └─ ← [Return] user2: [0x537C8f3d3E18dF5517a58B3fB9D9143697996802]
├─ [0] VM::label(user2: [0x537C8f3d3E18dF5517a58B3fB9D9143697996802], "user2")
│ └─ ← [Return]
├─ [0] VM::addr(````) [staticcall]
│ └─ ← [Return] user3: [0xc0A55e2205B289a967823662B841Bd67Aa362Aec]
├─ [0] VM::label(user3: [0xc0A55e2205B289a967823662B841Bd67Aa362Aec], "user3")
│ └─ ← [Return]
├─ [210147] → new AttackContract@0xF62849F9A0B5Bf2913b396098F7c7019b51A820a
│ └─ ← [Return] 937 bytes of code
├─ [0] VM::startPrank(owner: [0x7c8999dC9a822c1f0Df42023113EDB4FDd543266])
│ └─ ← [Return]
├─ [69726] InheritanceManager::addBeneficiery(AttackContract: [0xF62849F9A0B5Bf2913b396098F7c7019b51A820a])
│ └─ ← [Stop]
├─ [23826] InheritanceManager::addBeneficiery(user2: [0x537C8f3d3E18dF5517a58B3fB9D9143697996802])
│ └─ ← [Stop]
├─ [23826] InheritanceManager::addBeneficiery(user3: [0xc0A55e2205B289a967823662B841Bd67Aa362Aec])
│ └─ ← [Stop]
├─ [0] VM::stopPrank()
│ └─ ← [Return]
├─ [0] VM::warp(1)
│ └─ ← [Return]
├─ [0] VM::deal(InheritanceManager: [0x88F59F8826af5e695B13cA934d6c7999875A9EeA], 20000000000000000000 [2e19])
│ └─ ← [Return]
├─ [0] VM::warp(7776001 [7.776e6])
│ └─ ← [Return]
├─ [0] VM::startPrank(user1: [0x29E3b139f4393aDda86303fcdAa35F60Bb7092bF])
│ └─ ← [Return]
├─ [22791] InheritanceManager::inherit()
│ └─ ← [Stop]
├─ [10494] InheritanceManager::withdrawInheritedFunds(0x0000000000000000000000000000000000000000)
│ ├─ [1559] AttackContract::fallback{value: 6666666666666666666}()
│ │ ├─ [585] InheritanceManager::withdrawInheritedFunds(0x0000000000000000000000000000000000000000)
│ │ │ └─ ← [Revert] EvmError: Revert
│ │ └─ ← [Revert] EvmError: Revert
│ └─ ← [Revert] revert: something went wrong
└─ ← [Revert] revert: something went wrong
Lock of funds by making function withdrawInheritedFunds() reverting every time it's called.
Foundry
Implement error handling within the loop, allowing the loop to continue executing even if one iteration fails. Solidity’s try-catch
mechanism can be useful here.
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.