Security Audit
May 25th, 2023
Version 1.0.0
Presented by 0xMacro
This document includes the results of the security audit for Glo Dollar's smart contract code as found in the section titled ‘Source Code’. The security audit was performed by the Macro security team from May 15, 2023 to May 19, 2023.
The purpose of this audit is to review the source code of certain Glo Dollar Solidity contracts, and provide feedback on the design, architecture, and quality of the source code with an emphasis on validating the correctness and security of the software in its entirety.
Disclaimer: While Macro’s review is comprehensive and has surfaced some changes that should be made to the source code, this audit should not solely be relied upon for security, as no single audit is guaranteed to catch all possible bugs.
The following is an aggregation of issues found by the Macro Audit team:
Severity | Count | Acknowledged | Won't Do | Addressed |
---|---|---|---|---|
Low | 1 | - | - | 1 |
Code Quality | 2 | 1 | - | 1 |
Gas Optimization | 1 | 1 | - | - |
Glo Dollar was quick to respond to these issues.
Our understanding of the specification was based on the following sources:
Notable features of the contract include minting and burning of GLO tokens, pausability, denylisting, and upgradeability. The contract implements a roles-based access control with dedicated roles for each of the aforementioned functionalities. The roles include:
DEFAULT_ADMIN_ROLE
- can grant roles;PAUSER_ROLE
- can pause and unpause the contract;MINTER_ROLE
- can mint and burn GLO tokens;DENYLISTER_ROLE
- can add and remove from denylist;UPGRADER_ROLE
- can authorise an upgrade.It is worth noting that each role can be granted to any address which introduces a centralization risk whereby the user of the contract has to trust that all the roles will act faithfully.
The following source code was reviewed during the audit:
678ee06750bd91939a0bc746641c435307dfc13a
b5d93f59d7fc533b6a8d422dbe4e1237be0cd1de
. This version was deployed to Mainnet and Polygon on June 6 2023 to 0xf8dbe4f52b7d4fe90cd360aa4f49b7a66783c56f
.
Specifically, we audited the following contracts within this repository:
Source Code | SHA256 |
---|---|
USDGLO_V3.sol |
|
ERC20PermitUpgradeable_V3.sol |
|
ERC20Upgradeable_V2.sol |
|
Note: This document contains an audit solely of the Solidity contracts listed above. Specifically, the audit pertains only to the contracts themselves, and does not pertain to any other programs or scripts, including deployment scripts.
Click on an issue to jump to it, or scroll down to see them all.
We quantify issues in three parts:
This third part – the severity level – is a summary of how much consideration the client should give to fixing the issue. We assign severity according to the table of guidelines below:
Severity | Description |
---|---|
(C-x) Critical |
We recommend the client must fix the issue, no matter what, because not fixing would mean significant funds/assets WILL be lost. |
(H-x) High |
We recommend the client must address the issue, no matter what, because not fixing would be very bad, or some funds/assets will be lost, or the code’s behavior is against the provided spec. |
(M-x) Medium |
We recommend the client to seriously consider fixing the issue, as the implications of not fixing the issue are severe enough to impact the project significantly, albiet not in an existential manner. |
(L-x) Low |
The risk is small, unlikely, or may not relevant to the project in a meaningful way. Whether or not the project wants to develop a fix is up to the goals and needs of the project. |
(Q-x) Code Quality |
The issue identified does not pose any obvious risk, but fixing could improve overall code quality, on-chain composability, developer ergonomics, or even certain aspects of protocol design. |
(I-x) Informational |
Warnings and things to keep in mind when operating the protocol. No immediate action required. |
(G-x) Gas Optimizations |
The presented optimization suggestion would save an amount of gas significant enough, in our opinion, to be worth the development cost of implementing it. |
According to the documentation, approve
/increaseAllowance
/decreaseAllowance
are supposed to revert when the contract is paused, or a given address is denylisted.
This is currently not the case, and thus any address being denylisted can still call one of those functions.
This behavior doesn’t impose any security risks, as the required checks to not allow transfers from and to any denylisted address is checked in the _transfer function.
Consider adding require checks to revert on approve
/increaseAllowance
/decreaseAllowance
when contract is paused or address is denylisted.
Alternatively, update documentation accordingly.
I'll update the docs. We made the decision not to revert approves on denylists because the transfers check them anyway.
The project uses OpenZeppelin version 4.7.2 for contracts-upgradeable
. There are known vulnerabilities in older version used (see here).
For example ECDSAUpgradeable.sol used in ERC20PermitUpgradable_V3.sol is susceptible to signature malleability. See details here.
Contracts that are affected by this vulnerability are those that implement replay protection by marking the signature itself as used instead of any nonce or unique id.
Thus, with current code, there is no immediate security risk imposed as it uses nonces to prevent replay attacks. However, it is recommended to upgrade to latest stable OpenZeppelin version.
Acknowledged - but we prefer to postpone making these changes until our next smart contract upgrade as the issue doesn't introduce any risk, whilst making the changes would require us to rerun checks & delay our preferred timeline.
The documentation states the following:
The internal
_mint
method checks_requireBalanceIsNotDenylisted
on both the minters balance and theto
address balance.
The above statement is not entirely correct as the internal _mint
function only checks on the to
address. It is the external mint
function in USDGLO_V3.sol that also checks on the minter’s address via whenNotDenylisted(_msgSender())
.
The documentation mentions the following for the DEFAULT_ADMIN_ROLE
:
This role will be by default assigned to the contract deployer address.
However, it is not the deployer’s address that will be assigned to the role but instead the admin
address being passed in the initialize
function.
Consider updating the documentation to correctly reflect behavior.
mint
and burn
USDGLO_V2’s mint
and burn
functions emit an event Mint(…)
and Burn(…)
respectively. In addition, the underlying _transfer
function also emits an event Transfer(…)
, resulting in 2 events being emitted for every mint/burn.
In order to reduce gas costs, consider to remove the additional Mint(…)
and Burn(…)
events.
Acknowledged - but we prefer to postpone making these changes until our next smart contract upgrade as the issue doesn't introduce any risk, whilst making the changes would require us to rerun checks & delay our preferred timeline.
Macro makes no warranties, either express, implied, statutory, or otherwise, with respect to the services or deliverables provided in this report, and Macro specifically disclaims all implied warranties of merchantability, fitness for a particular purpose, noninfringement and those arising from a course of dealing, usage or trade with respect thereto, and all such warranties are hereby excluded to the fullest extent permitted by law.
Macro will not be liable for any lost profits, business, contracts, revenue, goodwill, production, anticipated savings, loss of data, or costs of procurement of substitute goods or services or for any claim or demand by any other party. In no event will Macro be liable for consequential, incidental, special, indirect, or exemplary damages arising out of this agreement or any work statement, however caused and (to the fullest extent permitted by law) under any theory of liability (including negligence), even if Macro has been advised of the possibility of such damages.
The scope of this report and review is limited to a review of only the code presented by the Glo Dollar team and only the source code Macro notes as being within the scope of Macro’s review within this report. This report does not include an audit of the deployment scripts used to deploy the Solidity contracts in the repository corresponding to this audit. Specifically, for the avoidance of doubt, this report does not constitute investment advice, is not intended to be relied upon as investment advice, is not an endorsement of this project or team, and it is not a guarantee as to the absolute security of the project. In this report you may through hypertext or other computer links, gain access to websites operated by persons other than Macro. Such hyperlinks are provided for your reference and convenience only, and are the exclusive responsibility of such websites’ owners. You agree that Macro is not responsible for the content or operation of such websites, and that Macro shall have no liability to your or any other person or entity for the use of third party websites. Macro assumes no responsibility for the use of third party software and shall have no liability whatsoever to any person or entity for the accuracy or completeness of any outcome generated by such software.