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

TokenSender contract will not send anything even if it needs to #235

Closed
code423n4 opened this issue Dec 12, 2022 · 3 comments
Closed

TokenSender contract will not send anything even if it needs to #235

code423n4 opened this issue Dec 12, 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-257 partial-50 Incomplete articulation of vulnerability; eligible for partial credit only (50%)

Comments

@code423n4
Copy link
Contributor

Lines of code

https://github.com/prepo-io/prepo-monorepo/blob/3541bc704ab185a969f300e96e2f744a572a3640/apps/smart-contracts/core/contracts/TokenSender.sol#L41

Vulnerability details

Impact

TokenSender contract is used to reimburse user fees. But if the balance of PPO token inside the contract is low it can happen that the user don't get any token even if there is some to be sent.

Proof of Concept

If the calculated token amount to send is more that is in the contract balance we simply don't send any

https://github.com/prepo-io/prepo-monorepo/blob/3541bc704ab185a969f300e96e2f744a572a3640/apps/smart-contracts/core/contracts/TokenSender.sol#L41

Tools Used

Manual review

Recommended Mitigation Steps

At least two options

  • revert instead of just return; to signal that the TokenSender contract is low on balance. Admin should tip the contract so repeating call will not fail
  • return the difference of outputAmount and the token balance. Something like this:
    if (outputAmount == 0) return;
-   if (outputAmount > _outputToken.balanceOf(address(this))) return;
+    if (_outputToken.balanceOf(address(this) == 0) revert("need token refill"); // OR just return 0 but then the problem remains
+   if (outputAmount > _outputToken.balanceOf(address(this)))  {
+       outputAmount -= _outputToken.balanceOf(address(this); //send what you can      
+   }

    _outputToken.transfer(recipient, outputAmount);
@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 12, 2022
code423n4 added a commit that referenced this issue Dec 12, 2022
@c4-judge
Copy link
Contributor

Picodes marked the issue as duplicate of #257

@c4-judge
Copy link
Contributor

c4-judge commented Jan 7, 2023

Picodes marked the issue as partial-50

@c4-judge c4-judge added the partial-50 Incomplete articulation of vulnerability; eligible for partial credit only (50%) label Jan 7, 2023
@Picodes
Copy link

Picodes commented Jan 7, 2023

The impact does not explain why in this context this is an issue. As the rebate is optional the described behavior could make sense, so the explanation needs to be more detailed.

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-257 partial-50 Incomplete articulation of vulnerability; eligible for partial credit only (50%)
Projects
None yet
Development

No branches or pull requests

3 participants