Denial of Service by wrong BatchRequests.removeAddress logic
The removeAddress function used delete instead of properly removing an array element, leaving a zero address in the array. This could cause a denial of service because the contract would later try to call canBatchContracts on address(0).
Submitted by 0x1f8b, also found by rfa, berndartmueller, BowTiedWardens, csanuragjain, Lambda, neumo, and StErMi
Note: issues #283, 115, 82, 89, 61, and 241 were originally broken out as a separate medium issue. Approximately 1 week after judging and awarding were finalized, the judging team re-assessed that these should have all been grouped under H-03. Accordingly, the 6 warden names have been added as submitters above.
Impact
The BatchRequests.removeAddress logic is wrong and it will produce a denial of service.
Proof of Concept
Removing the element from the array is done using the delete statement, but this is not the proper way to remove an entry from an array, it will just set that position to address(0).
Append dummy data:
addAddress('0x0000000000000000000000000000000000000001')addAddress('0x0000000000000000000000000000000000000002')addAddress('0x0000000000000000000000000000000000000003')getAddresses()=>address[]: 0x0000000000000000000000000000000000000001,0x0000000000000000000000000000000000000002,0x0000000000000000000000000000000000000003
Remove address:
removeAddress(0x0000000000000000000000000000000000000002)(or0x0000000000000000000000000000000000000003)getAddresses()=>address[]: 0x0000000000000000000000000000000000000001,0x0000000000000000000000000000000000000000,0x0000000000000000000000000000000000000003
Service is denied because it will try to call canBatchContracts to address(0).
Recommended Mitigation Steps
- To remove an entry in an array you have to use
popand move the last element to the removed entry position.
0xean (Yieldy) confirmed and resolved
Agree this is high, if the team (owner) didn’t know this they could cause some issues for sure.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
How it worked
Impact
The contract could suffer a denial of service because it would attempt to call canBatchContracts on address(0).
What the attacker needed
Ability to call addAddress and removeAddress
The fix
The removeAddress function should use pop and move the last element into the removed position instead of using delete.
How it was found
- Add three addresses to the batch list.
- Call getAddresses to confirm the three addresses are present.
- Remove the second or third address.
- Call getAddresses again and observe a zero address in place of the removed one.
- The service is denied because it will try to call canBatchContracts on address(0).
Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
A smart contract keeps a list of addresses. The function meant to remove one address only blanks it out, leaving a placeholder zero address in the list. Later, when the contract tries to use every address in the list, it hits that placeholder and fails, so the service stops working.
What is DoS?
A request that exhausts resources or crashes a component. Many programs forbid testing it; reports usually show it from code, not by attacking.