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

transferTokens should use _from instead of msg.sender #57

Open
code423n4 opened this issue Dec 13, 2021 · 0 comments
Open

transferTokens should use _from instead of msg.sender #57

code423n4 opened this issue Dec 13, 2021 · 0 comments
Labels
1 (Low Risk) Assets are not at risk. State handling, function incorrect as to spec, issues with comments bug Something isn't working sponsor confirmed Sponsor agrees this is a problem and intends to fix it (OK to use w/ "disagree with severity")

Comments

@code423n4
Copy link
Contributor

Handle

gpersoon

Vulnerability details

Impact

The function transferTokens of SavingsAccountUtil.sol sends the excess ETH to msg.sender, while a _from parameter is also present in the function.
It seems more logical to send it to _from, like the similar function _transferTokens of Repayments.sol

Luckily in the current code the _from is always msg.sender so it doesn't pose a direct risk.
However if the code is reused or forked it might lead to unexpected issues.

Note: transferTokens and _transferTokens are very similar so they could be integrated; they have to be checked carefully when doing this

Proof of Concept

https://github.com/code-423n4/2021-12-sublime/blob/e688bd6cd3df7fefa3be092529b4e2d013219625/contracts/SavingsAccount/SavingsAccountUtil.sol#L98-L127

function transferTokens(.... ,   address _from,   address _to ) {
     ...
       (bool success, ) = payable(address(msg.sender)).call{value: msg.value - _amount}(''); // uses msg.sender instead of _from // also uses - instead of sub

https://github.com/code-423n4/2021-12-sublime/blob/e688bd6cd3df7fefa3be092529b4e2d013219625/contracts/Pool/Repayments.sol#L457-L473

    function _transferTokens(  address _from,  address _to,.... ) {
       (bool refundSuccess, ) = payable(_from).call{value: msg.value.sub(_amount)}('');

Tools Used

Recommended Mitigation Steps

In function transferTokens() change msg.sender to _from

@code423n4 code423n4 added 1 (Low Risk) Assets are not at risk. State handling, function incorrect as to spec, issues with comments bug Something isn't working labels Dec 13, 2021
code423n4 added a commit that referenced this issue Dec 13, 2021
@ritik99 ritik99 added the sponsor confirmed Sponsor agrees this is a problem and intends to fix it (OK to use w/ "disagree with severity") label Dec 23, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
1 (Low Risk) Assets are not at risk. State handling, function incorrect as to spec, issues with comments bug Something isn't working sponsor confirmed Sponsor agrees this is a problem and intends to fix it (OK to use w/ "disagree with severity")
Projects
None yet
Development

No branches or pull requests

2 participants