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

parameter "who" not used #125

Open
code423n4 opened this issue Dec 5, 2021 · 1 comment
Open

parameter "who" not used #125

code423n4 opened this issue Dec 5, 2021 · 1 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

Comments

@code423n4
Copy link
Contributor

Handle

gpersoon

Vulnerability details

Impact

The function updateStreamInternal(address who) has a parameter "who", which isn't used.
However "TokenStream storage ts = tokensNotYetStreamed[msg.sender];" uses msg.sender, where probably "who" should be used.

Luckily in the current code this doesn't pose any problems however it is misleading and future code updates could introduce a high risk issue due to this.
Because "who" isn't used it is safer and cheaper to remove it. ==> thus I have classified this as a gas optimization

Proof of Concept

https://github.com/code-423n4/2021-11-streaming/blob/56d81204a00fc949d29ddd277169690318b36821/Streaming/src/Locke.sol#L203-L205

function updateStreamInternal(address who) internal {
        require(block.timestamp < endStream , "!stream");
        TokenStream storage ts = tokensNotYetStreamed[msg.sender];

https://github.com/code-423n4/2021-11-streaming/blob/56d81204a00fc949d29ddd277169690318b36821/Streaming/src/Locke.sol#L197-L201

modifier updateStream(address who) {
        // save bytecode space by making it a jump instead of inlining at cost of gas
        updateStreamInternal(who);
        _;
    }

Tools Used

Recommended Mitigation Steps

Remove "who" from updateStreamInternal(), as well as the modifier updateStream() and the functions that use the modier updateStream

@code423n4 code423n4 added bug Something isn't working G (Gas Optimization) labels Dec 5, 2021
code423n4 added a commit that referenced this issue Dec 5, 2021
@0xean
Copy link
Collaborator

0xean commented Jan 16, 2022

Going to move this to low-risk as the incorrect parameter can lead to confusion and function being incorrect to spec

1 — Low: Low: Assets are not at risk. State handling, function incorrect as to spec, issues with comments.

@0xean 0xean added 1 (Low Risk) Assets are not at risk. State handling, function incorrect as to spec, issues with comments and removed G (Gas Optimization) labels Jan 16, 2022
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
Projects
None yet
Development

No branches or pull requests

2 participants