Skip to content
Access control Audit finding Intermediate

Improper implementation of arbitraryCall() allows protocol gov to steal funds from users’ wallets

The arbitraryCall function allows the protocol governor to call any contract with any data, and because the incentive token address is not blocked after an incentive is claimed, a malicious or compromised governor could use transferFrom to steal users' tokens up to their allowance.

WatchPug Follow

Originally disclosed on Code4rena

Submitted by WatchPug, also found by Jujic and hack3r-0m

https://github.com/code-423n4/2021-11-streaming/blob/56d81204a00fc949d29ddd277169690318b36821/Streaming/src/Locke.sol#L733-L735

function arbitraryCall(address who, bytes memory data) public lock externallyGoverned {
    // cannot have an active incentive for the callee
    require(incentives[who] == 0, "inc");
    ...

When an incentiveToken is claimed after endStream, incentives[who] will be 0 for that incentiveToken.

If the protocol gov is malicious or compromised, they can call arbitraryCall() with the address of the incentiveToken as who and transferFrom() as calldata and steal all the incentiveToken in the victim’s wallet balance up to the allowance amount.

Proof of Concept

  1. Alice approved USDC to the streaming contract;
  2. Alice called createIncentive() and added 1,000 USDC of incentive;
  3. After the stream is done, the stream creator called claimIncentive() and claimed 1,000 USDC;

The compromised protocol gov can call arbitraryCall() and steal all the USDC in Alice’s wallet balance.

Recommendation

Consider adding a mapping: isIncentiveToken, setting isIncentiveToken[incentiveToken] = true in createIncentive(), and require(!isIncentiveToken[who], ...) in arbitraryCall().

brockelmore (Streaming Protocol) confirmed

The original report as published on Code4rena, by WatchPug. 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 arbitraryCall function only checks that the target address has no active incentive, but after an incentive is claimed the mapping is set to zero, so the incentive token address is no longer blocked.

Impact

A malicious or compromised protocol governor could steal all incentive tokens from users' wallets up to the allowance amount.

What the attacker needed

Compromised or malicious protocol governor; user has approved tokens to the contract

The fix

The fix should add a mapping to track incentive tokens and require that the target address is not an incentive token in arbitraryCall.

How it was found

  1. Alice approved USDC to the streaming contract
  2. Alice called createIncentive() and added 1,000 USDC of incentive
  3. After the stream is done, the stream creator called claimIncentive() and claimed 1,000 USDC
  4. The compromised protocol gov can call arbitraryCall() and steal all the USDC in Alice’s wallet balance

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.

The protocol has a special function that lets the governor make arbitrary calls to other contracts. After a user claims their incentive, the contract forgets that the token was used for incentives, so the governor can call that token's transferFrom function to move the user's tokens. This means a bad governor could take tokens from users who have approved the contract.

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 WatchPug

View all

197 more disclosed reports, best first.

More from Streaming Protocol 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.