Skip to content
Business logic Audit finding Intermediate

Collateral removal not possible

The protocol has no way to remove a previously approved collateral token. If an approved token later starts charging a fee on transfers, the deposit logic still credits the user with the full amount even though the contract receives less, creating an accounting mismatch.

Anurag Jain Follow with DadeKuma, rbserver and 2 others

Originally disclosed on Code4rena

Submitted by csanuragjain, also found by DadeKuma, rbserver, bytes032, and KIntern_NA

If an approved collateral has later started say taking fees on transfer then protocol has no way to remove such collateral. The current deposit logic cannot handle fee on transfer token and would give more funds to user then actually obtained by contract

Proof of Concept

  1. Assume protocol was supporting collateral X (say USDT which has fee currently set as 0)
  2. After some time collateral introduces fee on transfer
  3. Protocol does not have a way to remove a whitelisted collateral
  4. Problem begins once user starts depositing such collateral
    function _addCollateral(uint256 positionId, uint256 amount) internal {
    ...
    ERC20(shortPosition.collateral).safeTransferFrom(msg.sender, address(this), amount);
            ERC20(shortPosition.collateral).safeApprove(address(shortCollateral), amount);

            shortToken.adjustPosition(
                positionId,
                msg.sender,
                shortPosition.collateral,
                shortPosition.shortAmount,
                shortPosition.collateralAmount + amount
            );
            shortCollateral.collectCollateral(shortPosition.collateral, positionId, amount);
    ...
    }
  1. In this case amount is transferred from user to contract but contract will only receive amount-fees. But contract will still adjust position with full amount instead of amount-fees which is incorrect.

Recommended Mitigation Steps

Add a way to disapprove collateral so that if in future some policy changes for a particular collateral, protocol can stop supporting it. This will it would only have to deal with existing collateral which can be wiped out slowly using public announcement.

Dravee (judge) commented:

Not a duplicate of https://github.com/code-423n4/2023-03-polynomial-findings/issues/178 as Fee-on-transfer tokens are only mentioned as a scenario that may make the protocol want to disapprove a collateral.

Due to a real lack of way to disapprove a collateral, I believe this finding is valid.

mubaris (Polynomial) confirmed


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 protocol lacks a function to disapprove a collateral and its deposit logic credits the full transfer amount without checking the actual balance received.

Impact

The contract could credit users with more collateral than it actually holds, leading to an accounting shortfall.

What the attacker needed

An approved collateral token; the token later charges a transfer fee; a user deposits that token

The fix

The protocol should add a way to disapprove collateral tokens so support can be withdrawn if a token's policy changes.

How it was found

  1. The protocol supports a collateral token that initially has no transfer fee.
  2. Later the token introduces a fee on transfer.
  3. The protocol has no way to remove the whitelisted collateral.
  4. A user deposits the token, and the contract receives less than the amount recorded.

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 collateral token is an asset the protocol accepts as security. Some tokens take a small cut when they are moved (a fee on transfer), so the receiver gets less than the sender sent. Here the protocol had no way to stop accepting a token after approving it, and its deposit code assumed the full amount arrived, so it credited too much.

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 Anurag Jain

View all

63 more disclosed reports, best first.

More from Polynomial 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.