Skip to main content

Rust Security Checklist

Release: Version 2.0

#ItemDescription
1Default VisibilityFunctions and state variables visibility should be set explicitly. Visibility levels should be specified consciously.
2Integer Overflow and UnderflowIf unchecked math is used all math operations should be safe from overflows and underflows.
3Outdated Compiler VersionIt is recommended to use a recent version of the Rust compiler.
5Unchecked Call Return ValueThe return value of a message call should be checked.
6Access Control & AuthorizationOwnership takeover should not be possible. All crucial functions should be protected. Users could not affect data that belongs to other users.
9Assert ViolationProperly functioning code should never reach a failing assert statement.
10Deprecated Rust FunctionsDeprecated built-in functions should never be used.
12DoS (Denial of Service)Execution of the code should never be blocked by a specific contract state unless it is required.
15Block values as a proxy for timeBlock numbers should not be used for time calculations.
16Signature Unique IdSigned messages should always have a unique id. A transaction hash should not be used as a unique id. Chain identifier should always be used.
17Shadowing State VariableState variables should not be shadowed.
18Weak Sources of RandomnessRandom values should never be generated from Chain Attributes or be predictable.
20Calls Only to Trusted AddressesAll external calls should be performed only to trusted addresses.
21Presence of unused variablesThe code should not contain unused variables if this is not justified by design.
23Assets integrityFunds are protected and cannot be withdrawn without proper permissions or be locked on the contract.
24User Balances manipulationContract owners or any other third party should not be able to access funds belonging to users.
25Data ConsistencySmart contract data should be consistent all over the data flow.
26Flashloan AttackWhen working with exchange rates they should be received from a trusted source and not be vulnerable to short-term rate changes that can be achieved by using flash loans. Oracles should be used.
27Token Supply manipulationTokens can be minted only according to rules specified in a whitepaper or any other documentation provided by the customer.
28Gas Limit and LoopsTransaction execution costs should not depend dramatically on the amount of data stored on the contract. There should not be any cases when execution fails due to the block gas limit.
29Style guide violationStyle guides and best practices should be followed.
30Requirements ComplianceThe code should be compliant with the requirements provided by the Customer.
31Environment ConsistencyThe project should contain a configured development environment with a comprehensive description of how to compile build and deploy the code.
32Secure Oracles UsageThe code should have the ability to pause specific data feeds that it relies on. This should be done to protect a contract from compromised oracles.
33Tests CoverageThe code should be covered with unit tests. Test coverage should be 100% with both negative and positive cases covered. Usage of contracts by multiple users should be tested.
34Stable ImportsThe code should not reference draft contracts that may be changed in the future.
35Unsafe Rust codeThe Rust type system does not check memory safety of unsafe Rust code. Thus if a smart contract contains any unsafe Rust code it may still suffer from memory corruptions such as buffer overflows use after frees uninitialized memory etc.