Astaria contest - nicobevi's results

On a mission is to build a highly liquid NFT lending market.

General Information

Platform: Code4rena

Start Date: 05/01/2023

Pot Size: $90,500 USDC

Total HM: 55

Participants: 103

Period: 14 days

Judge: Picodes

Total Solo HM: 18

Id: 202

League: ETH

Astaria

Findings Distribution

Researcher Performance

Rank: 45/103

Findings: 1

Award: $253.34

QA:
grade-a

🌟 Selected for report: 0

🚀 Solo Findings: 0

[QA] - Function state mutability can be restricted to view

Where

[QA] - Function state mutability can be restricted to pure

Where

[QA] - Address param could be address(0)

Where

[QA] - Use OpenZeppelin's Base64.sol contract instead of write your own.

Where

[QA] - Add error messages or use custom errors instead

Where

[QA] - Invalid comment on function

Where

[QA] - Params shadowing storage variables

Function input param owner is shadowing the function owner(). The recommendation is to change the name to _owner.

Where

[QA] - currentWithdrawProxy is shadowing

Where

[QA] - Unused variables

Remove any unused variable

Where

[QA] - Unused input param

If an input param is not being used in the function body, then it could be removed to save gas

Where

[QA] - Constant name must be in capitalized SNAKE_CASE

Where

[QA] - Add // solhint-disable-next-line no-inline-assembly on assembly blocks

Where

[QA] - Create an onlyGuardian modifier/private function that verifies that msg.sender is the guardian and throw an error otherwise

Where

AstariaRouter.sol

+ error OnlyGuardianError();

+ function onlyGuardian(address guardian) private view {
+   if (msg.sender != guardian) {
+     revert OnlyGuardianError();
+   }
+ }

  function setNewGuardian(address _guardian) external {
    RouterStorage storage s = _loadRouterSlot();
-   require(msg.sender == s.guardian);
+   onlyGuardian(s.guardian);
    s.newGuardian = _guardian;
  }

  function __renounceGuardian() external {
    RouterStorage storage s = _loadRouterSlot();
-   require(msg.sender == s.guardian);
+   onlyGuardian(s.guardian);
    s.guardian = address(0);
    s.newGuardian = address(0);
  }

  function __acceptGuardian() external {
    RouterStorage storage s = _loadRouterSlot();
-   require(msg.sender == s.newGuardian);
+   onlyGuardian(s.newGuardian);
    s.guardian = s.newGuardian;
    delete s.newGuardian;
  }

  function fileGuardian(File[] calldata file) external {
    RouterStorage storage s = _loadRouterSlot();
-   require(msg.sender == address(s.guardian));
+   onlyGuardian(address(s.guardian));

    uint256 i;
    for (; i < file.length; ) {
      FileType what = file[i].what;
      bytes memory data = file[i].data;
      if (what == FileType.Implementation) {
        (uint8 implType, address addr) = abi.decode(data, (uint8, address));
        if (addr == address(0)) revert InvalidFileData();
        s.implementations[implType] = addr;
      } else if (what == FileType.CollateralToken) {
        address addr = abi.decode(data, (address));
        if (addr == address(0)) revert InvalidFileData();
        s.COLLATERAL_TOKEN = ICollateralToken(addr);
      } else if (what == FileType.LienToken) {
        address addr = abi.decode(data, (address));
        if (addr == address(0)) revert InvalidFileData();
        s.LIEN_TOKEN = ILienToken(addr);
      } else if (what == FileType.TransferProxy) {
        address addr = abi.decode(data, (address));
        if (addr == address(0)) revert InvalidFileData();
        s.TRANSFER_PROXY = ITransferProxy(addr);
      } else {
        revert UnsupportedFile();
      }
      emit FileUpdated(what, data);
      unchecked {
        ++i;
      }
    }
  }

[QA] - Add visibility to storage variables

Where

[QA] - Use floating pragma version for interfaces

Where

[QA] - Use fixed pragma version for contracts

Where

[QA] - Explicitly mark visibility of state

Where

[QA] - Use ROUTER() instead of calling the low function _getArgAddress(0) multiple times on ClearingHouse.sol

Where

- IAstariaRouter ASTARIA_ROUTER = IAstariaRouter(_getArgAddress(0));
+ IAstariaRouter ASTARIA_ROUTER = IAstariaRouter(ROUTER());

#0 - c4-judge

2023-01-26T14:27:40Z

Picodes marked the issue as grade-a

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