sherlock-audit / 2023-12-dodo-gsp-judging

6 stars 5 forks source link

XDZIBEC - Missing Lower Bound Check for Parameter k in init Function #76

Closed sherlock-admin closed 9 months ago

sherlock-admin commented 9 months ago

XDZIBEC

medium

Missing Lower Bound Check for Parameter k in init Function

Summary

see vulnerability details

Vulnerability Detail

in the function init exactlly this part :

// k should be greater than 0 and less than 1018
require(k <= 1018);
K = k;

here the k should be both greater than 0 and less than 10^18, and the require statement only checks that k is less than or equal to 10^18, and does not verify that k is greater than 0, the problem is k being zero would negatively affect the contract execution.
this is the expected code require(k > 0 && k <= 10**18, “Invalid K value: must be greater than 0 and less than or equal to 1e18”)

Impact

Code Snippet

nevillehuang commented 9 months ago

Invalid, admin/deployer are trusted to input the appropriate parameters, this seems to be just a missing sanity check