Starknet ID
Auto Renew

Starknet ID gives users domain names on Starknet. We reviewed the contract that renews those domains automatically so owners don't lose them.
report id
0135
category
Identity & Cryptography
language
Cairo
final report
October 4, 2023
lines of code
245
Content

Download audit report

1

Executive Summary

This document presents the security review performed by Nethermind on the Starknet ID Auto Renew Contract. The reviewed contracts implement an automatic renewal feature for domain ownership, ensuring a seamless and continuous user experience.

The audited code consists of 245 lines of Cairo code. The audit was performed using (a) manual analysis of the codebase, (b) simulation of the smart contract, and (c) creation of test cases.

Audit assessment
Audit TypeSecurity Review
Initial ReportAug. 24, 2023
Response from ClientSep 30, 2023
Final ReportOct 4, 2023
MethodsManual Review, Automated Analysis
RepositoryStarknet ID
Commit Hash (Audit)71f58bca69
Commit Hash (Reaudit)e1830508e0 5284970d3d 8bc436b8a8 1ffcf57289 9ef5b7cd44
Documentation AssessmentHigh
Test Suite AssessmentHigh
Total findings
10
Fixed
8
Acknowledged
2
Mitigated
0
Unresolved
0

Findings by severity

  • Critical0
  • High1
  • Medium0
  • Low3
  • Informational1
  • Best Practices5

2

Audited Files

#ContractLoCCommentsRatioBlankTotal
1src/lib.cairo2150.0%03
2src/auto_renewal.cairo2439940.7%43385
Total24510040.8%43388

4

System Overview

The audit covers the AutoRenewal smart contract. This contract manages domain renewals for the Starknet.id system. The contract emits the following events.

#[event]
#[derive(Drop, starknet::Event)]
enum Event {
EnabledRenewal: EnabledRenewal,
DisabledRenewal: DisabledRenewal,
DomainRenewed: DomainRenewed,
}

#[derive(Drop, starknet::Event)]
struct EnabledRenewal {
#[key]
domain: felt252,
renewer: ContractAddress,
limit_price: u256,
meta_hash: felt252,
}

#[derive(Drop, starknet::Event)]
struct DisabledRenewal {
#[key]
domain: felt252,
renewer: ContractAddress,
limit_price: u256,
}

#[derive(Drop, starknet::Event)]
struct DomainRenewed {
#[key]
domain: felt252,
renewer: ContractAddress,
days: felt252,
limit_price: u256,
timestamp: u64,
}

The contract uses the following imports.

use starknet::ContractAddress;
use starknet::{get_caller_address, get_contract_address, get_block_timestamp};
use starknet::contract_address::ContractAddressZeroable;
use traits::{TryInto, Into};
use option::OptionTrait;
use array::ArrayTrait;
use integer::u64_try_from_felt252;
use debug::PrintTrait;
use openzeppelin::token::erc20::interface::{IERC20CamelDispatcher, IERC20CamelDispatcherTrait};
use naming::interface::naming::{INamingDispatcher, INamingDispatcherTrait};

And the following storage variables.

#[storage]
struct Storage {
naming_contract: ContractAddress,
erc20_contract: ContractAddress,
tax_contract: ContractAddress,
admin: ContractAddress,
whitelisted_renewer: ContractAddress,
can_renew: bool,
// (renewer, domain, limit_price) -> 1 or 0
_is_renewing: LegacyMap::<(ContractAddress, felt252, u256), bool>,
// (renewer, domain) -> timestamp
last_renewal: LegacyMap::<(ContractAddress, felt252), u64>,
}

The contract has the following getters.

fn is_renewing(
self: @ContractState, domain: felt252, renewer: ContractAddress, limit_price: u256
) -> bool {
self._is_renewing.read((renewer, domain, limit_price))
}
fn get_contracts(
self: @ContractState
) -> (ContractAddress, ContractAddress, ContractAddress) {
(self.naming_contract.read(), self.erc20_contract.read(), self.tax_contract.read())
}

The function enable_renewals(...) allows the caller to renew a given domain given a limit_price. The function is shown below.

