Biconomy - Smart Contract Wallet contest - lukris02's results

One-Stop solution to enable an effortless experience in your dApp to onboard new users and abstract away transaction complexities.

General Information

Platform: Code4rena

Start Date: 04/01/2023

Pot Size: $60,500 USDC

Total HM: 15

Participants: 105

Period: 5 days

Judge: gzeon

Total Solo HM: 1

Id: 200

League: ETH

Biconomy

Findings Distribution

Researcher Performance

Rank: 29/105

Findings: 2

Award: $399.77

QA:
grade-a
Gas:
grade-b

๐ŸŒŸ Selected for report: 0

๐Ÿš€ Solo Findings: 0

QA Report for Biconomy - Smart Contract Wallet contest

Overview

During the audit, 4 low and 14 non-critical issues were found.

โ„–TitleRisk RatingInstance Count
L-1Review is neededLow10
L-2The require for not being a smart contract can be passedLow1
L-3Use the two-step-transfer of ownershipLow1
L-4Misleading commentLow1
NC-1Order of FunctionsNon-Critical5
NC-2Order of LayoutNon-Critical6
NC-3Open TODOsNon-Critical1
NC-4TyposNon-Critical6
NC-5Unused named return variablesNon-Critical4
NC-6Commented codeNon-Critical12
NC-7Empty function bodyNon-Critical1
NC-8Duplicate commentNon-Critical1
NC-9Variables with similar namesNon-Critical4
NC-10No space between the control structuresNon-Critical2
NC-11"nice to have"Non-Critical1
NC-12Missing NatSpecNon-Critical6
NC-13Missing leading underscoresNon-Critical18
NC-14Maximum line length exceededNon-Critical65

Low Risk Findings(5)

L-1. Review is needed

Description

There are many places in the code that have questions and require further review.

Instances
Recommendation

Resolve issues and/or delete irrelevant comments.

L-2. The require for not being a smart contract can be passed

Description

It is unsafe to assume that an address for which isContract function returns false is an externally-owned account (EOA) and not a contract. Among others, isContract will return false for the following types of addresses:

  • an externally-owned account
  • a contract in construction
  • an address where a contract will be created
  • an address where a contract lived, but was destroyed
Instances

L-3. Use the two-step-transfer of ownership

Description

If the owner accidentally transfers ownership to an incorrect address, protected functions may become permanently inaccessible.

Instances

Link:

function setOwner(address _newOwner) external mixedAuth { require(_newOwner != address(0), "Smart Account:: new Signatory address cannot be zero"); address oldOwner = owner; owner = _newOwner; emit EOAChanged(address(this), oldOwner, _newOwner); }
Recommendation

Consider using a two-step-transfer of ownership: the current owner would nominate a new owner, and to become the new owner, the nominated account would have to approve the change, so that the address is proven to be valid.

L-4. Misleading comment

Description

Only mode variable is unused.

Instances
Recommendation

Change to: // (mode; // unused param

Non-Critical Risk Findings(14)

NC-1. Order of Functions

Description

According to Style Guide, ordering helps readers identify which functions they can call and to find the constructor and fallback definitions easier.
Functions should be grouped according to their visibility and ordered:

  1. constructor
  2. receive function (if exists)
  3. fallback function (if exists)
  4. external
  5. public
  6. internal
  7. private
Instances

External functions should be placed before public:

receive() function should be placed before fallback():

Recommendation

Reorder functions where possible.

NC-2. Order of Layout

Description

According to Order of Layout, inside each contract, library or interface, use the following order:

  1. Type declarations
  2. State variables
  3. Events
  4. Modifiers
  5. Functions
Instances

State variables should be placed before events:

Event should be placed before constructor:

enum should be before function:

struct should be placed before events:

NC-3. Open TODOs

Instances
Recommendation

Resolve issues.

NC-4. Typos

Instances

NC-5. Unused named return variables

Description

Both named return variable(s) and return statement are used.

Instances
Recommendation

To improve clarity use only named return variables.
For example, change:

function functionName() returns (uint id) { return x;

to

function functionName() returns (uint id) { id = x;

NC-6. Commented code

Instances
Recommendation

Delete commented code.

NC-7. Empty function body

Instances

NC-8. Duplicate comment

Description

The same comment is at lines โ„–8 and โ„–12 in Executor.sol

Instances
Recommendation

Delete one of the comments.

NC-9. Variables with similar names

Description

Variables with similar names in the same part of the code make it difficult to understand the function and test it, and also it increases the likelihood of an error due to a misprint.

Instances

This part of the code has variables opasLen and opslen, opa and ops.

Recommendation

Consider renaming variables to more different.

NC-10. No space between the control structures

Description

According to Style Guide, there should be a single space between the control structures if, while, and for and the parenthetic block representing the conditional.

Instances
Recommendation

Change:

if(...) { ... }

to:

if (...) { ... }

NC-11. "nice to have"

Description

Probably, this event was supposed to be implemented.

Instances

Link:

// nice to have // event SmartAccountInitialized(IEntryPoint indexed entryPoint, address indexed owner);

NC-12. Missing NatSpec

Description

6 contracts have fucntions withh missing or incomplete NatSpec.

Instances
Recommendation

Add NatSpec for all functions.

NC-13. Missing leading underscores

Instances

Internal and private constants, immutables and functions should have a leading underscore:

Public immutables - should not:

Recommendation

Add and remove leading underscores where needed.

NC-14. Maximum line length exceeded

Description

According to Style Guide, maximum suggested line length is 120 characters.
Longer lines make the code harder to read.

Instances
Recommendation

Make the lines shorter.

#0 - c4-judge

2023-01-22T15:54:34Z

gzeon-c4 marked the issue as grade-a

#1 - c4-sponsor

2023-02-09T10:55:43Z

livingrockrises marked the issue as sponsor confirmed

#2 - livingrockrises

2023-02-09T10:55:49Z

like report quality!

Awards

38.7634 USDC - $38.76

Labels

bug
G (Gas Optimization)
grade-b
sponsor confirmed
G-05

External Links

Gas Optimizations Report for Biconomy - Smart Contract Wallet contest

Overview

During the audit, 2 gas issues were found.

Total savings ~455.

โ„–TitleInstance CountSaved
G-1Use unchecked blocks for incrementing10350
G-2Use unchecked blocks for subtractions where underflow is impossible3105

Gas Optimizations Findings(2)

G-1. Use unchecked blocks for incrementing

Description

In Solidity 0.8+, thereโ€™s a default overflow and underflow check on unsigned integers. In the loops, "i" (or other variable) will not overflow because the loop will run out of gas before that.

Instances
Recommendation

Change:

for (uint256 i; i < n; ++i) { // ... }

to:

for (uint256 i; i < n;) { // ... unchecked { ++i; } }
Saved

This saves ~30-40 gas per iteration.
So, ~35*10 = 350

G-2. Use unchecked blocks for subtractions where underflow is impossible

Description

In Solidity 0.8+, thereโ€™s a default overflow and underflow check on unsigned integers. When an overflow or underflow isnโ€™t possible (after require or if-statement), some gas can be saved by using unchecked blocks.

Instances
Saved

This saves ~35.
So, ~35*3 = 105

#0 - c4-judge

2023-01-22T16:20:45Z

gzeon-c4 marked the issue as grade-b

#1 - c4-sponsor

2023-02-09T12:26:09Z

livingrockrises marked the issue as sponsor confirmed

AuditHub

A portfolio for auditors, a security profile for protocols, a hub for web3 security.

Built bymalatrax ยฉ 2024

Auditors

Browse

Contests

Browse

Get in touch

ContactTwitter