Open code423n4 opened 1 year ago
Initialize
can only be called once due to the initializer
modifier and as per the docs it will be called with max 12 (6+6) addresses.
Invalid assumption.
0xSorryNotSorry marked the issue as low quality report
0xean marked the issue as unsatisfactory: Invalid
Hi @0xean, could you clarify on why this issue is considered invalid?
I think the lookout has confused the number of security councils with the number of security council members (6+6 as per the docs). Security councils are contracts on many different chains that are used by security council members to execute governing actions.
Given that the number of security councils could be very large (as seen from the maximum limit here) I think that this is a risk worth highlighting to the sponsor.
Thanks!
Happy to mark this as QA.
0xean changed the severity to QA (Quality Assurance)
0xean marked the issue as grade-a
Lines of code
https://github.com/ArbitrumFoundation/governance/blob/c18de53820c505fc459f766c1b224810eaeaabc5/src/security-council-mgmt/SecurityCouncilManager.sol#L118-L120
Vulnerability details
Bug Description
In
SecurityCouncilManager.sol
, theintialize()
function calls_addSecurityCouncil()
in a loop to add security councils individually:SecurityCouncilManager.sol#L118-L120
_addSecurityCouncil()
performs checks, which includes ensuring the new security council (_securityCouncilData
) isn't already added, before adding it to thesecurityCouncils
array:SecurityCouncilManager.sol#L251-L262
However, as the duplicate check loops over all elements in the
securityCouncils
storage array,_addSecurityCouncil()
will consume a lot of gas whenever it is called.As it is called repeatedly in
intialize()
, there is a signficant chance thatinitialize()
might consume too much gas when called, making it revert due to an out-of-gas error.The contract declares a maximum limit of 500 security councils to mitigate this:
SecurityCouncilManager.sol#L67
However, this is insufficient as calling
initialize()
with 500 security councils will still read from storage 125,250 times, which will still consume a huge amount of gas.Impact
If
SecurityCouncilManager
is initialized with a large number of security councils, theinitialize()
function might not be executable due to consuming too much gas.Recommended Mitigation
Consider performing all checks in
initialize()
and pushing to thesecurityCouncils
array directly, instead of calling_addSecurityCouncil
. This might reduce gas consumption significantly as the iteration is performed over the array stored in memory, thereby avoiding reading from storage.Assessed type
DoS