fn enable_renewals(ref self: ContractState, domain: felt252, limit_price: u256, meta_hash: felt252)
{
let caller = get_caller_address();
self._is_renewing.write((caller, domain, limit_price), true);
// we erase the previous renewal date
self.last_renewal.write((caller, domain), 0);
self.emit( Event::EnabledRenewal( EnabledRenewal { domain, renewer: caller, limit_price, meta_hash }))
}

The caller can also disable renewals for a given domain and limit_price by calling the function below.

fn disable_renewals(ref self: ContractState, domain: felt252, limit_price: u256) {
let caller = get_caller_address();
self._is_renewing.write((caller, domain, limit_price), false);

self.emit( Event::DisabledRenewal( DisabledRenewal { domain, renewer: caller, limit_price, } ))
}

Function renew(...): Only the whitelisted_renewer can call this function for domain renewals. The function applies several checks to evaluate if the current contract is not disabled, the domain can be renewed, the domain is not renewed yet in the current year, and the domain expires within a month. The function also updates when the last renewal was applied to avoid charging more than once a year. Then, the flow capacity (limit price amount) is taken from the user account and transferred to the contract. The tax price is transferred to the tax contract, and the expiration date is renewed for the next year.

fn renew( ref self: ContractState, root_domain: felt252, renewer: ContractAddress,
limit_price: u256, tax_price: u256, metadata: felt252,
) {
assert(self.can_renew.read(), 'Contract is disabled');
assert( get_caller_address() == self.whitelisted_renewer.read(), 'You are not whitelisted' );
self._renew(root_domain, renewer, limit_price, tax_price, metadata);
}
fn _renew( ref self: ContractState, root_domain: felt252, renewer: ContractAddress,
limit_price: u256, tax_price: u256, metadata: felt252,
) {
let naming = self.naming_contract.read();
let can_renew = self._is_renewing.read((renewer, root_domain, limit_price));

assert(can_renew, 'Renewal not toggled for domain');

// Check domain has not been renew yet this year
let block_timestamp = get_block_timestamp();
let last_renewed = self.last_renewal.read((renewer, root_domain));

// 364 because we keep adding one day margin to the existing month,
// if we take more than a day to renew, the margin will shrink.
assert(block_timestamp - last_renewed > 86400_u64 * 364_u64, 'Domain already renewed');

// Check domain is set to expire within a month
let expiry: u64 = INamingDispatcher { contract_address: naming }
.domain_to_data(array![root_domain].span())
.expiry;
assert(expiry <= block_timestamp + (86400_u64 * 30_u64), 'Domain not set to expire');
// Renew domain
// last_renewal is updated before external contract calls to prevent reentrancy attacks
// if the naming contract was compromised
self.last_renewal.write((renewer, root_domain), block_timestamp);
// events are sent before calls to other contracts to prevent a reordering via reentrancy attack
self.emit( Event::DomainRenewed( DomainRenewed { domain: root_domain, renewed, days: 365, limit_price, timestamp: block_timestamp } ) );
let contract = get_contract_address();
let erc20 = self.erc20_contract.read();
let _tax_contract = self.tax_contract.read();

// Transfer limit_price (including tax), will be canceled if the tx fails
IERC20CamelDispatcher { contract_address: erc20 }.transferFrom(renewer, contract, limit_price);
// transfer tax price to the tax contract address
IERC20CamelDispatcher { contract_address: erc20 }.transfer(_tax_contract, tax_price);
//Spend the remaining money to renew the domain
//If something remains after this, it can be considered as lost by the user,
//We keep the ability to claim it back but can't guarantee we will do it
INamingDispatcher { contract_address: naming }.renew(root_domain, 365_u16, ContractAddressZeroable::zero(), 0, metadata);
}

The function batch_renew(...): Only the whitelisted_renewer can call this function for batch domain renewals. The function applies the same checks described in renew(...). The difference relies only on the number of domains to be renewed.

