Debt DAO contest - 0xNazgul's results

A cryptonative credit marketplace for fully anon and trustless loans to DAOs.

General Information

Platform: Code4rena

Start Date: 03/11/2022

Pot Size: $115,500 USDC

Total HM: 17

Participants: 120

Period: 7 days

Judge: LSDan

Total Solo HM: 1

Id: 174

League: ETH

Debt DAO

Findings Distribution

Researcher Performance

Rank: 75/120

Findings: 1

Award: $61.35

QA:
grade-b

๐ŸŒŸ Selected for report: 0

๐Ÿš€ Solo Findings: 0

[NAZ-L1] Missing Equivalence Checks in Setters

Severity: Low Context: SpigotLib.sol#L125, SpigotLib.sol#L143, SpigotLib.sol#L164, SpigotLib.sol#L178, SpigotLib.sol#L187, SpigotLib.sol#L196, SpigotLib.sol#L208

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-L2] Missing Time locks

Severity: Low Context: SpigotLib.sol#L125, SpigotLib.sol#L143, SpigotLib.sol#L164, SpigotLib.sol#L178, SpigotLib.sol#L187, SpigotLib.sol#L196, SpigotLib.sol#L208

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-L3] receive() Function Should Emit An Event

Severity: Low Context: Spigot.sol#L227

Description: Consider emitting an event inside this function with msg.sender and msg.value as the parameters. This would make it easier to track incoming ether transfers.

Recommendation: Consider adding events to the receive() functions.

[NAZ-L4] Missing Events In Initialize Functions

Severity: Low Context: SecuredLine.sol#L37, EscrowedLine.sol#L25

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] Commented Out Code

Severity: Informational Context: InterestRateCredit.sol#L74-L86

Description: There is commented code that makes the code messy and unneeded.

Recommendation: Consider removing the commented out code.

[NAZ-N2] Code Contains Empty Blocks

Severity: Informational Context: SecuredLine.sol#L30

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-N3] Function && Variable Naming Convention

Severity Informational Context: Spigot.sol#L21, Escrow.sol#L32, Oracle.sol#L14, EscrowLib.sol#L34, EscrowLib.sol#L51, SpigotLib.sol#L29

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-N4] Code Structure Deviates From Best-Practice

Severity: Informational Context: SecuredLine.sol#L48, Spigot.sol#L70, Escrow.sol#L65, InterestRateCredit.sol#L25, EscrowLib.sol#L87, SpigotLib.sol#L221-L235, SpigotLib.sol#L61, SpigotLib.sol#L241-L289

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-N5] Use Underscores for Number Literals

Severity: Informational Context: InterestRateCredit.sol#L9, LineFactory.sol#L14

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-N6] TODOs (&& Bob) Left In The Code

Severity: Informational Context: LineFactory.sol#L140, LineFactory.sol#L145, CreditLib.sol#L27, CreditListLib.sol#L18

Description: There should never be any TODOs (&& Bob) in the code when deploying.

Recommendation: Consider finishing the TODOs (&& Bob) before deploying.

[NAZ-N7] Spelling Errors

Severity: Informational Context: SecuredLine.sol#L58 (dont => do not), SecuredLine.sol#L58 (fuly => fully), EscrowedLine.sol#L45 (priviliegad => privileged), EscrowedLine.sol#L74 (priviliegad => privileged), EscrowedLine.sol#L85 (priviliegad => privileged), Spigot.sol#L133 (revenu => revenue), Escrow.sol#L94 (thdeposits => the deposits), Escrow.sol#L95 (forlenders => for lenders), InterestRateCredit.sol#L17 (acrrued => accrued), CreditLib.sol#L123 (interset => interest), CreditLib.sol#L200 (bwithdrawn => withdrawn), CreditLib.sol#L221 (seeting => setting), CreditLib.sol#L237 (interset => interest), CreditLib.sol#L250 (demoninated => denominated), LineLib.sol#L56 (sendingtokens => sending tokens), SpigotLib.sol#L53 (doesnt => does not), SpigotLineLib.sol#L44 (priviliged => privileged), SpigotLineLib.sol#L48 (adddress => address), SpigotLineLib.sol#L188 (revenuw => revenue)

Description: Spelling errors in comments can cause confusion to both users and developers.

Recommendation: Consider checking all misspellings to ensure they are corrected.

[NAZ-N8] 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-N9] SPDX License Identifier Not Provided

Severity: Informational Context: All Contracts

Description: SPDX license identifier not provided in source file. Before publishing, consider adding a comment containing "SPDX-License-Identifier: <SPDX-License>" to each source file. Use "SPDX-License-Identifier: UNLICENSED" for non-open-source code.

Recommendation: Consider adding SPDX license identifier.

[NAZ-N10] Floating Pragma

Severity: Informational Context: SecuredLine.sol, Oracle.sol, InterestRateCredit.sol

Description: Contracts should be deployed with the same compiler version and flags that they have been tested with thoroughly. Locking the pragma helps to ensure that contracts do not accidentally get deployed using, for example, an outdated compiler version that might introduce bugs that affect the contract system negatively.

Recommendation: Consider locking the pragma version.

[NAZ-N11] 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-07T17:54:37Z

dmvt marked the issue as grade-b

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