Aave
Starknet Bridge

This bridge lets Aave's static aTokens move between Ethereum and Starknet while they keep earning rewards. We reviewed the L2 contracts, including how rewards are tracked on Starknet and claimed on Ethereum.
report id
0054
category
Cross-chain & Bridges
language
Cairo
final report
September 12, 2022
lines of code
1380
Content

Download audit report

1

Executive Summary

This document presents the security review performed by Nethermind on the AAVE Protocol - L2 contracts written in Cairo Language. The project is composed of 4 contracts, 2 libraries and 2 interfaces and together are used to allow movement of staticATokens between the Ethereum L1 and the Starknet L2 while continuing to accrue rewards. Rewards on the Starknet L2 are accrued through rewAAVE tokens which are exchanged for rewards on Ethereum L1 via AAVE bridge contracts which sit on both layers and allow communication between them. As an overall assessment of the initial audit, we note that the project can benefit from better technical documentation detailing a) use cases, b) functional requirements, c) non-functional requirements, d) diagrams showing how interactions take place, and e) a more extensive test suite. The audit was carried out using manual inspection of the code base. The instructions for running the test suite are not accurate, and the output changed for each auditor. Most of the reported issues are related to missing validations, access control, and handling initialize contracts. During the re-audit, 25 (out of 29) issues were fixed and 4 issues have been indicated as false positive by the client since these actions are controlled by the Aave Governance. The audit team has decided to consider these 4 issues as acknowledged because the code must be defensive. As requested by the client, during the re-audit stage, the audit team made a careful second pass on the math supporting the protocol and no errors were detected. Finally, the client reports that they have added additional changes in four commits that are not related to the findings. These commits are listed below and have not been reviewed in the scope of this audit.

- Upgrade Cairo to version 0.9: 494a6891941b039421e02eefe0f71c2e0923c4c8

- Insert in-line comments for L2: a0df8f39c14182992c475f7ed187ea68cba333c6

- Update the README.md: 3cff841e91ba1d9e42e2d8e80d62870c2b0e115b

- Add parameter to event: 43d4dfb334dde15d9e581c04a17c8380504dc400

Audit assessment
Audit TypeSecurity Review
Initial ReportJun 22, 2022
Response from ClientAug 9, 2022
Final ReportSep 12, 2022
MethodsManual Review, Creation of Test Cases
Repositoryhttps://github.com/aave-starknet-project/aave-starknet-bridge/tree/main/contracts/l2
Commit Hash (Initial Audit)017e84df7c
Commit Hash (Re-audit)8302ab87ab
Documentation AssessmentMedium
Total findings
29
Fixed
25
Acknowledged
4
Mitigated
0
Unresolved
0

Findings by severity

  • Critical2
  • High0
  • Medium3
  • Low6
  • Informational5
  • Best Practices13

3

Summary of Issues

#FindingSeverityUpdate
1.1Missing event emissionsInfoFixed
1.2Getter functions with @external visibilityBest PracticesFixed
1.3Missing use of the Cairo boolean libraryBest PracticesFixed
1.4Remove unused importsBest PracticesFixed
1.5Use of unofficial OpenZeppelin contract packageBest PracticesFixed
2.1Missing safety features in proxy.change_proxy_admin(...)MediumAcknowledged
2.2Missing safety features in proxy.upgrade_implementation(...)MediumAcknowledged
2.3Missing input validation in proxy.change_proxy_admin(...)LowFixed
2.4Missing input validation in proxy.initialize_proxy(...)LowFixed
2.5Missing input validation in proxy.constructor(...)InfoFixed
2.6Unnecessary initialization logic in proxy.initialize_proxy(...)InfoFixed
3.1Comment does not accurately reflect logicBest PracticesFixed
3.2Constant name spelling errorBest PracticesFixed
3.3Inconsistent variable naming across functionsBest PracticesFixed
3.4Unused variable naming across functionsBest PracticesFixed
4.1Missing input validation in incentivized_erc20_set_l2_bridge(...)LowFixed
5.1Contract can be initialized multiple timesCriticalFixed
5.2Missing input validation in rewAAVE.initialize_rewAAVE(...)LowFixed
6.1Contract can be initialized multiple timesCriticalFixed
6.2Incorrect function orderingBest PracticesFixed
7.1Missing safety features in bridge.set_reward_token(...).MediumAcknowledged
7.2Missing Ethereum address bounds check in bridge.bridge_rewards(...)LowFixed
7.3Possible invalid state when tokens are set without ownershipLowFixed
7.4Inconsistent L1 to L2 message input validationInfoAcknowledged
7.5Storage variable l1_bridge cannot be changed once assigned.InfoFixed
7.6Constant with zero valueBest PracticesFixed
7.7Misleading function name bridge.only_l1_handler(...)Best PracticesFixed
7.8Typo in commentBest PracticesFixed
7.9Unnecessary alloc_locals in bridge.set_reward_token(...)Best PracticesFixed