fn batch_renew( ref self: ContractState, domain: array::Span::<felt252>, renewer: array::Span::<starknet::ContractAddress>, limit_price: array::Span::<u256>, tax_price: array::Span::<u256>, metadata: array::Span::<felt252>,
) {
assert(self.can_renew.read(), 'Contract is disabled');
assert(
get_caller_address() == self.whitelisted_renewer.read(), 'You are not whitelisted'
);
assert(domain.len() == renewer.len(), 'Domain & renewer mismatch len');
assert(domain.len() == limit_price.len(), 'Domain & price mismatch len');

let mut domain = domain;
let mut renewer = renewer;
let mut limit_price = limit_price;
let mut tax_price = tax_price;
let mut metadata = metadata;

loop {
if domain.len() == 0 {
break;
}
let _domain = domain.pop_front().expect('pop_front error');
let _renewer = renewer.pop_front().expect('pop_front error');
let _limit_price = limit_price.pop_front().expect('pop_front error');
let _tax_price = tax_price.pop_front().expect('pop_front error');
let _metadata = metadata.pop_front().expect('pop_front error');
self._renew(*_domain, *_renewer, *_limit_price, *_tax_price, *_metadata);
}
}

The function claim(...): Only the admin can call this function to withdraw funds deposited in the contract.

fn claim(ref self: ContractState, amount: u256) {
assert(get_caller_address() == self.admin.read(), 'Caller not admin');
let erc20 = self.erc20_contract.read();
IERC20CamelDispatcher { contract_address: erc20 }.transfer(get_caller_address(), amount);
}

The contract also has the following update functions.

// Admin function to update admin address and the tax contract address
fn update_admin(ref self: ContractState, new_admin: ContractAddress,) {
assert(get_caller_address() == self.admin.read(), 'Caller not admin');
self.admin.write(new_admin);
}

fn update_tax_contract(ref self: ContractState, new_addr: ContractAddress,) {
assert(get_caller_address() == self.admin.read(), 'Caller not admin');
self.admin.write(new_addr);
}

fn update_whitelisted_renewer(ref self: ContractState, whitelisted_renewer: starknet::ContractAddress) {
assert(get_caller_address() == self.admin.read(), 'Caller not admin');
self.whitelisted_renewer.write(whitelisted_renewer);
}

fn toggle_off(ref self: ContractState) {
assert(get_caller_address() == self.admin.read(), 'Caller not admin');
self.can_renew.write(false);
}

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 Function update_tax_contract(...) is changing the contract owner

FileFix commitTypeStatus
auto_renewal.cairoPR #14HighFixed

The function update_tax_contract(...) is supposed to update the address of the tax contract. However, the function updates the admin address instead of the tax contract. Since the contract has no two-step process for transferring ownership, you effectively renounce or relinquish administrative control over the smart contract. If this happens in production, you remove the ability to execute administrative functions permanently and irreversibly. The function is reproduced below.

fn update_tax_contract(ref self: ContractState, new_addr: ContractAddress,) {
assert(get_caller_address() == self.admin.read(), 'Caller not admin');
///////////////////////////////////////////////////////////////////////////
// @audit Wrong storage variable. Should be "self.tax_contract.write(new_addr);"
///////////////////////////////////////////////////////////////////////////
self.admin.write(new_addr);
}

Recommendation

Update the function as shown below.

fn update_tax_contract(ref self: ContractState, new_addr: ContractAddress,) {
assert(get_caller_address() == self.admin.read(), 'Caller not admin');
- self.admin.write(new_addr);
+ self.tax_contract.write(new_addr);
}

Resolution

We updated the code according to the recommendation. Fixed in 9ef5b7cd44d67ae3799eba8989d571eea9ab0527.

6.2 Not using a two-step process for transferring ownership

FileFix commitTypeStatus
auto_renewal.cairoPR #16LowFixed

The admin can be updated using the update_admin(...) function. However, the code does not use a two-step process for transferring ownership. A two-step process for transferring ownership in smart contracts enhances security, reduces the risk of errors, and provides a mechanism for verification and reversibility. It is a best practice that adds an extra layer of protection when controlling a contract needs to change hands. Transferring ownership of a smart contract means giving control over its functions and funds to a new entity or address. A two-step process typically involves two transactions: one to initiate the ownership transfer and another to confirm it. This separation allows for verification and validation of the transfer, reducing the risk of accidental or malicious transfers.

