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
Rank: 47/103
Findings: 1
Award: $253.34
🌟 Selected for report: 0
🚀 Solo Findings: 0
🌟 Selected for report: ladboy233
Also found by: 0x1f8b, 0xAgro, 0xSmartContract, 0xbepresent, 0xkato, Aymen0909, CodingNameKiki, Cryptor, Deekshith99, Deivitto, HE1M, IllIllI, Kaysoft, Koolex, PaludoX0, Qeew, RaymondFam, Rolezn, Sathish9098, Tointer, a12jmx, arialblack14, ast3ros, ayeslick, bin2chen, btk, caventa, ch0bu, chaduke, chrisdior4, delfin454000, descharre, evan, fatherOfBlocks, georgits, gz627, jasonxiale, joestakey, kaden, lukris02, nicobevi, nogo, oberon, oyc_109, pfapostol, rbserver, sakshamguruji, seeu, shark, simon135, slvDev, synackrst, tnevler, whilom, zaskoh
253.3371 USDC - $253.34
File:
File:
_beforeCommitToLien
in VaultImplementation.sol_afterCommitToLien
in VaultImplementation.solFile: All functions in the ClearingHouse.sol
file do not have Natspec comments
File: hardhat.config.ts
const config: HardhatUserConfig = { solidity: { compilers: [ { version: "0.8.17", settings: { viaIR: true, optimizer: { enabled: true, runs: 200, },
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.
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); }
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.
setApprovalForAll
function is not implementedfunction setApprovalForAll(address operator, bool approved) external {}
setApprovalForall
functionality.isApprovedforAll
always return truefunction isApprovedForAll(address account, address operator) external view returns (bool) { return true; }
Consider implementing the functionality of isApprovedforAll
function.
The account
and id
parameters of the balanceOf
function are unused
File: src/ClearingHouse.sol#L82-L88
The ids
paramater of balanceOfBatch function is unused
File: src/ClearingHouse.sol#L90
All The parameters of the setApprovalForAll
and the isApprovalForAll
functions are unused.
File:
tokenContract
and the to
parameters of the _execute
functions are unused
File: src/ClearingHouse.sol#L115
All the parameters of the onERC721Received
function are unused.
File: src/ClearingHouse.sol#L188
The caller
and offerer
parameters of the isValidOrder
functions are unused
File: CollateralToken.sol#L157
The caller
, priorOrderhashes
and criteriaResolvers
parameters of the isValidOrderIncludingExtraData
are unused
File: CollateralToken.sol#L171
tokenContract
local variable of the releaseToAddress
function is unused
file: CollateralToken.sol#L342
unused local variable end
in the _paymentAH
function
File: LienToken.sol#L632
unused local variable s
for the _getRemainingInterest
function.
File: LienToken.sol#L775
unused local variable assets
in deposit
function of PublicVault.sol
File: PublicVault.sol#L262
unused function parameter param
in the function _beforeCommitToLien
of PublicVault.sol
File: PublicVault.sol#L413
unused function parameter shares
in the function afterDeposit
of the PublicVault.sol file
File: PublicVault.sol#L413
Unused local variable stack
and currentOfferPrice
ClearingHouse.sol#L139
Consider updating the code not to allow unused variables
The onwer
variables in redeem
, withdraw
, _redeemFutureEpoch
and redeemFutureEpoch
functions SHADOW the AstriaVaultBase.owner
variable.
Consider renaming the owner variable in those functions.
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