Unbounded for loop in MembershipERC1155::burnBatchMultiple
function can cause DOS.
The MembershipERC1155::burnBatchMultiple function:
We can see from the function that, there is unbounded for
loop
Inside which there is another for loop hence the loop runs for j * 7
times for every value of j. As froms.length
increases total number of runs would drastically increase.
I have used foundry for writing the test, it is being installed using forge init --force
we use the --force
flag because it is a non-empty directory. The following test file MembershipERC1155Test
includes the setup and the test function.
When both the tests are ran in the test file we get the following outputs
testFailBurnBatchUnsafe
using forge test --mt testFailBurnBatchUnsafe -vvv
testBurnBatchSafe
using forge test --mt testBurnBatchSafe -vvv
In the test file there is two test to show what can be a approximate safe batch size and unsafe batch size. The test result clearly show that the unsafe batch size i.e. 100 here exceeds the 30mil block gas limit by a big margin.
But when we use a smaller batch size then the gas usage stays well within the block gas limit.
If batch size is large enough it will lead to DoS.
Impact : Medium , Likelihood : High (as it can occur with a batch size of just 100), but keeping severity as Medium as this is a admin controlled function.
Manual review
Have batch limits for example 20 as shown in the test. If large batches of tokens need to be burned, break large batches in smaller batches which would remain in the safe block gas limit.
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.