prePO contest - 0xNazgul's results

Decentralized Exchange for Pre-IPO Stocks & Pre-IDO Tokens.

General Information

Platform: Code4rena

Start Date: 09/12/2022

Pot Size: $36,500 USDC

Total HM: 9

Participants: 69

Period: 3 days

Judge: Picodes

Total Solo HM: 2

Id: 190

League: ETH

prePO

Findings Distribution

Researcher Performance

Rank: 46/69

Findings: 1

Award: $28.12

QA:
grade-b

🌟 Selected for report: 0

🚀 Solo Findings: 0

Awards

28.124 USDC - $28.12

Labels

bug
grade-b
QA (Quality Assurance)
sponsor disputed
Q-30

External Links

[NAZ-L1] Value Range Validity for Setters

Severity Low Context: TokenSender.sol#L45, TokenSender.sol#L50, TokenSender.sol#L55, NFTScoreRequirement.sol#L17, DepositRecord.sol#L23, WithdrawHook.sol#L96, WithdrawHook.sol#L101, WithdrawHook.sol#L106, WithdrawHook.sol#L111

Description: These functions doesn't have any checks to ensure that the variables being set is within some kind of value range.

Recommendation: Each variable input parameter updated should have it's own value range checks to ensure their validity.

[NAZ-L2] Max/Infinite Approvals are Dangerous

Severity: Low Context: DepositTradeHelper.sol#L18-L19

Description: Giving max/infinite approvals to contracts are dangerous because if those contracts are exploited then they can remove all the funds from the approving addresses.

Recommendation: Consider checking allowance and approve as much as required.

[NAZ-L3] Missing Equivalence Checks in Setters

Severity: Low Context: AccountListCaller.sol#L10, AllowedMsgSenders.sol#L15, TokenSenderCaller.sol#L11, Collateral.sol#L80, Collateral.sol#L90, Collateral.sol#L96, Collateral.sol#L102, Collateral.sol#L107, Collateral.sol#L112, PrePOMarket.sol#L109, PrePOMarket.sol#L114, PrePOMarket.sol#L119, PrePOMarket.sol#L126, PrePOMarketFactory.sol#L36, TokenSender.sol#L45, TokenSender.sol#L50, TokenSender.sol#L55, WithdrawHook.sol#L81, WithdrawHook.sol#L86, WithdrawHook.sol#L91, WithdrawHook.sol#L96, WithdrawHook.sol#L101, WithdrawHook.sol#L106, WithdrawHook.sol#L111

Description: Setter functions are missing checks to validate if the new value being set is the same as the current value already set in the contract. Such checks will showcase mismatches between on-chain and off-chain states.

Recommendation: This may hinder detecting discrepancies between on-chain and off-chain states leading to flawed assumptions of on-chain state and protocol behavior.

[NAZ-L4] Missing Time locks

Severity: Low Context: AccountListCaller.sol#L10, AllowedMsgSenders.sol#L15, TokenSenderCaller.sol#L11, Collateral.sol#L80, Collateral.sol#L102, Collateral.sol#L107, Collateral.sol#L112, PrePOMarket.sol#L109, PrePOMarket.sol#L114, PrePOMarket.sol#L119, PrePOMarketFactory.sol#L36, TokenSender.sol#L45, TokenSender.sol#L50, TokenSender.sol#L55, WithdrawHook.sol#L81, WithdrawHook.sol#L86, WithdrawHook.sol#L91, WithdrawHook.sol#L96, WithdrawHook.sol#L101, WithdrawHook.sol#L106, WithdrawHook.sol#L111

Description: When critical parameters of systems need to be changed, it is required to broadcast the change via event emission and recommended to enforce the changes after a time-delay. This is to allow system users to be aware of such critical changes and give them an opportunity to exit or adjust their engagement with the system accordingly. None of the onlyOwner functions that change critical protocol addresses/parameters have a timelock for a time-delayed change to alert: (1) users and give them a chance to engage/exit protocol if they are not agreeable to the changes (2) team in case of compromised owner(s) and give them a chance to perform incident response.

Recommendation: Users may be surprised when critical parameters are changed. Furthermore, it can erode users' trust since they can’t be sure the protocol rules won’t be changed later on. Compromised owner keys may be used to change protocol addresses/parameters to benefit attackers. Without a time-delay, authorised owners have no time for any planned incident response.

[NAZ-L5] Missing Zero-address Validation

Severity: Low Context: AccountListCaller.sol#L10, AllowedMsgSenders.sol#L15, TokenSenderCaller.sol#L11, Collateral.sol#L29, Collateral.sol#L80, Collateral.sol#L102, Collateral.sol#L107, Collateral.sol#L112, DepositTradehelper.sol#L14, PrePOMarket.sol#L109, PrePOMarket.sol#L114, PrePOMarketFactory.sol#L36, TokenSender.sol#L31, WithdrawHook.sol#L81, WithdrawHook.sol#L86