The first step usually involves initiating the transfer and confirming the intent, while the second step finalizes the transfer. This adds an extra layer of security because it ensures that the owner has consciously and deliberately chosen to transfer ownership, preventing unauthorized or accidental transfers. A two-step process often includes a time delay between the initiation and confirmation steps. This delay can act as a safeguard against sudden or unexpected transfers. It allows the current owner or other stakeholders to react if the transfer was initiated without proper authorization or in error.

If a mistake is discovered during the confirmation step or if there are concerns about the legitimacy of the transfer, it can be halted before it becomes irreversible. This flexibility is especially valuable when the consequences of an ownership transfer can be significant. The function is reproduced below.

// Admin function to update the admin address and the tax contract address
fn update_admin(ref self: ContractState, new_admin: ContractAddress,) {
//////////////////////////////////////////////////////////////////
// @audit Not using a two-step process for transferring ownership
//////////////////////////////////////////////////////////////////
assert(get_caller_address() == self.admin.read(), 'Caller not admin');
self.admin.write(new_admin);
}

Recommendation

Adopt a two-step process for transferring ownership.

Resolution

We updated the code to adopt a two-step process via start_admin_update and confirm_admin_update. Fixed in: e1830508e0c310dc390684cc5cfc7517484bf2f4.

6.3 Possible unnecessary spending of user funds

FileFix commitTypeStatus
auto_renewal.cairoPR #16
PR #18
LowFixed

The function _renew is called by external methods that can only be called by whitelisted_renewer, which is a centralized authority. This authority can decide tax prices. However, domain prices can also be changed by the authority on naming contracts if there is any case where that tax price or renewing cost is lowered from when users enable renewals. The user still pays the cost initially, but that amount is stuck in the contract and only claimable by the admin.

fn _renew(
ref self: ContractState, root_domain: felt252, renewer: ContractAddress, limit_price: u256, tax_price: u256, metadata: felt252,
) {
...
///////////////////////////////////////////////////////////////
// @audit-issue: The user always debited the amount of `limit_price`
// but that amount can differ from time to time.
///////////////////////////////////////////////////////////////
IERC20CamelDispatcher { contract_address: erc20 }
.transferFrom(renewer, contract, limit_price);
// transfer tax price to tax contract address
IERC20CamelDispatcher { contract_address: erc20 }.transfer(_tax_contract, tax_price);
...
}

Recommendation

Consider calculating the current price of renewal (renewal cost + tax price) and then compare with limit_price. If it is lower or equal, then continue the flow and debit the user only the cost.

Resolution

We followed the suggestion.

Fixed in: 1ffcf572894514e14c20f0e973ca6fe2b4d05d5a, 8bc436b8a848354b21bab1785c06af1d83dc846d.

6.4 tax_price can be greater than limit_price

FileFix commitTypeStatus
auto_renewal.cairoPR #16
PR #18
LowFixed

The whitelisted_renewer charges the renewal for domains by calling the functions renew(...) and batch_renew(...). These functions call the private function _renew(...) reproduced below.

fn _renew(
ref self: ContractState,
root_domain: felt252,
renewer: ContractAddress,
limit_price: u256,
tax_price: u256,
metadata: felt252,
) {
let naming = self.naming_contract.read();
let can_renew = self._is_renewing.read((renewer, root_domain, limit_price));
assert(can_renew, 'Renewal not toggled for domain');
...
IERC20CamelDispatcher { contract_address: erc20 }
.transferFrom(renewer, contract, limit_price);
///////////////////////////////////////////////////////////////////
// @audit ensure that "limit_price" is greater than "tax_price"
///////////////////////////////////////////////////////////////////
IERC20CamelDispatcher { contract_address: erc20 }.transfer(_tax_contract, tax_price);
...
}

