Platform: Code4rena
Start Date: 05/10/2023
Pot Size: $33,050 USDC
Total HM: 1
Participants: 54
Period: 6 days
Judge: hansfriese
Id: 294
League: ETH
Rank: 28/54
Findings: 2
Award: $16.12
🌟 Selected for report: 0
🚀 Solo Findings: 0
🌟 Selected for report: thekmj
Also found by: 0x3b, 33BYTEZZZ, Bauchibred, Chom, Dravee, J4X, Limbooo, Maroutis, MiloTruck, MrPotatoMagic, SBSecurity, Sathish9098, Tadev, ZanyBonzy, adam-idarrha, adriro, btk, hyh, lukejohn, nmirchev8, peakbolt, radev_sw, rvierdiiev
5.4311 USDC - $5.43
Total 9 instances over 7 issues:
L: Low impact issue, N: Non Critical Issues
ID | Issue | Instances |
---|---|---|
[L-01] | Delegating to Address Zero | 1 |
[L-02] | Token Transfer to ERC20ProxyDelegator | 1 |
[N-03] | No Standardized Data Format for delegateMulti | 1 |
[L-04] | Lack of a Pausable Mechanism | 2 |
[L-05] | Interaction with Approved Operators in ERC1155 | 1 |
[N-06] | Same Source and Target | 1 |
[N-07] | Lack of Event Emission | 2 |
[N-08] | Redundant Balance Check in _processDelegation | 2 |
The contract allows users to delegate to address zero (0x0), which effectively locks up tokens without a valid delegate. This can be achieved when one of the entities in the targets
array in the delegateMulti
params has a value of 0.
Recommendation: Add checks to prevent delegating to address zero or implement specific actions.
ERC20ProxyDelegator
Transferring tokens directly to an ERC20ProxyDelegator
contract before or after the creation is currently counted as a valid vote but is not recoverable. This could lead to unintentional loss of tokens.
Recommendation: Implement a mechanism to recover tokens sent directly to ERC20ProxyDelegator
for improved user experience.
delegateMulti
The delegateMulti
function takes three arrays (sources, targets, and amounts) as arguments, making it less user-friendly and challenging to integrate with other contracts and tools.
Recommendation: Consider implementing a structured data format for better usability.
Code Snippet:
struct Delegation { // maybe type and owner address source; address target; uint256 amount; } function delegateMulti(Delegation[] calldata delegations) external { // Process delegations using the structured format. for (uint256 i = 0; i < delegations.length; i++) { _processDelegation(delegations[i]); } //... }
The contract does not include a pausable mechanism, which can be essential for emergency scenarios, bug fixes, or temporary halting of certain functions.
Recommendation: Implement a pausable mechanism for added security and control.
Description: The contract does not allow approved operators in ERC1155 to implement the delegateMulti
function on behalf of their users. This limitation can impact usability.
Recommendation: Explore options to allow approved operators to interact with delegateMulti
.
When the source and target addresses are the same, the contract still executes a transfer operation, but this doesn't have any practical impact on the contract's functionality. It results in the emission of redundant events.
Recommendation: Optimize the code to avoid redundant event emissions in this scenario.
Token transfers from a source delegate (proxy delegator) back to the user in the _reimburse
function and during the creation of proxy delegators are missing event emissions. This absence of event emission may lead to confusion and misunderstandings about the state of the current situation, as users are not notified when these functionality occur.
Recommendation: Implement an event emission mechanism to notify users whenever tokens are transferred during the reimbursement process in the _reimburse
function and when tokens are sent to proxy delegators. This will improve transparency and user experience.
Instances:
_reimburse
function._processDelegation
In the _processDelegation
function, there's a redundant balance check on the user's account, ensuring they have a sufficient balance for the token transfer. However, the standard balanceOf
function check is already performed within the _burnBatch
function, which is part of the ERC1155 standard behavior.
Recommendation: Remove the redundant balance check within _processDelegation
to optimize gas costs and improve code efficiency.
#0 - 141345
2023-10-13T12:49:34Z
L-02 is dup of https://github.com/code-423n4/2023-10-ens-findings/issues/62
#1 - c4-pre-sort
2023-10-13T12:49:45Z
141345 marked the issue as sufficient quality report
#2 - c4-judge
2023-10-24T15:50:55Z
hansfriese marked the issue as grade-b
🌟 Selected for report: polarzero
Also found by: 0x3b, 0xSmartContract, 0xnev, ABA, Bulletprime, J4X, Limbooo, MrPotatoMagic, SBSecurity, Sathish9098, asui, d3e4, hyh, ihtishamsudo, inzinko, marchev, pfapostol, radev_sw, rahul, ro1sharkm
10.6913 USDC - $10.69
This code snippet is part of a utility contract that allows delegators to pick multiple delegates for an ERC20 token. It involves complex interactions with ERC20Votes and ERC1155 standards. The code aims to improve the delegation process for token holders.
The analysis below highlights critical aspects and potential improvements.
The evaluation involves a line-by-line analysis of the code, considering best practices, standards, and potential issues. The focus is on code quality, security, and usability with relevant contracts from OpenZeppelin lib and some ENS implementation contracts.
Some testing was established to validate a variant attack scenarios as follow but not limited to:
Reentarcy over delegateMulti
,
ERC20 transfer over ERC20ProxyDelegator
before and after creation,
Trying to build complex duplicate sources and targets as delegate batches,
Multilevel delegating over a deployed proxy delegators.
Excellency approach was used to validate the msg.sender
balances by relaying on ERC1155 implementation upon burning and minting, some of execution like when transferring between proxy delegators it check sender balance of the source proxy delegator while it will be prevented when ERC1155 burn batch executed.
The contract deploys proxy delegators for each delegate address when needed. It follows a standard pattern for deploying a contract with a deterministic address based on the contract's creation code and other parameters. The code ensures that a proxy delegator contract is created for each unique combination of _token
and _delegate
without the risk of deploying duplicate contracts with the same combination of arguments.
While there is no risks found here, but the code dose not limit user interactions like delegating to target zero, or transferring between duplicate addresses. If an attacker provides duplicate entries in the sources or targets arrays, the contract will process transfers for the same amount of tokens as specified in the amounts array. The contract won't create extra tokens, and if the source delegate doesn't have enough tokens to cover the specified amount, the transaction will revert. Even though, the attacker will not receive extra tokens, but the transfers may still occur as intended, or they may revert due to insufficient funds in the source delegate's balance. However The key concern in such cases is more about the potential for confusion and unintended behavior.
Pausable Mechanism: Implement a pausable mechanism to allow emergency halting of specific functions for added security and control. Pausability is crucial in smart contracts.
User Experience Enhancements: Improve the user experience by implementing additional user notifications or feedback mechanisms to keep users informed about the status of their delegations or token transfers.
ERC1155 Approved Operators: Consider implementing support for ERC1155 approved operators. This feature allows token holders to authorize specific addresses as operators to perform token delegation on their behalf. This enhancement can simplify delegation and provide more control to token holders, enhancing the user experience.
Consistency with ERC Standards: Ensure that the codebase remains consistent with the latest versions of relevant ERC standards, such as ERC20, ERC1155, and ERC20Votes.
The code structure is well-organized, following OpenZeppelin standards.
Function and variable names are descriptive, enhancing readability.
It uses OpenZeppelin libraries and adheres to recognized standards. Updating to latest version will enhance security and gas usage.
Code duplication for event emission can be reduced by optimizing event emission in specific scenarios, such as same-source-and-target transfers.
ERC20ProxyDelegator
without recovery mechanisms. Users need to be cautious when interacting with proxy delegators.Ensure that users are aware of the potential for losing tokens when transferring them directly to ERC20ProxyDelegators.
Enhance user experience by adding mechanisms to recover tokens sent directly to ERC20ProxyDelegators, maybe fixing this will lead to inheriting ERC1155Supply
.
The ERC20MultiDelegate
code is well-structured and adheres to recognized standards. It simplifies delegation for token holders but comes with centralization and token loss risks. Implementing a pausable mechanism and optimizing event emission can enhance the codebase.
16 hours
#0 - c4-pre-sort
2023-10-14T08:44:45Z
141345 marked the issue as sufficient quality report
#1 - c4-judge
2023-10-24T16:45:04Z
hansfriese marked the issue as grade-b