4

System Overview

No system overview is included in this report.

5

Risk Rating Methodology

The risk rating methodology used by Nethermind Security follows the principles established by the OWASP Foundation. The severity of each finding is determined by two factors: Likelihood and Impact.

Likelihood measures how likely the finding is to be uncovered and exploited by an attacker. This factor will be one of the following values:

  1. High: the issue is trivial to exploit and has no specific conditions that need to be met;
  2. Medium: the issue is moderately complex and may have some conditions that need to be met;
  3. Low: the issue is very complex and requires very specific conditions to be met.

When defining the likelihood of a finding, other factors are also considered. These can include but are not limited to motive, opportunity, exploit accessibility, ease of discovery, and ease of exploit.

Impact is a measure of the damage that may be caused if an attacker exploits the finding. This factor will be one of the following values:

  1. High: the issue can cause significant damage, such as loss of funds or the protocol entering an unrecoverable state;
  2. Medium: the issue can cause moderate damage, such as impacts that only affect a small group of users or only a particular part of the protocol;
  3. Low: the issue can cause little to no damage, such as bugs that are easily recoverable or cause unexpected interactions that cause minor inconveniences.

When defining the impact of a finding, other factors are also considered. These can include but are not limited to data and state integrity, loss of availability, financial loss, and reputation damage. After defining the likelihood and impact of an issue, the severity is determined according to the table below.

Impact / LikelihoodLowMediumHigh
HighMediumHighCritical
MediumLowMediumHigh
LowInfo / Best PracticesLowMedium
UndeterminedUndeterminedUndeterminedUndetermined

To address issues that do not fit a High, Medium or Low severity, Nethermind Security also uses three more finding severities: Informational, Best Practices, and Undetermined.

  1. Informational findings do not pose any risk to the application, but they carry some information that the audit team intends to pass to the client formally;
  2. Best Practice findings are used when some piece of code does not conform with smart contract development best practices;
  3. Undetermined findings are used when we cannot predict the impact or likelihood of the issue.

6

Issues

6.1 General findings

6.1.1 Missing event emissions

