Platform: Code4rena
Start Date: 27/10/2022
Pot Size: $33,500 USDC
Total HM: 8
Participants: 96
Period: 3 days
Judge: kirk-baird
Total Solo HM: 1
Id: 176
League: ETH
Rank: 59/96
Findings: 1
Award: $19.64
🌟 Selected for report: 0
🚀 Solo Findings: 0
🌟 Selected for report: robee
Also found by: 0x007, 0x1f8b, 0x52, 0xDjango, 0xNazgul, 0xSmartContract, 8olidity, Awesome, B2, Bnke0x0, Chom, Diana, Dravee, JTJabba, Jeiwan, Josiah, Lambda, Mathieu, Picodes, RaoulSchaffranek, RaymondFam, RedOneN, ReyAdmirado, Rolezn, Ruhum, Sm4rty, Tricko, Trust, Waze, __141345__, a12jmx, adriro, ajtra, brgltd, c3phas, carlitox477, cccz, ch0bu, chaduke, chrisdior4, corerouter, cryptonue, csanuragjain, ctf_sec, cylzxje, delfin454000, dic0de, djxploit, horsefacts, imare, jayphbee, jwood, ktg, ladboy233, leosathya, lukris02, minhtrng, neko_nyaa, oyc_109, pashov, peritoflores, rbserver, rvierdiiev, shark, tnevler, yixxas
19.6449 USDC - $19.64
Issue | Contexts | |
---|---|---|
LOW‑1 | Missing parameter validation in constructor | 4 |
Total: 4 contexts over 1 issues
Issue | Contexts | |
---|---|---|
NC‑1 | Use a more recent version of Solidity | 1 |
NC‑2 | Event Is Missing Indexed Fields | 4 |
NC‑3 | Implementation contract may not be initialized | 1 |
NC‑4 | Unused event may be unused code or indicative of missed emit/logic | 1 |
NC‑5 | Non-usage of specific imports | 8 |
NC‑6 | Lines are too long | 2 |
Total: 17 contexts over 6 issues
constructor
Some parameters of constructors are not checked for invalid values.
132: constructor( 133: address _votingEscrow, 134: address _delegationBoost, 135: address _chestAddress, 136: uint256 _minTargetVotes 137: ) {
https://github.com/code-423n4/2022-10-paladin/tree/main/contracts/WardenPledge.sol#L132-L137
Validate the parameters.
Use a solidity version of at least 0.8.12 to get string.concat() instead of abi.encodePacked(<str>,<str>) Use a solidity version of at least 0.8.13 to get the ability to use using for with a list of free functions
pragma solidity 0.8.10;
https://github.com/code-423n4/2022-10-paladin/tree/main/contracts/WardenPledge.sol#L2
Consider updating to a more recent solidity version.
Index event fields make the field more quickly accessible to off-chain tools that parse events. However, note that each index field costs extra gas during emission, so it's not necessarily best to index the maximum allowed per event (three fields).
Each event should use three indexed fields if there are three or more fields, and gas usage is not particularly of concern for the events in question. If there are fewer than three fields, all of the fields should be indexed.
event NewPledge( address creator, address receiver, address rewardToken, uint256 targetVotes, uint256 rewardPerVote, uint256 endTimestamp );
https://github.com/code-423n4/2022-10-paladin/tree/main/contracts/WardenPledge.sol#L85
event ChestUpdated(address oldChest, address newChest);
https://github.com/code-423n4/2022-10-paladin/tree/main/contracts/WardenPledge.sol#L115
event PlatformFeeUpdated(uint256 oldfee, uint256 newFee);
https://github.com/code-423n4/2022-10-paladin/tree/main/contracts/WardenPledge.sol#L117
event MinTargetUpdated(uint256 oldMinTarget, uint256 newMinTargetVotes);
https://github.com/code-423n4/2022-10-paladin/tree/main/contracts/WardenPledge.sol#L119
OpenZeppelin recommends that the initializer modifier be applied to constructors. Per OZs Post implementation contract should be initialized to avoid potential griefs or exploits. https://forum.openzeppelin.com/t/uupsupgradeable-vulnerability-post-mortem/15680/5
132: constructor( 133: address _votingEscrow, 134: address _delegationBoost, 135: address _chestAddress, 136: uint256 _minTargetVotes 137: ) {
https://github.com/code-423n4/2022-10-paladin/tree/main/contracts/WardenPledge.sol#L132-L137
Events that are declared but not used may be indicative of unused declarations where it makes sense to remove them for better readability/maintainability/auditability, or worse indicative of a missing emit which is bad for monitoring or missing logic that would have emitted that event.
96: event IncreasePledgeTargetVotes
https://github.com/code-423n4/2022-10-paladin/tree/main/contracts/WardenPledge.sol#L96
Add emit or remove event declaration.
The current form of relative path import is not recommended for use because it can unpredictably pollute the namespace. Instead, the Solidity docs recommend specifying imported symbols explicitly. https://docs.soliditylang.org/en/v0.8.15/layout-of-source-files.html#importing-other-source-files
4: import "./oz/interfaces/IERC20.sol"; 5: import "./oz/libraries/SafeERC20.sol"; 6: import "./utils/Owner.sol"; 7: import "./oz/utils/Pausable.sol"; 8: import "./oz/utils/ReentrancyGuard.sol"; 9: import "./interfaces/IVotingEscrow.sol"; 10: import "./interfaces/IBoostV2.sol"; 11: import "./utils/Errors.sol"; https://github.com/code-423n4/2022-10-paladin/tree/main/contracts/WardenPledge.sol#L4-L11 #### <ins>Recommended Mitigation Steps</ins> Use specific imports syntax per solidity docs recommendation. ### <a href="#Summary">[NC‑6]</a><a name="NC‑6"> Lines are too long Usually lines in source code are limited to 80 characters. Today's screens are much larger so it's reasonable to stretch this in some cases. Since the files will most likely reside in GitHub, and GitHub starts using a scroll bar in all cases when the length is over 164 characters, the lines below should be split when they reach that length Reference: https://docs.soliditylang.org/en/v0.8.10/style-guide.html#maximum-line-length #### <ins>Proof Of Concept</ins>
239: // Check that the user has enough boost delegation available & set the correct allowance to this contract
https://github.com/code-423n4/2022-10-paladin/tree/main/contracts/WardenPledge.sol#L239
261: // based on the Boost bias & the Boost duration, to take in account that the delegated amount decreases
https://github.com/code-423n4/2022-10-paladin/tree/main/contracts/WardenPledge.sol#L261
#0 - kirk-baird
2022-11-12T00:02:27Z
NC-3 is not applicable here as it is not a proxy contract that inherits Initializeable
#1 - c4-judge
2022-11-12T00:02:32Z
kirk-baird marked the issue as grade-b