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

_handleCloseFees returns a _payout that does not account for referral fees #382

Closed
code423n4 opened this issue Dec 16, 2022 · 3 comments
Closed
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 satisfies C4 submission criteria; eligible for awards

Comments

@code423n4
Copy link
Contributor

Lines of code

https://github.com/code-423n4/2022-12-tigris/blob/588c84b7bb354d20cbca6034544c4faa46e6a80e/contracts/Trading.sol#L805

Vulnerability details

Impact

Payout calculated on closing a trade accounts for daoFees, burnFees, botFees but misses referralFees. This means that payout to trader is higher than what it is supposed to be. Since the error concerns payments to users, I have classified it as High Risk finding

Payout is calculated in line 805 as follows

        payout_ = _payout - _daoFeesPaid - _burnFeesPaid - _botFeesPaid;

Above formula can also be written as

payout_ = _payout - (daoFeesPaid + burnFeesPaid + botFeesPaid)

Note that _daoFeesPaid variable in above formula has already accounted for

  • 2*_referralFeesPaid that is already subtracted
  • _botFeesPaid that is also subtracted

current formula adds back _botFeesPaid to daoFeesPaid but the 2*_referralPaid that was earlier subtracted from daoFeesPaid is not added -> so the payout_ computed will always be higher than the actual value

Recommended Mitigation Steps

Use formula below for line 805

payout_ = _payout - (daoFeesPaid + burnFeesPaid + botFeesPaid + 2* _referralFeesPaid);
@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 Dec 16, 2022
code423n4 added a commit that referenced this issue Dec 16, 2022
@c4-judge
Copy link
Contributor

GalloDaSballo marked the issue as duplicate of #476

@c4-judge c4-judge added the satisfactory satisfies C4 submission criteria; eligible for awards label Jan 22, 2023
@c4-judge
Copy link
Contributor

GalloDaSballo marked the issue as satisfactory

@c4-judge
Copy link
Contributor

GalloDaSballo 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 satisfies C4 submission criteria; eligible for awards
Projects
None yet
Development

No branches or pull requests

2 participants