code-423n4 / 2021-11-streaming-findings

0 stars 0 forks source link

unstreamed variable is not updated in withdraw function #224

Closed code423n4 closed 2 years ago

code423n4 commented 2 years ago

Handle

csanuragjain

Vulnerability details

Impact

Contract variable unstreamed is not updated in withdraw function which can lead to unstability

Proof of Concept

  1. Observe the stake function of Stream contract
function stake(uint112 amount) public lock updateStream(msg.sender) {

...

unstreamed += trueDepositAmt;
...
}
  1. As we can see once user stakes the unstreamed variable is increased by user's stake amount

  2. Now lets see the withdraw function. This function does not decrease the unstreamed variable by user withdrawn amount bringing contract variable to instability.

Recommended Mitigation Steps

Add below statement in withdraw function

unstreamed -= trueDepositAmt;
0xean commented 2 years ago

dupe of #118