Similar functions from VotingEscrow have different permissions
Summary
The two functions deposit_for and increase_amount contain similar implementations. However, one of them requires the caller to be either the owner or an approved spender, while the other doesn't.
Vulnerability Detail
Besides the initial assertion of the increase_amount function, the two functions do the exact same thing. Initially, they both verify for a greater than zero value and for an existing, non-expired lock. The only difference is that the increase_amount implementation uses assert instead of require for the value check.
They end up by calling _deposit_for with an almost identical set of parameters, the only difference being the final variable, the deposit type. However, by looking at the deposit_forimplementation, the only difference is in the emitted event, that is not used by the implementation.
Therefore, there's no reason to have the approved spender / owner check in the increased_amount function, as an user can bypass it by calling the deposit_for function.
Impact
Low - inconsisten API.
Code Snippet
The implementation of the two functions, for ease of review:
Funny Merlot Yeti
Low/Info
Similar functions from VotingEscrow have different permissions
Summary
The two functions
deposit_for
andincrease_amount
contain similar implementations. However, one of them requires the caller to be either the owner or an approved spender, while the other doesn't.Vulnerability Detail
Besides the initial assertion of the
increase_amount
function, the two functions do the exact same thing. Initially, they both verify for a greater than zero value and for an existing, non-expired lock. The only difference is that theincrease_amount
implementation usesassert
instead ofrequire
for the value check. They end up by calling_deposit_for
with an almost identical set of parameters, the only difference being the final variable, the deposit type. However, by looking at thedeposit_for
implementation, the only difference is in the emitted event, that is not used by the implementation.Therefore, there's no reason to have the approved spender / owner check in the
increased_amount
function, as an user can bypass it by calling thedeposit_for
function.Impact
Low - inconsisten API.
Code Snippet
The implementation of the two functions, for ease of review:
Tool used
Manual Review
Recommendation
Either remove the
require
forincrease_amount
, or add it for thedeposit_for
function.