Unbounded Loop in revokeSigningRole Can Cause DoS
The revokeSigningRole function contains an unbounded loop that iterates through all signers to find the target address. While currently limited to 5 signers, if the MAX_SIGNER_COUNT were increased or if the loop fails to find the signer due to a bug, this could consume excessive gas. Additionally, the pattern of using type(uint256).max as a sentinel value without checking if the signer was actually found could lead to unexpected behavior.
Likelihood:
The revokeSigningRole function contains an unbounded loop that iterates through all signers to find the target address. While currently limited to 5 signers, if the MAX_SIGNER_COUNT were increased or if the loop fails to find the signer due to a bug, this could consume excessive gas. Additionally, the pattern of using type(uint256).max as a sentinel value without checking if the signer was actually found could lead to unexpected behavior.
Impact:
If the signer is not found in the array (due to state inconsistency), the function will proceed with indexToRemove = type(uint256).max, potentially causing an out-of-bounds array access or unexpected behavior. Gas costs increase linearly with signer count.
The "Swap and Pop" Logic
The code uses a gas-efficient method to remove an address from the s_signers array. Instead of shifting every item, it finds the target's position and replaces it with the last item in the list.
Key Components:
• The Search: It loops through the array to find the index of the address provided.
• The Swap: It overwrites the target address with the address currently sitting at the end of the array.
• The Flaw: If the address isn't found, indexToRemove stays at the maximum possible value. Because there is no "if not found, revert" check, the function might proceed to delete the last signer in the list by mistake.
By adding the require statement, you ensure the function only proceeds if the address is actually in the list.
Why this matters:
• Prevents Wrongful Deletion: Without this check, the function would skip the "swap" logic but still decrease the signer count, accidentally removing the last person in the list.
• State Integrity: It ensures your s_signerCount stays accurate and synced with the actual addresses in storage.
• Clear Feedback: It provides an explicit error message ("Signer not found") if an admin tries to remove someone who isn't a signer.
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.
The contest is complete and the rewards are being distributed.