Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fee-on-transfer / rebasing tokens lead to errors #123

Closed
code423n4 opened this issue Nov 7, 2022 · 3 comments
Closed

Fee-on-transfer / rebasing tokens lead to errors #123

code423n4 opened this issue Nov 7, 2022 · 3 comments
Labels
2 (Med Risk) Assets not at direct risk, but function/availability of the protocol could be impacted or leak value bug Something isn't working duplicate-367 satisfactory Finding meets requirement

Comments

@code423n4
Copy link
Contributor

Lines of code

https://github.com/debtdao/Line-of-Credit/blob/d7ef66035ddf873b0c96804a1c9deeebb1f798ea/contracts/utils/LineLib.sol#L69
https://github.com/debtdao/Line-of-Credit/blob/f32cb3eeb08663f2456bf6e2fba21e964da3e8ae/contracts/utils/SpigotLib.sol#L38

Vulnerability details

Impact & Proof Of Concept

The function LineLib.receiveTokenOrETH that is used in multiple places assumes that the requested transfer amount is also equal to the actual transferred amount:

if(token != Denominations.ETH) { // ERC20
            IERC20(token).safeTransferFrom(sender, address(this), amount);
}

This is not true for fee-on-transfer tokens, where the change in balance is smaller than the requested amount. This leads to problems in multiple places. For instance, in LineOfCredit.addCredit, the amount parameter is used to create the credit:

LineLib.receiveTokenOrETH(token, lender, amount);

bytes32 id = _createCredit(lender, token, amount);

When the contract does not contain this amount, there are two options:
1.) Payouts that should be possible are not possible (because the balance is not sufficient).
2.) Funds from other users are used for payouts.

Another big problem for the system are rebasing tokens. This can cause an underflow in SpigotLib._claimRevenue (because the balance is now smaller than the previously cached balance), making all calls to claim revenue revert:

uint256 existingBalance = LineLib.getBalance(token);
...

claimed = existingBalance - self.escrowed[token];

Recommended Mitigation Steps

Check the actual amount that was transferred (i.e., the difference of the balances).

@code423n4 code423n4 added 2 (Med Risk) Assets not at direct risk, but function/availability of the protocol could be impacted or leak value bug Something isn't working labels Nov 7, 2022
code423n4 added a commit that referenced this issue Nov 7, 2022
@c4-judge
Copy link
Contributor

dmvt marked the issue as duplicate of #26

@c4-judge
Copy link
Contributor

c4-judge commented Dec 6, 2022

dmvt marked the issue as satisfactory

@c4-judge c4-judge added the satisfactory Finding meets requirement label Dec 6, 2022
@C4-Staff
Copy link
Contributor

liveactionllama marked the issue as duplicate of #367

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
2 (Med Risk) Assets not at direct risk, but function/availability of the protocol could be impacted or leak value bug Something isn't working duplicate-367 satisfactory Finding meets requirement
Projects
None yet
Development

No branches or pull requests

3 participants