Express Security Review from Quantstamp
Saffron engaged Quantstamp to execute an express security review starting on November 18th which was completed on November 23rd.
The purpose of this was:
- To collect feedback on whether or not our code follows best practices
- To have a professional team of auditors review all of the Saffron production smart contracts for any errors or mistakes
- To begin an engagement with a high quality audit firm to lay the groundwork for eventually beginning a full audit to ensure the safety and reliability of the Saffron smart contract system
Result
I am happy to announce that the express security review was completed without any findings of high severity. There were also no findings that could lead to loss of user funds.
However, it should be noted that an express security review is not the same as a full audit, which would entail a longer and more detailed process involving thorough examination of the code with a higher degree of certainty.
Findings
There is a document outlining the findings discovered by the Quantstamp team hosted by a Quantstamp auditor on GitHub here. Below we examine each of the findings and explain their potential consequences and how they will be resolved.
Medium severity
The first and only medium severity finding relates to missing input validation. Missing input validation has a medium severity rating because a mistaken input sent to a contract by mistake (a typo, missing parameter, or parameters in the wrong order) could lead to catastrophic results and should be checked. This finding affects 11 of our mainnet production functions.
Fortunately, of these 11 affected functions, all of them are only accessible by governance. 9 of the functions are only called once: upon initial contract deployment. They all must be called before the epoch begins which is before users can deposit any funds. These functions are thoroughly tested in our deploy process. The remaining 2 functions are isolated in the team multisig contract which has no access to user funds whatsoever. The team has been instructed to double check their inputs to make sure they don’t accidentally burn their own funds.
Input validation will be fixed by examining the input of each governance function and validating it appropriately to ensure mistaken inputs have a low chance of causing an unintended or stuck contract state.
Low severity
The remaining findings are low or informational severity.
TEAM Allocations results from outdated comments in the team multisig that don’t indicate the intention of the newer code. This won’t lead to loss of team funds but will be updated to make the code more clear.
Privileged Roles and Ownership points out that the governance role can mint new tokens whenever they’d like, which is true. There is a Medium article covering EOA risk on the governance key from November 1st. The role of governance and its risks as a single EOA single key will be resolved when we announce and implement our multisig governance protocol with public well known keyholders.
Exchange Rate alerts us of a situation where a value emitted a log is scaled up too high, to 18 decimals, which is 10 more than cDAI’s native 8 decimals. This value is only used in an event log for precise measurement of DAI on the web3 app and will be changed to a scaled down value to match cDAI’s implementation.
Informational
Informational findings are less severe than low severity findings.
Unlocked Pragma describes a way to prevent unexpected behavior due to compiler version specification. We will implement this change to our pragma statements beginning in epoch 2.
Double Spend Exploit this finding has to do with the allowance function on most ERC20 tokens. It is possible for a malicious web3 application to exploit the behavior of ERC20 approvals to spend users’ funds in an unexpected way. Developers using Saffron’s smart contract system should be aware of this exploit and follow best practices for allowances to ensure web3 apps cannot steal user funds.
Clone & Own recommends using a framework for imported library files such that we aren’t modifying the existing library code and stay up-to-date with the latest and most secure smart contract libraries.
Contact
If you’ve still got questions about smart contract or web3 security at Saffron then please feel free to join the community and ask us anything:
Web3 app: https://saffron.finance
Telegram: https://t.me/saffronfinance
Discord: https://discord.gg/pDXpXKY
Twitter: https://twitter.com/saffronfinance_
Github: https://github.com/saffron-finance/saffron