Description: Lack of zero-address validation on address parameters may lead to transaction reverts, waste gas, require resubmission of transactions and may even force contract redeployments in certain cases within the protocol.

Recommendation: Consider adding explicit zero-address validation on input parameters of address type.

[NAZ-L6] Missing Events In Initialize Functions

Severity: Low Context: Collateral.sol#L34, PrePOMarketFactory.sol#L16

Description: None of the initialize functions emit emit init-specific events. They all however have the initializer modifier (from Initializable) so that they can be called only once. Off-chain monitoring of calls to these critical functions is not possible.

Recommendation: It is recommended to emit events in your initialization functions.

[NAZ-N1] Code Contains Empty Blocks

Severity: Informational Context: LongShortToken.sol#L9

Description: It's best practice that when there is an empty block, to add a comment in the block explaining why it's empty.

Recommendation: Consider adding /* Comment on why */ to the empty blocks.

[NAZ-N2] Function && Variable Naming Convention

Severity Informational Context: Collateral.sol#L10-L17, DepositHook.sol#L13-L14, DepositRecord.sol#L8-L12, ManagerWithdrawHook.sol#L8-L10, PrePOMarket.sol#L14-L27, WithdrawHook.sol#L10-L20

Description: The linked variables do not conform to the standard naming convention of Solidity whereby functions and variable names(local and state) utilize the mixedCase format unless variables are declared as constant in which case they utilize the UPPER_CASE_WITH_UNDERSCORES format. Private variables and functions should lead with an _underscore.

Recommendation: Consider naming conventions utilized by the linked statements are adjusted to reflect the correct type of declaration according to the Solidity style guide.

[NAZ-N3] Code Structure Deviates From Best-Practice

Severity: Informational Context: AccountListCaller.sol#L15, AllowedMsgSenders.sol#L20, NFTScoreRequirement.sol#L17, TokenSenderCaller.sol#L16, Collateral.sol#L45, ManagerWithdrawHook.sol#L19

Description: The best-practice layout for a contract should follow the following order: state variables, events, modifiers, constructor and functions. Function ordering helps readers identify which functions they can call and find constructor and fallback functions easier. Functions should be grouped according to their visibility and ordered as: constructor, receive function (if exists), fallback function (if exists), external, public, internal, private. Functions should then further be ordered with view functions coming after the non-view labeled ones.

Recommendation: Consider adopting recommended best-practice for code structure and layout.

[NAZ-N4] Use Underscores for Number Literals

Severity: Informational Context: Collateral.sol#L19-L20, DepositTradeHelper.sol#L12, ManagerWithdrawHook.sol#L12, PrePOMarket.sol#L30-L31, TokenSender.sol#L25

Description: There are multiple occasions where certain numbers have been hardcoded, either in variables or in the code itself. Large numbers can become hard to read.

Recommendation: Consider using underscores for number literals to improve its readability.

[NAZ-N5] TODOs Left In The Code

Severity: Informational Context: TokenSender.sol#L15

Description: There should never be any TODOs in the code when deploying.

Recommendation: Consider finishing the TODOs before deploying.

[NAZ-N6] Missing or Incomplete NatSpec

Severity: Informational Context: All Contracts

Description: Some functions are missing @notice/@dev NatSpec comments for the function, @param for all/some of their parameters and @return for return values. Given that NatSpec is an important part of code documentation, this affects code comprehension, auditability and usability.

Recommendation: Consider adding in full NatSpec comments for all functions to have complete code documentation for future use.

[NAZ-N7] Older Version Pragma

Severity: Informational Context: All Contracts

Description: Using very old versions of Solidity prevents benefits of bug fixes and newer security checks. Using the latest versions might make contracts susceptible to undiscovered compiler bugs.

Recommendation: Consider using the most recent version.

#0 - c4-judge

2022-12-19T13:50:29Z

Picodes marked the issue as grade-b

#1 - c4-judge

2022-12-19T13:50:43Z

Picodes marked the issue as grade-a

#2 - c4-sponsor

2022-12-22T10:48:23Z

davidprepo marked the issue as sponsor disputed

#3 - ghost

2022-12-22T10:48:50Z

Looks like a generated report and the issues are by design.

#4 - c4-judge

2023-01-07T18:01:34Z

Picodes marked the issue as grade-b

#5 - Picodes

2023-01-07T18:02:25Z

Giving grade b in the absence of evidence that this is not purely an automated report

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