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

1 stars 1 forks source link

Division by 0 totalWeights #205

Closed code423n4 closed 2 years ago

code423n4 commented 2 years ago

Handle

pauliax

Vulnerability details

Impact

totalWeights might be zero and this will cause division by 0 runtime error. function _computeShareCount divides by _totalWeights:

  return (_amount * _weight) / _totalWeights;

Admin can accidentaly set totalWeights to 0 in function setRoyaltiesWeight when totalWeights = royaltiesWeight and _weight = 0.

Recommended Mitigation Steps

Consider algorithmitcally enforcing totalWeights > 0 or handle this special case in function _computeShareCount.

adrien-supizet commented 2 years ago

duplicate #43