Biconomy - Smart Contract Wallet contest - 2997ms'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: 81/105

Findings: 1

Award: $36.50

QA:
grade-b

🌟 Selected for report: 0

šŸš€ Solo Findings: 0

Summary

Low Risk Issues

IssueContexts
LOW-1Change the order of emit1
LOW-2Avoid to create a sender with address 01
LOW-3Initilize() function can be called by anybody1
LOW-4Lack the validation that the divisor should not be 0.1

Non-critical Issues

IssueContexts
NC-1Solidity versions should be consistent1
NC-2Change some functions into modifiers4
NC-3Some enum values are never used1
NC-4Open TODOs2
NC-5Add the validation of start address1
NC-6Rename the function of getDeposit1

[LOW-01]Change the order of emit

It should be build the IEntryPoint first, then emit the event. This is to prevent from issues when building IEntryPoint failed.

Proof Of Concept

https://github.com/code-423n4/2023-01-biconomy/blob/main/scw-contracts/contracts/smart-contract-wallet/SmartAccount.sol#L129-L130

Recommended Mitigation Steps

Change it to:

entryPoint = IEntryPoint(payable(_newEntryPoint)); emit EntryPointChanged(address(_entryPoint), _newEntryPoint);

[LOW-02]Avoid to create a sender with address 0

In createSender function, if we finally failed to create a sender, we return an address 0. And we validate outside when invoking this function, this behaviour is very dangerous and doesn't follow "minimum exposure" principle. We'd better to handle this situation inside the function itself.

Proof Of Concept https://github.com/code-423n4/2023-01-biconomy/blob/5df2e8f8c0fd3393b9ecdad9ef356955f07fbbdd/scw-contracts/contracts/smart-contract-wallet/aa-4337/core/SenderCreator.sol#L25

Recommended Mitigation Steps

Revert directly at the end of this function.

[LOW-03] Initilize() function can be called by anybody

Anyone has the access of init function and can set the owner and entryPointAddress.

initializer doesn't cover the ownership issue. It can only make sure the function is only initialized once. https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/proxy/utils/Initializable.sol

Proof Of Concept https://github.com/code-423n4/2023-01-biconomy/blob/main/scw-contracts/contracts/smart-contract-wallet/SmartAccount.sol#L166-L176

Recommended Mitigation Steps

Add the modifier of mixedAuth

[LOW-04] Lack the validation that the divisor should not be 0.

If b is 0, the transaction will be reverted because there is no validation that b != 0.

As it is a very basic function in math.sol, so we need to add a message to tell the customers why the transaction being reverted. Proof Of Concept https://github.com/code-423n4/2023-01-biconomy/blob/main/scw-contracts/contracts/smart-contract-wallet/libs/Math.sol#L45-L47

Recommended Mitigation Steps Add require(b!=0, "divisor should not be 0");

[NC-01]Solidity versions should be consistent

Most of solidity versions in the files are pragma solidity ^0.8.12;Other files are pragma solidity 0.8.12, it's better to make them consisten.

Proof Of Concept

pragma solidity ^0.8.12;

https://github.com/code-423n4/2023-01-biconomy/blob/main/scw-contracts/contracts/smart-contract-wallet/aa-4337/core/EntryPoint.sol

pragma solidity 0.8.12;

https://github.com/code-423n4/2023-01-biconomy/blob/main/scw-contracts/contracts/smart-contract-wallet/SmartAccountFactory.sol

Recommended Mitigation Steps

Make the versions consistent

[NC-02]Change some functions into modifiers

There are some functions which only do the validations. They are better to be modifier instead of functions

Proof Of Concept

https://github.com/code-423n4/2023-01-biconomy/blob/main/scw-contracts/contracts/smart-contract-wallet/SmartAccountNoAuth.sol#L484

https://github.com/code-423n4/2023-01-biconomy/blob/main/scw-contracts/contracts/smart-contract-wallet/paymasters/BasePaymaster.sol#L104

https://github.com/code-423n4/2023-01-biconomy/blob/main/scw-contracts/contracts/smart-contract-wallet/aa-4337/samples/SimpleAccount.sol#L98

https://github.com/code-423n4/2023-01-biconomy/blob/main/scw-contracts/contracts/smart-contract-wallet/aa-4337/samples/SimpleAccount.sol#L52

https://github.com/code-423n4/2023-01-biconomy/blob/main/scw-contracts/contracts/smart-contract-wallet/base/ModuleManager.sol#L105

Recommended Mitigation Steps

Change them into modifiers

It should be build the IEntryPoint first, then emit the event.

https://github.com/code-423n4/2023-01-biconomy/blob/main/scw-contracts/contracts/smart-contract-wallet/SmartAccount.sol#L129-L130

[NC-03]Some enum values are never used

In the enum Rounding, the values of Up and Zero are never used. So this could be changed into a flag, like "isUp", this is already enough because the default of our calculation is to round down. There is no need to keep a value of down.

Proof Of Concept

​ enum Rounding { ​ Down, // Toward negative infinity ​ Up, // Toward infinity ​ Zero // Toward zero ​ }

https://github.com/code-423n4/2023-01-biconomy/blob/main/scw-contracts/contracts/smart-contract-wallet/libs/Math.sol#L10-L14

Recommended Mitigation Steps Making these enums as one boolean flag is already enough.

[NC-04]Open TODOs

An open TODO is present. It is recommended to avoid open TODOs as they may indicate programming errors that still need to be fixed.

Proof Of Concept

https://github.com/code-423n4/2023-01-biconomy/blob/5df2e8f8c0fd3393b9ecdad9ef356955f07fbbdd/scw-contracts/contracts/smart-contract-wallet/aa-4337/core/EntryPoint.sol#L255

https://github.com/code-423n4/2023-01-biconomy/blob/5df2e8f8c0fd3393b9ecdad9ef356955f07fbbdd/scw-contracts/contracts/smart-contract-wallet/SmartAccountNoAuth.sol#L44

Recommended Mitigation Steps Resolve these TODOs

[NC-05]Add the validation of start address

In getModulesPaginated function, We didn't validate if the start address is 0 or not. Also we didn't check if this address is in modules. When start is 0x0, we treat it as a normal input and we'd better to add a require to validate start address.

Proof Of Concept https://github.com/code-423n4/2023-01-biconomy/blob/5df2e8f8c0fd3393b9ecdad9ef356955f07fbbdd/scw-contracts/contracts/smart-contract-wallet/base/ModuleManager.sol#L114

Recommended Mitigation Steps Add a require to validate start address.

[NC-06]Rename the function of getDeposit

The name "getDeposit" is very confusing, it sounds like withdrawDeposit. Actually this function is to get the balance of deposit. So we can name it "getDepositBalance"

Proof Of Concept

https://github.com/code-423n4/2023-01-biconomy/blob/5df2e8f8c0fd3393b9ecdad9ef356955f07fbbdd/scw-contracts/contracts/smart-contract-wallet/aa-4337/core/BasePaymaster.sol#L82

Recommended Mitigation Steps Name it "getDepositBalance"

#0 - c4-judge

2023-01-22T15:34:18Z

gzeon-c4 marked the issue as grade-b

#1 - c4-sponsor

2023-02-09T12:35:03Z

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