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

ETH can be accidentally sent with ERC20 in sendOutTokenOrETH function #507

Closed
code423n4 opened this issue Nov 10, 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-355 partial-50

Comments

@code423n4
Copy link
Contributor

Lines of code

https://github.com/debtdao/Line-of-Credit/blob/audit/code4rena-2022-11-03/contracts/utils/LineLib.sol#L34-L51

Vulnerability details

Impact

ETH can be accidentally sent with ERC20 in sendOutTokenOrETH function

User who wants to send ERC20 due to payable function can write a value in the value field

Proof of Concept

contracts/utils/LineLib.sol:
  33       */
  34:     function sendOutTokenOrETH(
  35:       address token,
  36:       address receiver,
  37:       uint256 amount
  38:     )
  39:       external
  40:       returns (bool)
  41:     {
  42:         if(token == address(0)) { revert TransferFailed(); }
  43:         
  44:         // both branches revert if call failed
  45:         if(token!= Denominations.ETH) { // ERC20
  46:             IERC20(token).safeTransfer(receiver, amount);
  47:         } else { // ETH
  48:             payable(receiver).transfer(amount);
  49:         }
  50:         return true;
  51:     }

Recommended Mitigation Steps

ETH can be sent by mistake with ERC20 in sendOutTokenOrETH function, it is enough to add a simple require to prevent this

@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 10, 2022
code423n4 added a commit that referenced this issue Nov 10, 2022
@c4-judge
Copy link
Contributor

dmvt marked the issue as duplicate of #89

@c4-judge
Copy link
Contributor

dmvt marked the issue as partial-50

@C4-Staff
Copy link
Contributor

liveactionllama marked the issue as duplicate of #355

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-355 partial-50
Projects
None yet
Development

No branches or pull requests

3 participants