#37315 [SC-High] Theft of Unclaimed Yields Due to Improper Reward Distribution in Vault Program

Submitted on Dec 2nd 2024 at 06:40:54 UTC by @GlitchLens for Audit Comp | Jito Restaking

  • Report ID: #37315

  • Report Type: Smart Contract

  • Report severity: High

  • Target: https://github.com/jito-foundation/restaking/tree/master/vault_program

  • Impacts:

    • Theft of unclaimed yield

Description

Brief/Intro

The vault program suffers from a vulnerability in its reward distribution mechanism where the UpdateVaultBalance function is not enforced before minting or other actions involving vault.deposited_tokens. This allows an attacker to mint tokens immediately after rewards are deposited but before the balance update, enabling them to unfairly claim a portion of the rewards they did not contribute to. Exploiting this could result in financial losses for legitimate depositors and enable theft of unclaimed yields.

Vulnerability Details

The vulnerability lies in the lack of enforcement for calling UpdateVaultBalance before performing operations like mint_to. This causes an inaccurate calculation of rewards:

  1. When rewards are deposited into the vault, they are initially unclaimed and stored in the vault's token account.

  2. If a new depositor mints tokens before the balance update, they are included in the reward distribution calculation.

  3. This results in the redistribution of existing rewards, allowing the new depositor to claim unclaimed yields they are not entitled to.

For example:

  • Depositor1 deposits 10,000 tokens.

  • Rewards of 1,000 tokens are added to the vault, intended entirely for Depositor1.

  • Depositor2 mints tokens before UpdateVaultBalance is called.

  • The rewards are recalculated to include Depositor2, diverting a portion of Depositor1's rightful share.

Impact Details

  • Theft of Unclaimed Yield: Attackers can exploit the system to claim rewards they did not contribute to, directly stealing unclaimed yields.

  • Financial Loss: Legitimate depositors lose a portion of their entitled rewards, resulting in direct monetary losses.

References

https://github.com/jito-foundation/restaking/blob/master/vault_program/src/mint_to.rs https://github.com/jito-foundation/restaking/blob/master/vault_program/src/update_vault_balance.rs

Proof of Concept

Proof of Concept

In the provided PoC:

  • Depositor1 deposits 10,000 tokens and is entitled to 1,000 tokens in rewards.

  • Depositor2 mints an equivalent amount before UpdateVaultBalance is called.

  • Upon withdrawal, Depositor1 receives only 10,500 tokens instead of the expected 11,000, demonstrating a loss of 500 tokens due to theft of unclaimed yield.

yield_theft.rs

running the poc with cargo test give the following output

Last updated

Was this helpful?