FileFix commitTypeStatus
contracts/l2/*—InfoFixed

Contracts are missing event emissions for important changes to state, such as owner/admin address, token address changes and initialization. A list of functions with missing event emissions is shown below:

Recommendation

Consider emitting events in the functions presented above.

Resolution

Commit Hash with the fix of the issue: 59e280f6ab536aefd746fa66299ca38a1223a43b

6.1.2 Getter functions with @external visibility

FileFix commitTypeStatus
contracts/l2/*—Best PracticesFixed

Contracts contain functions that have a visibility decorator of @external even though they do not make any changes to state. There are several "getter" functions that have this issue.

Recommendation

Review the decorator of all functions in all contracts. Functions that do not change the state such as "getters" can have their visibility descriptor set to @view.

Resolution

Commit Hash with the fix of the issue: 02d838cc6b3de79db9399c749d52bc8995dd34fc.

6.1.3 Missing use of the Cairo boolean library

FileFix commitTypeStatus
contracts/l2/*—Best PracticesFixed

Contracts use felt values 1 and 0 to represent boolean values rather than constants TRUE and FALSE from the Cairo boolean library. Some examples of felt values being used as booleans are shown below:

Recommendation

To improve overall code readability and maintainability it is recommended to use the Cairo boolean library rather than direct 1 and 0 felt values.

Resolution

Commit Hash with the fix of the issue: ffb3ed4a3681fa29d2b497862e06537ff29fcffb.

6.1.4 Remove unused imports

FileFix commitTypeStatus
contracts/l2/*—Best PracticesFixed

Contracts contain unused imports which affect the readability and maintainability of the code. A non-exhaustive list of the unused imports is shown below:

Recommendation

Check all contract imports and remove imports that are unused to improve the overall readability and maintainability of the code.

Resolution

Commit Hash with the fix of the issue: b06d4f314c6ac718d3e4108f11dc1b8f711c4182

6.1.5 Use of unofficial OpenZeppelin contract package

FileFix commitTypeStatus
N/A—Best PracticesFixed

The OpenZeppelin Cairo library contracts are retrieved from the npm package @joriksch/oz-cairo which does not appear to be an official OpenZeppelin package. The official OpenZeppelin Cairo library contracts are found here.

Recommendation

Consider using the official OpenZeppelin Cairo contract library.

Resolution

Commit Hash with the fix of the issue: 80827082de76308005d657369a2d09b840b965e9.

6.2 contracts/l2/lib/proxy.cairo

6.2.1 Missing safety features in proxy.change_proxy_admin(...)

FileFix commitTypeStatus
contracts/l2/lib/proxy.cairo—MediumAcknowledged

There are no safety features in place in case an incorrect or malicious address is set in proxy.change_proxy_admin(...). This will allow unexpected behavior to occur as soon as the address is changed. The function is shown below:

Recommendation

Consider introducing safety features to mitigate a wrong address being set as the proxy admin. Some examples of safety features for address changes are *set then claim*, *set then confirm* and *timelock*. Consider checking new_admin for zero values.

Resolution

This is not an error but a design choice. Aave governance process handles proxy admin’s change. Commit Hash with the fix of the issue: 55ac73f0223176c45f09485508820a9f3bbe0a4b.

Update from Nethermind Security

We understand that this function is protected, only callable by the admin. However, as the code shows above, any value can be inserted as the proxy admin, including address(0x0). So, we consider this issue as acknowledged by the client.

6.2.2 Missing safety features in proxy.upgrade_implementation(...)

FileFix commitTypeStatus
contracts/l2/lib/proxy.cairo—MediumAcknowledged

There are no safety features in place should an incorrect or malicious address be set in proxy.upgrade_implementation(...). This will allow unexpected behavior to occur as soon as the address is changed. The function is shown below:

Recommendation

Consider introducing safety features to mitigate a wrong address being set as the implementation. Some examples of safety features for address changes are *set then confirm* and *timelock*.

Resolution

This is not an error but a design choice. Aave governance process handles implementation’s change. Commit Hash with the fix of the issue: 3d345380e011f892243728ecdeb3ad13aedddeca.

Update from Nethermind Security

We understand that this function is protected, only callable by the admin. However, as the code shows above, any measures have been taken to protect this code from a wrong input. So, we consider this issue as acknowledged by the client.

6.2.3 Missing input validation in proxy.change_proxy_admin(...)

FileFix commitTypeStatus
contracts/l2/lib/proxy.cairo—LowFixed

The function proxy.change_proxy_admin(...) does not check the argument new_admin for zero values. If the proxy admin were to be set to zero it will not be possible to recover the contract. The function is shown below:

Recommendation

Check the argument new_admin for zero values.

Resolution

Commit Hash with the fix of the issue: 55ac73f0223176c45f09485508820a9f3bbe0a4b.

6.2.4 Missing input validation in proxy.initialize_proxy(...)

FileFix commitTypeStatus
contracts/l2/lib/proxy.cairo—LowFixed

The function proxy.initialize_proxy(...) does not check the argument implementation_address for zero values. The function is shown below:

Recommendation

Check the argument implementation_address for zero values.

Resolution

Commit Hash with the fix of the issue: 9fa8d7c784c36c9586b75dc7f7e27521363d6a04.

6.2.5 Missing input validation in proxy.constructor(...)

FileFix commitTypeStatus
contracts/l2/lib/proxy.cairo—InfoFixed

The constructor does not check the argument proxy_admin for zero values. The constructor is shown below:

Recommendation

Check the argument proxy_admin for zero values.

Resolution

Commit Hash with the fix of the issue: cded7b6e3af94e6ab441a03e79cb3ae771931414.

6.2.6 Unnecessary initialization logic in proxy.initialize_proxy(...)

FileFix commitTypeStatus
contracts/l2/lib/proxy.cairo—InfoFixed

A proxy will typically keep track of whether it has been initialized to prevent calls to the __default__ or __l1_default__ before the proxy has been properly initialized. Given that calls to __default__ and __l1_default__ do not check the storage variable Proxy_initialized, the initialization logic is not necessary.

Recommendation

Consider replacing the functions proxy.initialize_proxy(...) and proxy.upgrade_implementation (which both set the implementation) with one function which has no initialization logic.

Resolution

We replaced both initialize_proxy and upgrade_implementation by set_implementation. Commit Hash with the fix of the issue: fb0ca2c5aad2d1ea0cc67cec7898378c0b73b030.

6.3 contracts/l2/lib/wad_ray_math.cairo

6.3.1 Comment does not accurately reflect logic

FileFix commitTypeStatus
contracts/l2/lib/wad_ray_math.cairo—Best PracticesFixed

There are two comments on L29 and L34 that state the return of their respective functions is of type Ray, where the functions actually return type Wad. A code snippet is shown below:

Recommendation

Ensure there is consistency between function logic and their respective comments.

Resolution

Commit Hash with the fix of the issue: ad0b4634116e1e4c778845aa8600b55dfe58245e.

6.3.2 Constant name spelling error

FileFix commitTypeStatus
contracts/l2/lib/wad_ray_math.cairo—Best PracticesFixed

The constant HALF_WAD_RAY_RATION is spelled incorrectly, it should be HALF_WAD_RAY_RATIO. This spelling error occurs on L30 and L53.

Recommendation

Change HALF_WAD_RAY_RATION to HALF_WAD_RAY_RATIO on L30 and L53.

Resolution

Commit Hash with the fix of the issue: 00846ab1e92c5a0360cc1032dd0f21226c05b90c.

6.3.3 Inconsistent variable naming across functions

FileFix commitTypeStatus
contracts/l2/lib/wad_ray_math.cairo—Best PracticesFixed

The functions wad_mul(...), wad_div(...), ray_mul(...) and ray_div(...) refer to the quotient returned by uint256_unsigned_div_rem(...) with either the variable name quo or quotient.

Recommendation

To improve the overall readability of the codebase it is recommended only to use one consistent variable name across all functions that use uint256_unsigned_div_rem(...).

Resolution

Commit Hash with the fix of the issue: 21c02030b302f6204204edca60525bf98e5cf41c.

6.3.4 Unused variable naming across functions

FileFix commitTypeStatus
contracts/l2/lib/wad_ray_math.cairo—Best PracticesFixed

The functions wad_mul(...) and ray_mul(...) both call uint256_unsigned_vid_rem(...) and store the remainder in a variable rem even though it is not used.

Recommendation

To improve code readability and maintainability it is recommended to not declare any variables that will not be used. Consider substituting rem with _ for unused return values.

Resolution

Commit Hash with the fix of the issue: f0806bc6f12dab8832615a38b547f0c6732a0e5b.

6.4 contracts/l2/tokens/incentivized_erc20.cairo

6.4.1 Missing input validation in incentivized_erc20_set_l2_bridge(...)

FileFix commitTypeStatus
contracts/l2/tokens/incentivized_erc20.cairo—LowFixed

The function incentivized_erc20.incentivized_erc20_set_l2_bridge(...) does not check the argument l2_bridge_ for zero values. If 0 is passed into this function, incentivized_erc20.incentivized_erc20_only_bridge will fail its assertion which prevents minting, burning and pushing the rewards index. The function is shown below:

Recommendation

Check the argument l2_bridge_ for zero values.

Resolution

Commit Hash with the fix of the issue: b737713256feadb3caee5674678ca61a81f6f635.

6.5 contracts/l2/tokens/rewAAVE.cairo

6.5.1 Contract can be initialized multiple times

FileFix commitTypeStatus
contracts/l2/tokens/rewAAVE.cairo—CriticalFixed

The function rewAAVE.initialize_rewAAVE(...) does not check if the contract is already initialized. Anybody can call the initialize function at any time allowing the token name, symbol, decimals and owner to change as well as minting amount tokens to recipient. These newly minted rewAAVE tokens can then be claimed at contracts/l2/bridge.cairo for AAVE tokens on L1. The function is shown below:

Recommendation

Ensure that rewAAVE.initialize_rewAAVE(...) can only be called once.

Resolution

Commit Hash with the fix of the issue: 0b6aa6b3636b06a1790e615e76a946c6717425f9.

6.5.2 Missing input validation in rewAAVE.initialize_rewAAVE(...)

FileFix commitTypeStatus
contracts/l2/tokens/rewAAVE.cairo—LowFixed

In the function rewAAVE.initialize_rewAAVE(...) the arguments name, symbol, decimals, initial_supply,recipient and owner can be set to zero. If the initialize function is called where owner is zero, the owner cannot be changed. The function is shown below:

Recommendation

For the arguments name, symbol, decimals, initial_supply and recipient consider adding checks for zero values. For the argument owner add a check for zero values.

Resolution

We allow initial_supply to be zero. Commit Hash with the fix of the issue: 964903789567e23ddd881a58a974e792c109e6f5.

6.6 contracts/l2/tokens/static_a_token.cairo

6.6.1 Contract can be initialized multiple times

FileFix commitTypeStatus
contracts/l2/tokens/static_a_token.cairo—CriticalFixed

The function static_a_token.initialize_static_a_token(...) checks if the contract has already been initialized by checking that the storage variables ERC20_name_, ERC20_symbol_ and ERC20_decimals_ are zero. If this function is called with the arguments name, symbol and decimals set to zero, the next time the initialize function is called the zero checks will pass. A malicious account can call this initialize function with zero values before the "official" initialize call by the Aave team. This allows the malicious account to mint any number of tokens (argument initial_supply) to any account of their choosing (argument recipient) and then exchange these tokens for their respective L1 token. When the official Aave initialize call executes with non-zero values for name, symbol and decimals the contract will properly initialize and this issue can no longer be exploited. The function is shown below:

Recommendation

Ensure that the function static_a_token.initialize_static_a_token(...) can only be called once. Check the arguments name, symbol and decimals for zero.

Resolution

Commit Hash with the fix of the issue: 6ba4633de872a640745c7dc2d1f6aa7508ad2995.

6.6.2 Incorrect function ordering

FileFix commitTypeStatus
contracts/l2/tokens/static_a_token.cairo—Best PracticesFixed

The function static_a_token.get_user_claimable_rewards(...) has the function decorator @view. However, according to the in-line documentation it is placed in the section for @external functions. The function is shown below:

Recommendation

Move the function to the "getters" section of the contract.

Resolution

Commit Hash with the fix of the issue: 6c389851eff52ed82ea6f4f33c7a76ef328d8292.

6.7 contracts/l2/bridge.cairo

6.7.1 Missing safety features in bridge.set_reward_token(...).

FileFix commitTypeStatus
contracts/l2/bridge.cairo—MediumAcknowledged

There are no safety features in place should an incorrect or malicious address be set to the reward token with bridge.set_reward_token(...). This will allow unexpected behavior to occur as soon as the address is changed. Because reward tokens can be claimed for L1 tokens through the bridge, any unexpected behavior related to the total supply of reward tokens (such as minting) could potentially lead to token being drained on the L1 bridge. The function is shown below:

Recommendation

Consider introducing safety features to mitigate a wrong address being set as the implementation. Some examples of safety features for address changes are *set then claim*, *set then confirm* and *timelock*. Consider checking the argument reward_token for zero values.

Resolution

This is not an error, but a design choice. Aave governance process handles reward token’s change. Commit Hash with the fix of the issue: c68cb40f75a29652bf9381f8338f651505e57080.

Update from Nethermind Security

We agree that the function is protected, so it is very likely that this finding will not represent an issue. However, the code must protect itself from external modules. Thus, we are marking this as acknowledged.

6.7.2 Missing Ethereum address bounds check in bridge.bridge_rewards(...)

FileFix commitTypeStatus
contracts/l2/bridge.cairo—LowFixed

The function bridge.bridge_rewards(...) communicates with L1 however the argument l1_recipient is not checked that it is within the bounds of 0 to ETH_ADDRESS_BOUND. Unaware users may lose funds by passing an invalid address into this function. The function is shown below:

Recommendation

Ensure that the argument l1_recipient is a valid Ethereum address.

Resolution

Commit Hash with the fix of the issue: be6ad9193381d4935193fefb20fd917fc604d1e6.

6.7.3 Possible invalid state when tokens are set without ownership

FileFix commitTypeStatus
contracts/l2/bridge.cairo—LowFixed

It is possible for the reward token and any static_a_token to be set in bridge.cairo without the bridge being the owner of the token. When the reward token is set without bridge ownership rewards cannot be bridged, deposits cannot be handled and rewards cannot be minted. When a static_a_token is set without bridge ownership withdrawals cannot be initiated, deposits cannot be handled, rewards cannot be minted and index updates will fail.

Recommendation

In reality, the ownership will most likely be transferred by the owner. However bridge.set_reward_token(...) and bridge.approve_bridge(...) should still assert that it has ownership over the token before it is used by the protocol as a safeguard storage to ensure the bridge contract does not enter an invalid state.

Resolution

Commit Hash with the fix of the issue: 35904e15b2e1ca53e897b2704a33761635167ed0.

6.7.4 Inconsistent L1 to L2 message input validation

FileFix commitTypeStatus
contracts/l2/bridge.cairo—InfoAcknowledged

It is not possible for the L1 bridge to deposit a given token where its associated L2 token is zero. The contract bridge.cairo also does this zero address check. The L2 bridge should operate correctly, independently, and prevent incorrect messaging input regardless of the L1 bridge’s implementation. However the same level of input sanitisation is not upheld for the other message parameters. For instance, block number 0 is not possible, yet there is no check for this in the @l1_handler function bridge.handle_deposit(...).

Recommendation

Consistency with input sanitation between L1 and L2 contracts should be practiced.

Resolution

Comments from the client: Adding too many checks increases costs for users who are using the bridge with valid parameters.

Update from Nethermind Security

The communication between the L1 and L2 layers must contain all the parameters and validations necessary for the requests to be matched and executed without any possibility of ambiguity. Otherwise, we may have unpredictable behaviors.

6.7.5 Storage variable l1_bridge cannot be changed once assigned.

FileFix commitTypeStatus
contracts/l2/bridge.cairo—InfoFixed

The storage variable l1_bridge cannot be changed after being assigned. This is beneficial in terms of security, but it also imposes a hard limitation in case the L1 bridge needs to be changed in the future. The function is shown below:

Recommendation

This is a trade-off between security and flexibility, the development team must discuss the best approach.

Resolution

Commit Hash with the fix of the issue: 28fe1e1e787344a39fee514cde60fd36bb4b1e6e.

6.7.6 Constant with zero value

FileFix commitTypeStatus
contracts/l2/bridge.cairo—Best PracticesFixed

The contract defines the constant WITHDRAW_MESSAGE set to zero. Since all storage and memory values are initially zero, this can potentially lead to unexpected behavior.

const WITHDRAW_MESSAGE = 0

Recommendation

Consider using a non-zero value for the constant WITHDRAW_MESSAGE.

Resolution

Commit Hash with the fix of the issue: 1e4034ecd1cea12e68dc4bbfc82a00b51547403c.

6.7.7 Misleading function name bridge.only_l1_handler(...)

FileFix commitTypeStatus
contracts/l2/bridge.cairo—Best PracticesFixed

The function only_l1_handler(...) checks if the sender is the L1 bridge. The function should therefore be renamed to only_l1_bridge(...).

Recommendation

Consider updating the function name.

Resolution

Commit Hash with the fix of the issue: 0e98552f1b54b69f950b6d4b7b42ca12da4978fa.

6.7.8 Typo in comment

FileFix commitTypeStatus
contracts/l2/bridge.cairo—Best PracticesFixed

There is a typo in the comment on L311.

Recommendation

Change "recieve" to "receive" on L311.

Resolution

Commit Hash with the fix of the issue: 3883f5e6745f534cc70bf0851508e3ac9bb617d5.

6.7.9 Unnecessary alloc_locals in bridge.set_reward_token(...)

FileFix commitTypeStatus
contracts/l2/bridge.cairo—Best PracticesFixed

The statement alloc_locals in the function bridge.set_reward_token(...) is not necessary. The function is shown below:

Recommendation

Consider removing alloc_locals.

Resolution

Commit Hash with the fix of the issue: d5f25510e112457b7d337b1b92610095274ceda1.

7

Documentation Evaluation

Software documentation refers to the written or visual information that describes the functionality, architecture, design, and implementation of software. It provides a comprehensive overview of the software system and helps users, developers, and stakeholders understand how the software works, how to use it, and how to maintain it. Software documentation can take different forms, such as user manuals, system manuals, technical specifications, requirements documents, design documents, and code comments. Software documentation is critical in software development, enabling effective communication between developers, testers, users, and other stakeholders. It helps to ensure that everyone involved in the development process has a shared understanding of the software system and its functionality. Moreover, software documentation can improve software maintenance by providing a clear and complete understanding of the software system, making it easier for developers to maintain, modify, and update the software over time. Smart contracts can use various types of software documentation. Some of the most common types include:

  • Technical whitepaper: A technical whitepaper is a comprehensive document describing the smart contract’s design and technical details. It includes information about the purpose of the contract, its architecture, its components, and how they interact with each other;
  • User manual: A user manual is a document that provides information about how to use the smart contract. It includes step-by-step instructions on how to perform various tasks and explains the different features and functionalities of the contract;
  • Code documentation: Code documentation is a document that provides details about the code of the smart contract. It includes information about the functions, variables, and classes used in the code, as well as explanations of how they work;
  • API documentation: API documentation is a document that provides information about the API (Application Programming Interface) of the smart contract. It includes details about the methods, parameters, and responses that can be used to interact with the contract;
  • Testing documentation: Testing documentation is a document that provides information about how the smart contract was tested. It includes details about the test cases that were used, the results of the tests, and any issues that were identified during testing;
  • Audit documentation: Audit documentation includes reports, notes, and other materials related to the security audit of the smart contract. This type of documentation is critical in ensuring that the smart contract is secure and free from vulnerabilities.

These types of documentation are essential for smart contract development and maintenance. They help ensure that the contract is properly designed, implemented, and tested, and they provide a reference for developers who need to modify or maintain the contract in the future.

8

Remarks & Test Suite

We recommend the following improvements be made to the documentation of this project:

  • Inline comments to describe each function (what it does, inputs, outputs);
  • Inline comments for lines of code that could benefit from an added description for further context;
  • Improve the architecture description of the system;
  • Create user facing documentation;
  • Formalize the functional requirements of the project, and the actions performed by each contract.

The technical documentation explaining the bridging system between L1 and L2 could be improved by taking inspiration from the original AAVE governance proposal and first Starknet update, where they explain the overall concept in a way that easy to understand.

We strongly recommend creating a complete documentation suite in order to maximize the output of external audits that will be performed in this code base. This will reduce the audit cost, and improve the audit efficacy. One of the most important goals of an audit is to match code against specification, which becomes impossible without a complete and well organized set of technical documents. Thus, despite the issues presented in this report, we highlight that the most important take away from this internal audit is the need to create high quality documentation able to present the quality of this project to the Web3 community.

During the first audit, the tests fail to run when using the provided commit hash. The environment variables used to setup the Ethereum L1 test chain cannot be accessed through the script testnet:l1 in package.json. Changes had to be made to the testnet:l1 script in order to have tests run (the new testnet:l1 script is provided below). Once these changes were made, the output of the tests were inconsistent where different team members would have a different number of failing tests. During the re-audit, the tests were executed

using a docker image. The output is presented below.

,! function.

,! function.

,! function.,! RewardsClaimed(address,address,address,uint256))

,! RewardsClaimed(address,address,address,uint256))

,! pc=0:91:

,! 20596759951375991457633380310041163031717389243715232810820868874136108825.,! pc=0:91:

,! 2144281840703669607578820663997386699993676463909798375948849229948128629884.

,! pc=0:91:

,! ['l2_bridge_'])

,! 1372230931195349345258302106925467725186894800524563684099591909164756476672.

,! pc=0:91:,! ['l2_bridge_'])

,! 1372230931195349345258302106925467725186894800524563684099591909164756476672.

,! pc=0:91:

,! ['l2_bridge_'])

,! 1372230931195349345258302106925467725186894800524563684099591909164756476672.

Test suite
52Tests passed0Failed

The complete test output is in the full report.

As auditors, we recommend that any changes or updates made to the audited codebase undergo a re-audit or security review to address potential vulnerabilities or risks introduced by the modifications. By conducting a re-audit or security review of the modified codebase, you can significantly enhance the overall security of your system and reduce the likelihood of exploitation. However, we do not possess the authority or right to impose obligations or restrictions on our clients regarding codebase updates, modifications, or subsequent audits. Accordingly, the decision to seek a re-audit or security review lies solely with you.

This report is based on the scope of materials and documentation provided by you to Nethermind in order that Nethermind could conduct the security review outlined in 1. Executive Summary and 2. Audited Files. The results set out in this report may not be complete nor inclusive of all vulnerabilities. Nethermind has provided the review and this report on an as-is, where-is, and as-available basis. You agree that your access and/or use, including but not limited to any associated services, products, protocols, platforms, content, and materials, will be at your sole risk. Blockchain technology remains under development and is subject to unknown risks and flaws. The review does not extend to the compiler layer, or any other areas beyond the programming language, or other programming aspects that could present security risks. This report does not indicate the endorsement of any particular project or team, nor guarantee its security. No third party should rely on this report in any way, including for the purpose of making any decisions to buy or sell a product, service or any other asset. To the fullest extent permitted by law, Nethermind disclaims any liability in connection with this report, its content, and any related services and products and your use thereof, including, without limitation, the implied warranties of merchantability, fitness for a particular purpose, and non-infringement. Nethermind does not warrant, endorse, guarantee, or assume responsibility for any product or service advertised or offered by a third party through the product, any open source or third-party software, code, libraries, materials, or information linked to, called by, referenced by or accessible through the report, its content, and the related services and products, any hyperlinked websites, any websites or mobile applications appearing on any advertising, and Nethermind will not be a party to or in any way be responsible for monitoring any transaction between you and any third-party providers of products or services. As with the purchase or use of a product or service through any medium or in any environment, you should use your best judgment and exercise caution where appropriate. FOR AVOIDANCE OF DOUBT, THE REPORT, ITS CONTENT, ACCESS, AND/OR USAGE THEREOF, INCLUDING ANY ASSOCIATED SERVICES OR MATERIALS, SHALL NOT BE CONSIDERED OR RELIED UPON AS ANY FORM OF FINANCIAL, INVESTMENT, TAX, LEGAL, REGULATORY, OR OTHER ADVICE.