From 292f03586b5bc51f7a6fd2d650d3512b57d58000 Mon Sep 17 00:00:00 2001 From: Jon Chambers Date: Wed, 10 Jun 2026 11:15:28 -0400 Subject: [PATCH] Add an IP-based rate limiter for adding payment methods for subscriptions --- .../textsecuregcm/controllers/SubscriptionController.java | 4 ++++ .../org/whispersystems/textsecuregcm/limits/RateLimiters.java | 1 + 2 files changed, 5 insertions(+) diff --git a/service/src/main/java/org/whispersystems/textsecuregcm/controllers/SubscriptionController.java b/service/src/main/java/org/whispersystems/textsecuregcm/controllers/SubscriptionController.java index 16f20caef..66939467c 100644 --- a/service/src/main/java/org/whispersystems/textsecuregcm/controllers/SubscriptionController.java +++ b/service/src/main/java/org/whispersystems/textsecuregcm/controllers/SubscriptionController.java @@ -67,6 +67,8 @@ import org.whispersystems.textsecuregcm.configuration.SubscriptionLevelConfigura import org.whispersystems.textsecuregcm.configuration.dynamic.DynamicConfiguration; import org.whispersystems.textsecuregcm.entities.Badge; import org.whispersystems.textsecuregcm.entities.PurchasableBadge; +import org.whispersystems.textsecuregcm.limits.RateLimitedByIp; +import org.whispersystems.textsecuregcm.limits.RateLimiters; import org.whispersystems.textsecuregcm.mappers.SubscriptionExceptionMapper; import org.whispersystems.textsecuregcm.metrics.MetricsUtil; import org.whispersystems.textsecuregcm.metrics.UserAgentTagUtil; @@ -286,6 +288,7 @@ public class SubscriptionController { @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON) @ManagedAsync + @RateLimitedByIp(RateLimiters.For.ADD_SUBSCRIPTION_PAYMENT_METHOD) public CreatePaymentMethodResponse createPaymentMethod( @Auth Optional authenticatedAccount, @PathParam("subscriberId") String subscriberId, @@ -323,6 +326,7 @@ public class SubscriptionController { @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON) @ManagedAsync + @RateLimitedByIp(RateLimiters.For.ADD_SUBSCRIPTION_PAYMENT_METHOD) public CreatePayPalBillingAgreementResponse createPayPalPaymentMethod( @Auth Optional authenticatedAccount, @PathParam("subscriberId") String subscriberId, diff --git a/service/src/main/java/org/whispersystems/textsecuregcm/limits/RateLimiters.java b/service/src/main/java/org/whispersystems/textsecuregcm/limits/RateLimiters.java index ad26d479c..627de0055 100644 --- a/service/src/main/java/org/whispersystems/textsecuregcm/limits/RateLimiters.java +++ b/service/src/main/java/org/whispersystems/textsecuregcm/limits/RateLimiters.java @@ -62,6 +62,7 @@ public class RateLimiters extends BaseRateLimiters { SUBMIT_CALL_QUALITY_SURVEY("submitCallQualitySurvey", new RateLimiterConfig(100, Duration.ofMinutes(1), true)), BATCH_IDENTITY_CHECK("batchIdentityCheck", new RateLimiterConfig(100, Duration.ofMinutes(1), true)), ONE_TIME_DONATION("oneTimeDonation", new RateLimiterConfig(5, Duration.ofMinutes(1), true)), + ADD_SUBSCRIPTION_PAYMENT_METHOD("addSubscriptionPaymentMethod", new RateLimiterConfig(10, Duration.ofMinutes(1), true)), ; private final String id;