Skip to content
Access control Audit finding Intermediate

Depositor can spend funds of another Depositor

The depositBribeERC20 function in BribeVault.sol allows a depositor to specify an arbitrary briber address, so a malicious depositor could transfer another user's approved tokens without their knowledge. The function also lacks checks for expired proposals and allows mismatched reward and bribe identifiers, leading to incorrect state updates.

Anurag Jain Follow

Originally disclosed on Code4rena

Submitted by csanuragjain

  1. One depositor can spend funds of another depositor
  2. Depositor can deposit in expired proposal
  3. rewardIdentifier and bribeIdentifier can point to different rounds/tokens

Proof of Concept

One depositor can spend funds of another depositor:

  1. Malicious depositor can call depositBribeERC20 at BribeVault.sol#L164 with briber as User B (Malicious user can generate bribeIdentifier with his own proposal)
  2. Assume this User B has approved amount x to this contract
  3. BribeVault.sol#L187 (IERC20(token).safeTransferFrom(briber, address(this), amount);) will transfer this amount x to the contract due to call at step 1. All this happen without User B knowledge

Expired Proposal:

  1. Malicious depositor can generate bribeIdentifier of an expired proposal (proposalDeadlines[proposal] < block.timestamp) using generateBribeVaultIdentifier at TokemakBribe.sol#L166
  2. Malicious depositor can then simply call depositBribeERC20 at BribeVault.sol#L164
  3. Since there is no deadline check and this function blindly trusts bribeIdentifier, user deposit will be success even though the associated proposal already expired

RewardIdentifier and bribeIdentifier can point to different rounds/tokens:

  1. Similar to expired proposal, depositor can generate bribeIdentifier and RewardIdentifier with different tokens and rounds.
  2. Depositor now calls epositBribeERC20 at BribeVault.sol#L164 with the generated bribeIdentifier and RewardIdentifier
  3. rewardToBribes[rewardIdentifier].push(bribeIdentifier); will update reward for round x and bribeIdentifier will point to round y which is incorrect

Recommended Mitigation Steps

depositBribeERC20 at BribeVault.sol#L164 should only be allowed to be called via TokemakBribe.sol

kphed (Redacted Cartel) disputed and commented:

depositBribeERC20 at BribeVault.sol#L164 should only be allowed to be called via TokemakBribe.sol

Only those with the “depositor” role can call the deposit bribe methods (depositBribeERC20 and depositBribe). We only grant the role to bribe contracts we own such as TokemakBribe.sol.

Thanks again for participating in our contest csanuragjain, looking forward to more feedback/suggestions/comments.

Alex the Entreprenerd (judge) decreased severity to Medium and commented:

While the finding is similar to M-02, I believe this more eloquently shows the specific types of admin privileges that the DEPOSITOR_ROLE has for the function depositBribeERC20.

Ultimately the finding is highlighting how things can go wrong and how the DEPOSITOR_ROLE provides a high level of admin privilege.

Because this is contingent on a malicious admin, I believe Medium Severity to be more appropriate.


The original report as published on Code4rena, by csanuragjain. Images and videos are our own copies; raw HTML is shown as text. View it on Code4rena.

Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.

How it worked

Root cause

Likely the depositBribeERC20 function trusts the caller-supplied briber address and bribeIdentifier without validating that the caller is authorised for that briber or that the proposal is active and matches the rewardIdentifier.

Impact

A malicious depositor could spend another user's approved funds and create incorrect reward-to-bribe mappings, but the project disputed this because only trusted bribe contracts are granted the depositor role.

What the attacker needed

The attacker has the depositor role; the victim has approved tokens to the contract

The fix

The function should only be callable by trusted bribe contracts, as the project states it already restricts the depositor role to such contracts.

How it was found

  1. A malicious depositor calls depositBribeERC20 with the briber set to another user's address.
  2. The other user has already approved the contract to spend some amount of tokens.
  3. The contract transfers that amount from the other user to itself without their knowledge.
  4. The depositor can also generate a bribeIdentifier for an expired proposal and call depositBribeERC20, which succeeds because there is no deadline check.
  5. The depositor can generate a bribeIdentifier and rewardIdentifier pointing to different rounds or tokens and call depositBribeERC20, causing rewardToBribes to be updated incorrectly.

Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.

Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.

A depositor is someone allowed to add funds to a contract. The contract lets them say who the money comes from, so a bad depositor could take money from someone else who had approved the contract. The contract also doesn't check if a proposal is still active or if the reward and bribe identifiers match.

What is Access control?

A user can do something their role should not allow: reach an admin function, act on a feature they have not paid for, or skip a permission check. IDOR is the special case where the object belongs to someone else.

More by Anurag Jain

View all

63 more disclosed reports, best first.

More from Redacted Cartel contest

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Broken access control

The lesson behind this report.

A user can do something their role should not allow: reach an admin function, act on a feature they have not paid for, or skip a permission check. IDOR is the special case where the object belongs to someone else.