Lucene search

K
code423n4Code4renaCODE423N4:2022-03-BICONOMY-FINDINGS-ISSUES-181
HistoryMar 16, 2022 - 12:00 a.m.

Sending tokens close to the maximum will fail and user will lose tokens

2022-03-1600:00:00
Code4rena
github.com
6
vulnerability
impact
mitigation
liquiditypool contract
tokens limit

Lines of code
<https://github.com/code-423n4/2022-03-biconomy/blob/04751283f85c9fc94fb644ff2b489ec339cd9ffc/contracts/hyphen/LiquidityPool.sol#L273&gt;

Vulnerability details

Impact

Detailed description of the impact of this finding.

Proof of Concept

When a user calls the deposit function the reward amount is calculated and an event is emited with amount+reward as the transfer amount. The function checks amount is smaller than the max amount.

An executor then listens to this event and calls sendFundsToUser with rewards + amount as the amount parameter. This function checks amount+reward is smaller than max amount.

This is a problem because the amount transferred may be in the limit but amount + reward could pass the limit and the executor won’t be able to send the transaction. The user will lose the funds. Both checks should be made with the reward or without the reward but the checks should be the same for this not to happen.

Step by step :
Max transfer is set to 50 for token A
Bob transfers 49 tokens, this will pass since 49<50. The reward is calculated in 2 tokens.
The executor then calls sendFundsToUser with 52. This transaction will revert and user will lose their tokens.

This value of amount includes rewards but the previous check didn’t include rewards:
<https://github.com/code-423n4/2022-03-biconomy/blob/04751283f85c9fc94fb644ff2b489ec339cd9ffc/contracts/hyphen/LiquidityPool.sol#L273&gt;

Recommended Mitigation Steps

Both checks should be made over the same amount = amount + rewards


The text was updated successfully, but these errors were encountered:

All reactions