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

Excess ETH should be returned #94

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

Excess ETH should be returned #94

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-39 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#L71

Vulnerability details

Impact

Only msg.value > amount is allowed here, but the excess(msg.value - amount) is not returned to the user.

Proof of Concept

    function receiveTokenOrETH(
      address token,
      address sender,
      uint256 amount
    )
      external
      returns (bool)
    {
        if(token == address(0)) { revert TransferFailed(); }
        if(token != Denominations.ETH) { // ERC20
            IERC20(token).safeTransferFrom(sender, address(this), amount);
        } else { // ETH
            if(msg.value < amount) { revert TransferFailed(); } // @audit  
        }
        return true;
    }

Tools Used

vscode

Recommended Mitigation Steps

payable(sender).transfer(msg.value - amout);
@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 #25

@c4-judge
Copy link
Contributor

dmvt marked the issue as partial-50

@C4-Staff
Copy link
Contributor

liveactionllama marked the issue as duplicate of #39

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

No branches or pull requests

3 participants