Astaria contest - Kaysoft'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: 47/103

Findings: 1

Award: $253.34

QA:
grade-a

🌟 Selected for report: 0

🚀 Solo Findings: 0

[NC-01] SPDX license identifier not provided in source file.

File:

[NC-02] Remove empty blocks or emit events.

File:

  • src/BeaconProxy.sol#L87
  • _beforeCommitToLien in VaultImplementation.sol
  • _afterCommitToLien in VaultImplementation.sol

[NC-03] No NatSpec comments for some functions on the codebase

File: All functions in the ClearingHouse.sol file do not have Natspec comments

[NC-04] Solidity compiler optimization can be problematic

File: hardhat.config.ts

const config: HardhatUserConfig = {
  solidity: {
    compilers: [
      {
        version: "0.8.17",
        settings: {
          viaIR: true,
          optimizer: {
            enabled: true,
            runs: 200,
          },

Description

Protocol has enabled optional compiler optimizations in Solidity. There have been several optimization bugs with security implications. Moreover, optimizations are actively being developed. Solidity compiler optimizations are disabled by default, and it is unclear how many contracts in the wild actually use them.

Therefore, it is unclear how well they are being tested and exercised. High-severity security issues due to optimization bugs have occurred in the past. A high-severity bug in the emscripten-generated solc-js compiler used by Truffle and Remix persisted until late 2018. The fix for this bug was not reported in the Solidity CHANGELOG.

Another high-severity optimization bug resulting in incorrect bit shift results was patched in Solidity 0.5.6. More recently, another bug due to the incorrect caching of keccak256 was reported. A compiler audit of Solidity from November 2018 concluded that the optional optimizations may not be safe. It is likely that there are latent bugs related to optimization and that new bugs will be introduced due to future optimizations.

Exploit Scenario A latent or future bug in Solidity compiler optimizations—or in the Emscripten transpilation to solc-js—causes a security vulnerability in the contracts.

Short term, measure the gas savings from optimizations and carefully weigh them against the possibility of an optimization-related bug.Long term, monitor the development and adoption of Solidity compiler optimizations to assess their maturity.

[L-01] Lack of 2 step ownership change

Mistakenly setting the new owner with a wrong address will be irrecoverable.

File: src/AuthInitializable.sol#L95

function transferOwnership(address newOwner) public virtual requiresAuth { AuthStorage storage s = _getAuthSlot(); s.owner = newOwner; emit OwnershipTransferred(msg.sender, newOwner); }

Use Openzeppelin's 2-step ownership change. see https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/access/Ownable2Step.sol#L35-L56

function transferOwnership(address newOwner) public virtual override onlyOwner { _pendingOwner = newOwner; emit OwnershipTransferStarted(owner(), newOwner); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`) and deletes any pending owner. * Internal function without access restriction. */ function _transferOwnership(address newOwner) internal virtual override { delete _pendingOwner; super._transferOwnership(newOwner); } /** * @dev The new owner accepts the ownership transfer. */ function acceptOwnership() external { address sender = _msgSender(); require(pendingOwner() == sender, "Ownable2Step: caller is not the new owner"); _transferOwnership(sender); }

[L-02] The balanceOf function do not return the balance.

The balanceOf function does not return the balance of the account. The function instead always return type(uint256).max. File: src/ClearingHouse.sol#L82-L88

function balanceOf(address account, uint256 id) external view returns (uint256) { return type(uint256).max; }

Implement the balanceOf functionality instead of returning the max uint value.

[L-03] The setApprovalForAll function is not implemented

File: https://github.com/code-423n4/2023-01-astaria/blob/1bfc58b42109b839528ab1c21dc9803d663df898/src/ClearingHouse.sol#L104

function setApprovalForAll(address operator, bool approved) external {}
  • Consider implementing the setApprovalForall functionality.

[L-04] The isApprovedforAll always return true

File: https://github.com/code-423n4/2023-01-astaria/blob/1bfc58b42109b839528ab1c21dc9803d663df898/src/ClearingHouse.sol#L106

function isApprovedForAll(address account, address operator) external view returns (bool) { return true; }

Consider implementing the functionality of isApprovedforAll function.

[L-05] Remove unused parameters and variables

Consider updating the code not to allow unused variables

[L-06] Shadowing local variables found in PublicVault.sol

The onwer variables in redeem, withdraw, _redeemFutureEpoch and redeemFutureEpoch functions SHADOW the AstriaVaultBase.owner variable.

Tool used
  • Solhint

Consider renaming the owner variable in those functions.

[L-07] currentWithdrawProxy local variable in the function transferWithdrawReserve of PublicVault.sol file is declared twice.

Lines: 366 and 397

#0 - c4-judge

2023-01-26T14:51:18Z

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