veRWA - 0xStalin's results

Incentivization Primitive for Real World Assets on Canto

General Information

Platform: Code4rena

Start Date: 07/08/2023

Pot Size: $36,500 USDC

Total HM: 11

Participants: 125

Period: 3 days

Judge: alcueca

Total Solo HM: 4

Id: 274

League: ETH

Canto

Findings Distribution

Researcher Performance

Rank: 109/125

Findings: 1

Award: $4.23

QA:
grade-b

🌟 Selected for report: 0

🚀 Solo Findings: 0

Lines of code

https://github.com/code-423n4/2023-08-verwa/blob/main/src/LendingLedger.sol#L188-L199

Vulnerability details

Impact

  • Some users may won't be able to claim their corresponding rewards for some epochs if the total amount of rewards that was allocated for the epochs doesn't match or is less than the total CANTO balance in the contract

Proof of Concept

  • Rewards can be set to any amount for different epochs, but there are no checks to enforce if there is enough CANTO to back up the total allocated rewards for the specified ephocs.

  • The consequence of not enforcing that the rewards are really fully back up with CANTO tokens are that epochs can run out of rewards before all the users have claimed their corresponding rewards, thus, some users will lost their rewards.

  • The only way this contract can receive CANTO tokens is by directly depositing them using the LendingLedger::receive(), but this function also doesn't validate if the amount of CANTO tokens been deposited are enough to fully back up the total rewards allocated for all the epochs for all the users.

    • Governance could send a tremendous huge number of CANTO tokens and just leave them sitting there in the contract, but that might not be the most optimal approach since those tokens would be basically doing nothing in the contract, those tokens could be used in other things to generate some yield overtime.
  • The most optimal approach is to ensure that all the allocated rewards for all the epochs are fully backed up by CANTO tokens, the contract should have a 100% of the rewards to be distributed, not more not less.

Tools Used

Manual Audit

  • When setting the rewards also force the deposit of all the rewards that are been allocated.
  • Make payable this function and validate that the total amount of rewards allocated for all the epochs matches the total CANTO (native token) that was sent alongside this call
+ function setRewards(....) .... payable {
+   uint256 totalAllocatedRewards = 0;
    for(...){
      ...
+     totalAllocatedRewards += _amountPerEpoch;
    }

+   //If msg.value is greather than the total allocated rewards, refund the excess
+   if(msg.value > totalAllocatedRewards) {
+       uint refundExcess = msg.value - totalAllocatedRewards;
+       (bool success, ) = msg.sender.call{refundExcess}("");
+       require(success, "Failed to send CANTO");
+   } else {
+       revert("Not enough CANTO tokens were sent to back up all the allocated rewards for all the epochs");
+   }
  }

Assessed type

Invalid Validation

#0 - c4-pre-sort

2023-08-13T02:51:43Z

141345 marked the issue as primary issue

#1 - 141345

2023-08-13T02:52:19Z

privileged role mistake

QA might be more appropriate.

#2 - c4-sponsor

2023-08-16T14:57:58Z

OpenCoreCH marked the issue as sponsor acknowledged

#3 - OpenCoreCH

2023-08-16T14:58:18Z

True, but intended behaviour, as governance should send CANTO to the contract separately.

#4 - c4-judge

2023-08-24T21:28:56Z

alcueca changed the severity to QA (Quality Assurance)

#5 - c4-judge

2023-08-24T21:29:00Z

alcueca 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