Axelar Network v2 contest - mics's results

Decentralized interoperability network.

General Information

Platform: Code4rena

Start Date: 29/07/2022

Pot Size: $50,000 USDC

Total HM: 6

Participants: 75

Period: 5 days

Judge: GalloDaSballo

Total Solo HM: 3

Id: 149

League: ETH

Axelar Network

Findings Distribution

Researcher Performance

Rank: 21/75

Findings: 2

Award: $101.29

🌟 Selected for report: 0

🚀 Solo Findings: 0

QA REPORT

Table Of Content

QA REPORT

Should approve(0) first

Some tokens (like USDT L199) do not work when changing the allowance from an existing non-zero allowance value. They must first be approved by zero and then the actual allowance must be approved.

Code Instances:

Consider adding constant variables instead of hardcoded strings

A good practice is to use constant variables instead of hardcoded strings in the code.

Code Instances:

Magical number should be documented and explained. Use a constant instead

For instance, [DepositBase.sol#L31](https://github.com/code-423n4/2022-07-axelar/tree/main/C:\Users\eldad\Desktop\Code Arena\2022-07-axelar\contracts/deposit-service/DepositBase.sol#L31)

Approve return value is ignored

According to the ERC20 specs, the approve function is allowed to return a success value, that may be negative. Same as transfer return value, approve return value should be handled.

Code Instances:

Some contracts does not support 0 transfer, then the transaction will revert with no explanation. We recommend to add a require statement that the amount is not 0.

Code Instances:

Use safeApprove() instead approve()

Use openzeppelin safeApprove() method instead of approve() in the following locations.

Code Instances:

Use safeTransfer() instead approve()

Use openzeppelin safeTransfer() method instead of transfer() in the following locations.

Code Instances:

Unused success return value

The following calls ignores the return value of the called function that might indicate the the call failed.

Code Instances:

Different solidity versions are in use

The project is compiled with different versions of solidity, which is not recommended because it can lead to undefined behaviors.

Contract should have pause/unpause functionality

In case a hack is occuring or an exploit is discovered, the team (or validators in this case) should be able to pause functionality until the necessary changes are made to the system. Additionally, the gravity.sol contract should be manged by proxy so that upgrades can be made by the validators.

Because an attack would probably span a number of blocks, a method for pausing the contract would be able to interrupt any such attack if discovered.)

Code Instances:

Missing two steps verification process

The process of transferring ownership is dangerous since typing the wrong address can lead to severe implications. It is better to have to steps verification process with set and claim functions to decrease the chances of human error. Consider changing to two steps verification process of transferring privileges. Human mistakes can happen.

Code Instances:

Array access is out of bounds

There is no check for the access to be in the array bounds.

For instance, AxelarAuthWeighted.sol

Immutable state variable assignment without validation

Code Instances:

Missing function spec comments

Code Instances:

Missing nonReentrancy modifier

The following functions allows attackers to try reentrancy since they are calling to external contracts / transferring eth. Consider adding a nonReentrancy modifier.

Code Instances:

Use timelock modifier for setter functions

It is good to have a timelock for functions that set key/critical variables.

Code Instances:

Missing zero address check in a state variable setter function

A state variable of type 'address' is set without a non-zero verification. This can lead to undesired behavior.

Code Instances:

Events not emitted for important state changes

When changing state variables events are not emitted. Emitting events allows monitoring activities with off-chain monitoring tools.

Code Instances:

Payable functions that should not be payable

The following functions are payable but doesn't record the sender transaction. Consider making them not payable instead.

Code Instances:

Missing event emit

In functions that update/assigns state variables it is a good practice to emit event.

Code Instances:

Unused function parameters should have name removed

If for any reason the following unused parameters are necessary then remove their naming (since only the type matters for function signature)

Code Instances:

validate fee parameter

The fee parameter should be validated to me strictly greater than 0 and less than 100%. In the following lines at least one of those checks is missing.

Code Instances:

#0 - re1ro

2022-08-05T01:38:04Z

Should approve(0) first

Dup #3

Consider adding constant variables instead of hardcoded strings

Ack. We might keep it this way because those are error messages.

Magical number should be documented and explained. Use a constant instead

Good spot

Approve return value is ignored

Yup. Dup #16

0 amount check

Yup. Good spot

Use safeApprove() instead approve()

Yup. Good spot.

Use safeTransfer() instead approve()

Not applicable.

Unused success return value

Not applicable.

Different solidity versions are in use

Dup #8

Contract should have pause/unpause functionality

No applicable by design

Missing two steps verification process

Dup #16

Array access is out of bounds

Not applicable. It's checked in _transferOperatorship

Immutable state variable assignment without validation

Good spot.

Missing function spec comments

Ack

Missing nonReentrancy modifier

There is not reentrancy threat there

Use timelock modifier for setter functions

Ack

Missing zero address check in a state variable setter function

Good spot

Events not emitted for important state changes

Not applicable. Those are example/unit test contracts

Payable functions that should not be payable

Not applicable. Those are example/unit test contracts. Payable functions use less gas and actually needed in those places.

Missing event emit

Not applicable

Unused function parameters should have name removed

Ack

validate fee parameter

Ack

#1 - GalloDaSballo

2022-09-05T14:46:23Z

Should approve(0) first

Disputed as it's used properly in this codebase

Consider adding constant variables instead of hardcoded strings

R, this is another issue of using strings instead of custom errors

Magical number should be documented and explained. Use a constant instead

R

Approve return value is ignored & use SafeApprove

L

Different solidity versions are in use

NC

Contract should have pause/unpause functionality

Disagree with blank-all statement

Missing two steps verification process

NC

Array access is out of bounds

R as the statement is closer to "fail early"

Immutable state variable assignment without validation & Missing zero address check in a state variable setter function

L

Missing function spec comments

NC

Missing nonReentrancy modifier

You can't make a statement about security and then link to the entire file, disputed in lack of a clear risk

Use timelock modifier for setter functions

Disputed per the rulebook, you cannot verify a timelock is or is not being used

Events not emitted for important state changes

NC

Every other finding doesn't link to the specific line nor mentions it, for that reason I'm ignoring them.

A report like this feels like hearing Rajeev from Secureum mixed in with other old reports, I don't think it offers anything unique to the sponsor

The lack of polish (links without reference, dump of links) further diminishes the perceived value from this report, which does have some valid findings.

I'm not impressed

2L 3R 4NC

GAS REPORT

Table Of Content

GAS REPORT

Using abiEncodePacked() is more efficient that abiEncode()

Code Instances:

Caching array size

In the following for loops consider caching the array size instead of loading it every iteration.

Code Instances:

replace <= and >=

You can replace a<=b with a-1<b which reduces the gas usage.

Code Instances:

Don't cache msg.sender

reading msg.sender is 2 gas units which is less than a read of a local var + the unnecessary store operation.

Code Instances:

Use assembly opcodes iszero instead of solidity equation to save gas

Code Instances:

Mark as payable If has onlyOwner modifier

In order to save gas you can put a payable modifier for functions that are called by protocol owners.

Code Instances:

#0 - re1ro

2022-08-05T01:45:35Z

1

abi.encodePacked is not secure. Dup #2

2

Yup. Dup #2

3

replace <= and >=

Good spot.

4

Not applicable. Broken line numbers...

5

Ack. We might prefer readability over this optimisation.

6

Dup #7 [G-05]

#1 - GalloDaSballo

2022-08-23T00:55:17Z

Less than 100 gas saved

iszero doesn't always save gas when compared to unchecked unchecked almost always is equivalent, true benchmark should be offered for this type of advice as the blanket statement is a 50/50

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