Wrong validation checks
Duplicate and missing validation checks across initiatePayment and registerSubscription: validity timestamps are checked twice, amount zero-check is duplicated across contracts, and there is no enforcement that validUntil > validAfter.
Description
-
The
processPayment()performs validation checks forvalidAfterandvalidUntilproperties but these checks are already performed in theinitiatePayment()function that executesprocessPayment(). -
When registering a subscription
_validUntilshould be enforced to be larger than_validAfterwhich is set toblock.timestamp, to ensure that the newly created subscription is valid. -
When registering a subscription in the
createSubscription()function in theSubExecutor.solcontract there is a zero-address check for theamountbut this check is already performed in theregisterSubscription()function inInitiator.solcontract which is executed internally.
/// @notice Initiates a payment for a given subscriber/// @param _subscriber Address of the subscriber/// @dev This function ensures that the subscription is active and the/// payment interval has been reachedfunction initiatePayment(address _subscriber) public nonReentrant {require(subscription.validUntil > block.timestamp, "Subscription is not active");require(subscription.validAfter < block.timestamp, "Subscription is not active");}
Impact
Redundant gas usage on every payment call, and a missing invariant check that allows nonsensical subscriptions with validUntil <= validAfter to be registered.
Recommendation
-
Consider removing the duplicated validation checks:
difffunction initiatePayment(address _subscriber) public nonReentrant {- require(subscription.validUntil > block.timestamp, "Subscription is not active");- require(subscription.validAfter < block.timestamp, "Subscription is not active");}- require(_amount > 0, "Subscription amount is 0"); -
Add the following validation check in the
registerSubscription()function, and consider setting a minimum subscription's validity period as well:diff+ require(_validUntil > _validAfter, "Wrong subscription's timestamp validity");
Resolution
Team Response: Acknowledged and fixed as suggested.

