Language: Go
Label: vulnerable
CWE: CWE-20 \u2014 Improper Input Validation
The product receives input or data, but it does
        not validate or incorrectly validates that the input has the
        properties that are required to process the data safely and
        correctly.

Code:
func (o *OnChainVerifier) CheckThresholdSetEvent(
	event *types.SignerThresholdSetEvent,
) error {
	o.mu.RLock()
	defer o.mu.RUnlock()

	if o.log.GetLevel() <= logging.DebugLevel {
		o.log.Debug("checking threshold set event on chain",
			logging.String("contract-address", o.multiSigAddress.Hex()),
			logging.String("event", event.String()),
		)
	}

	filterer, err := multisig.NewMultisigControlFilterer(
		o.multiSigAddress,
		o.ethClient,
	)
	if err != nil {
		o.log.Error("could not instantiate multisig control filterer",
			logging.Error(err))
		return err
	}

	ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
	defer cancel()

	iter, err := filterer.FilterThresholdSet(
		&bind.FilterOpts{
			Start:   event.BlockNumber,
			End:     &event.BlockNumber,
			Context: ctx,
		},
	)
	if err != nil {
		o.log.Error("Couldn't start filtering on signer added event",
			logging.Error(err))
		return err
	}
	defer iter.Close()

	for iter.Next() {
		if o.log.GetLevel() <= logging.DebugLevel {
			o.log.Debug("found threshold set event on chain",
				logging.Uint16("new-threshold", iter.Event.NewThreshold),
			)
		}

		nonce, _ := big.NewInt(0).SetString(event.Nonce, 10)
		if iter.Event.Raw.BlockNumber == event.BlockNumber &&
			uint64(iter.Event.Raw.Index) == event.LogIndex &&
			iter.Event.NewThreshold == uint16(event.Threshold) &&
			nonce.Cmp(iter.Event.Nonce) == 0 {
			// now we know the event is OK,
			// just need to check for confirmations
			return o.ethConfirmations.Check(event.BlockNumber)
		}
	}

	return ErrNoThresholdSetEventFound
}