The function _renew(...) checks if the renewal for the specified domain and limit_price can be charged. Then, the limit_price amount is taken from the renewer account to the contract. After that, the tax_price is transferred to the tax_contract. As we can notice, the function does not check if the tax_price is less than or equal to the limit_price. When the tax_price exceeds the limit_price, funds deposited in the contract will be transferred to the tax_contract, and the user will not be charged the due amount.

Recommendation

Consider checking if tax_price is lesser or equal to the amount limit_price.

Resolution

We followed the next suggestion, which resolves this one. Fixed in: 1ffcf572894514e14c20f0e973ca6fe2b4d05d5a, and 8bc436b8a848354b21bab1785c06af1d83dc846d.

6.5 Parameter metadata can be changed by a whitelisted caller.

FileFix commitTypeStatus
auto_renewal.cairo—InfoAcknowledged

Metadata passed to this function should be the same as users passed value to function enable_renewals(...). However, in this case, the caller can change this value, which can cause a mismatch in sensitive data on the backend.

fn renew(
ref self: ContractState,
root_domain: felt252,
renewer: ContractAddress,
limit_price: u256,
tax_price: u256,
metadata: felt252,
) {
...
self._renew(root_domain, renewer, limit_price, tax_price, metadata);
///////////////////////////////////////////////////////////////////
// @audit: Metadata is not the one that the user passes
// while enabling renewal. As we know it is a hash of sensitive
// data, but in this case, it is passed to this call via
// centralized caller or oracle(whitelisted_caller)
///////////////////////////////////////////////////////////////////
}

Recommendation

Consider getting this data directly from the users’ parameter. It can be stored in storage and read back in this function. Also, whole data can be stored as a hash.

Resolution

We use metadata for accounting. We could decide not to provide the metadata (a hash of private data) given by the user, but that would be a problem for us, not the user.

6.6 Generic error messages for pop operations

FileFix commitTypeStatus
auto_renewal.cairoPR #16Best PracticesFixed

The function batch_renew(...) receives arrays for batch renewals, and their length needs to be the same. However, the length checking is not applied on the arrays tax_price and metadata. The function is reproduced below.

fn batch_renew(
ref self: ContractState,
domain: array::Span::<felt252>,
renewer: array::Span::<starknet::ContractAddress>,
limit_price: array::Span::<u256>,
tax_price: array::Span::<u256>,
metadata: array::Span::<felt252>,
) {
...
assert(domain.len() == renewer.len(), 'Domain & renewer mismatch len');
assert(domain.len() == limit_price.len(), 'Domain & price mismatch len');
...
loop {
if domain.len() == 0 {
break;
}
let _domain = domain.pop_front().expect('pop_front error');
let _renewer = renewer.pop_front().expect('pop_front error');
let _limit_price = limit_price.pop_front().expect('pop_front error');
////////////////////////////////////////////////////////
// @audit Error messages for tax_price and metadata pop operations are too
// generic.
////////////////////////////////////////////////////////
let _tax_price = tax_price.pop_front().expect('pop_front error');
let _metadata = metadata.pop_front().expect('pop_front error');
self._renew(*_domain, *_renewer, *_limit_price, *_tax_price, *_metadata);
}
}

If tax_price or metadata is lesser than the other arrays, the operation reverts with a generic error message.

Recommendation

Consider customizing the error messages to identify where the error has occurred easily.

Resolution

We updated the code to check the missing arrays’ lengths and replaced the .expect() by unwrap(). Fixed in: e1830508e0c310dc390684cc5cfc7517484bf2f4.

6.7 Missing tax_price and metadata in the event DomainRenewed

FileFix commitTypeStatus
auto_renewal.cairoPR #16Best PracticesFixed

The event DomainRenewed keeps track of the domain, renewer, days, limit_price, and timestamp, as shown below.

#[derive(Drop, starknet::Event)]
struct DomainRenewed {
#[key]
domain: felt252,
renewer: ContractAddress,
days: felt252,
limit_price: u256,
timestamp: u64,
}

This event is emitted in the function fn _renew(...). This function receives the root_domain, renewer, limit_price, tax_price, and metadata as input parameters. The function header is reproduced below.

