File Location: https://github.com/Cyfrin/2024-07-biconomy/blob/d2adadc0f3105eb789329eb3c958472638692a2d/contracts/factory/RegistryFactory.sol#L57-L73
The 'RegistryFactory' contract relies on a single externally owned account (EOA) as the sole owner to perform critical functions, thereby creating a risk of centralization. This single failure can cause the contract to be compromised if the owner's private key is stolen or otherwise inaccessible.
The original implementation of the 'RegistryFactory' contract includes important functions such as 'addAttester', 'removeAttester', and 'setThreshold', all protected by the 'onlyOwner' modifier. This design requires a single EOA to perform these sensitive operations, creating significant centralization risks. If the owner's private key is lost or compromised, the entire contract can become vulnerable.
Single Point of Failure
Increased Risk of Exploitation
Operational Risks
Inspection manual
Solidity
Foundry
To overcome this, you can change the contract implementation from using 'onlyOwner' to using a multi-signature wallet or a role-based authorization model.
Code snippet:
L57-L73
Fixed code:
Explanation:
‘safeAddress’: The address of Gnosis Safe who will act as owner.
Modifier ‘onlySafe’: Ensures that only Gnosis Safe can call certain functions.
Constructor: Initializes the Gnosis Safe address when the contract is created.
Code when testing using Foundry:
Foundry output:
Ran 6 tests for test/RegistryFactory.t.sol:RegistryFactoryTest
[PASS] testAddAttester() (gas: 60685)
[PASS] testAddAttesterNotAuthorized() (gas: 12764)
[PASS] testRemoveAttester() (gas: 46728)
[PASS] testRemoveAttesterNotAuthorized() (gas: 12861)
[PASS] testSetThreshold() (gas: 36050)
[PASS] testSetThresholdNotAuthorized() (gas: 10717)
Suite result: ok. 6 passed; 0 failed; 0 skipped; finished in 56.58ms (71.56ms CPU time)
Ran 1 test suite in 121.86ms (56.58ms CPU time): 6 tests passed, 0 failed, 0 skipped (6 total tests)
Invalid [known issue [Medium-1]](https://github.com/Cyfrin/2024-07-biconomy/issues/1)
Invalid [known issue [Medium-1]](https://github.com/Cyfrin/2024-07-biconomy/issues/1)
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.