Skip to content
Business logic Audit finding Intermediate

Users with large cooldown s can grief other users

An account with a large cooldown can increase the cooldown of another account by sending it a small amount of tokens, because the receiver's cooldown is recalculated as a weighted average that includes the sender's cooldown. This could delay the victim's ability to transfer or unstake their tokens.

IllIllI Follow

Originally disclosed on Code4rena

Submitted by IllIllI, also found by 0xDjango and csanuragjain

If an account has a large cooldown, that account can grief other accounts that are waiting for their own cooldowns, by sending small amounts to them.

Proof of Concept

Every transfer to an account increases the cooldown

    /** @dev Hook called before any transfer */
    function _beforeTokenTransfer(
        address from,
        address to,
        uint256 amount
    ) internal virtual override {
        if(from != address(0)) { //check must be skipped on minting
            // Only allow the balance that is unlocked to be transfered
            require(amount <= _availableBalanceOf(from), "hPAL: Available balance too low");
        }

        // Update user rewards before any change on their balance (staked and locked)
        _updateUserRewards(from);

        uint256 fromCooldown = cooldowns[from]; //If from is address 0x00...0, cooldown is always 0

        if(from != to) {
            // Update user rewards before any change on their balance (staked and locked)
            _updateUserRewards(to);
            // => we don't want a self-transfer to double count new claimable rewards
            // + no need to update the cooldown on a self-transfer

            uint256 previousToBalance = balanceOf(to);
            cooldowns[to] = _getNewReceiverCooldown(fromCooldown, amount, to, previousToBalance);
        }

HolyPaladinToken.sol#L875-L899

The amount of the increase is proportional to the sender’s cooldown:

        // Default new cooldown, weighted average based on the amount and the previous balance
        return ((amount * _senderCooldown) + (receiverBalance * receiverCooldown)) / (amount + receiverBalance);

HolyPaladinToken.sol#L1130-L1131

Recommended Mitigation Steps

Only allow a total of one cooldown increase when the sender is not the recipient.

Kogaroshi (Paladin) disputed and commented:

As explained in the documentation & the comments for this method, this is required to prevent users to game the system and unstake by skipping the cooldown period. As stated in another Issue of the same kind, this type of behavior, to have an impact on another user cooldown, would require to send an amount of token consequent compared to the receiver balance, acting as a “financial safeguard” against this type of scenario being used frequently.

For another example of this logic, see the stkAAVE system, using the same logic and the same cooldown imapct calculation on transfers.

0xean (judge) commented:

2 — Med: Assets not at direct risk, but the function of the protocol or its availability could be impacted, or leak value with a hypothetical attack path with stated assumptions, but external requirements.

I am going to side with the warden here. I do see the sponsors argument that this attack is expensive to execute, but is certainly feasible. I think this qualifies as a hypothetical attack path with stated assumptions, but external requirements. The external requirements being someone with enough malice to waste their own money to do so.

While there may not be an easy solution to solve this, it’s still a valid risk to raise and for the sponsors to (potentially) disclose to users if there is in fact no way to mitigate it without undesired side effects.


The original report as published on Code4rena, by IllIllI. 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

The receiver's cooldown is set to a weighted average of the sender's cooldown and the receiver's previous cooldown, so any incoming transfer can increase the receiver's cooldown.

Impact

The victim's cooldown could be extended, delaying their ability to transfer or unstake tokens; the sponsor argues the attack is expensive because it requires sending a large amount relative to the receiver's balance.

What the attacker needed

Attacker holds tokens with a large cooldown; attacker sends tokens to victim

The fix

The report recommends allowing only one cooldown increase when the sender is not the recipient, but the sponsor disputed the issue and no fix is confirmed.

How it was found

  1. Have an account with a large cooldown.
  2. Send a small amount of tokens to another account that is waiting for its own cooldown.
  3. The receiver's cooldown increases, delaying their ability to transfer or unstake.

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 cooldown is a waiting period before you can move your tokens. The contract updates your cooldown whenever you receive tokens, mixing in the sender's cooldown. So someone with a long cooldown can send you a tiny amount and make your own cooldown longer, forcing you to wait more.

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 IllIllI

View all

119 more disclosed reports, best first.

More from Paladin - Warden Pledges 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.