fn _renew(
ref self: ContractState,
root_domain: felt252,
renewer: ContractAddress,
limit_price: u256,
tax_price: u256,
metadata: felt252,
)

The code triggering the event is reproduced below.

self.emit(
Event::DomainRenewed(
DomainRenewed {
domain: root_domain,
renewer,
days: 365,
limit_price,
timestamp: block_timestamp
}
)
);

We notice that the field days receives the constant 365. Maybe this field can be omitted. On the other hand, the fields tax_price and metadata are not part of the event.

Recommendation

We suggest that the development team discuss the possibility of removing the field days and adding the tax_price and metadata fields.

Resolution

We added the suggested relevant fields. Fixed in 5284970d3df79836c21debfe1cbd11ad3694bf52.

6.8 Missing events emission

FileFix commitTypeStatus
auto_renewal.cairoPR #16Best PracticesFixed

Some important state transitions are not generating events. Events provide a way to log and broadcast important state changes and transactions within a smart contract. These events are recorded on the blockchain and can be publicly accessed and examined by anyone. Events also enable off-chain systems and applications to monitor and analyze the behavior of smart contracts. Below, we list the functions that could benefit from emitting events.

- fn constructor(...) {}
- fn update_admin(...) {}
- fn update_tax_contract(...) {}
- fn update_whitelisted_renewer(...) {}
- fn toggle_off(...) {}
- fn claim(...) {}

Recommendation

We recommend that the development team carefully review the above functions and deliberate on which functions should emit events.

Resolution

We added an event to all the listed functions so users can easily track what happens to the contract. Fixed in: e1830508e0c310dc390684cc5cfc7517484bf2f4.

6.9 Storage variable _is_renewing can be more optimized.

FileFix commitTypeStatus
auto_renewal.cairoPR #16Best PracticesFixed

Using LegacyMap in Cairo done hashes in the background. Storage variable _is_renewing is LegacyMap with keys of 3 elements tuple. However, u256 type in Cairo is represented by two u128, so this mapping will have four elements tuple. To calculate the storage key of the _is_renewing variable, four Pedersen hashes and one keccak. Hash applications are one of the most expensive operations in Starknet.

#[storage]
struct Storage {
...
_is_renewing: LegacyMap::<(ContractAddress, felt252, u256), bool>,
/////////////////////////////////////////////////////////////////////
// @audit-issue: Calculation of key consumes following applications.
// p(p(p(p(keccak(_is_renewing),u256.high), u256.low,)
// felt252,) ContractAddress,) p: Pedersen Hash
/////////////////////////////////////////////////////////////////////
...
}

It is better to optimize the storage variable, while this variable is just used to register users’ correct variables.

Recommendation

Consider using the following approach.

#[storage]
struct Storage {
...
_is_renewing: LegacyMap::<(ContractAddress, felt252), u256>,
/////////////////////////////////////////////////////////////////
// @audit-issue: Similar usage but instead of using u256 as key,
// it is used as a value.
/////////////////////////////////////////////////////////////////
}

Resolution

We adopted the suggested approach. Fixed in e1830508e0c310dc390684cc5cfc7517484bf2f4.

6.10 Storage variables can be constant

FileFix commitTypeStatus
auto_renewal.cairo—Best PracticesAcknowledged

Storage variables with names: naming_contract and erc20_contract can be constants instead of stored in contract storage. These variables are assigned in the constructor and never changed again. Reading from storage causes unnecessary syscalls.

#[storage]
struct Storage {
naming_contract: ContractAddress,
erc20_contract: ContractAddress,
...
}

Recommendation

Consider assigning these variables to contract-level constants.

Resolution

We understand the suggestion but prefer to keep on storage variables because it is not that expensive and allows us to test the contract more easily and use the same class hash on both testnet and mainnet.

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

The Starknet.ID team has provided two sources of documentation. A README explaining all the implemented features and restrictions in the Auto renew contract. Business logic documentation can be found in https://docs.starknet.id/.

Test suite
15Tests 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.