From 8257859834ed6d67ccc8db33bc0a31b33bb665f2 Mon Sep 17 00:00:00 2001 From: Jon Chambers Date: Wed, 10 Jun 2026 11:11:25 -0400 Subject: [PATCH] Add an IP-based rate limiter for creating one-time donations --- .../textsecuregcm/controllers/OneTimeDonationController.java | 3 +++ .../org/whispersystems/textsecuregcm/limits/RateLimiters.java | 1 + 2 files changed, 4 insertions(+) diff --git a/service/src/main/java/org/whispersystems/textsecuregcm/controllers/OneTimeDonationController.java b/service/src/main/java/org/whispersystems/textsecuregcm/controllers/OneTimeDonationController.java index 0d7f715f3..4c512c5ab 100644 --- a/service/src/main/java/org/whispersystems/textsecuregcm/controllers/OneTimeDonationController.java +++ b/service/src/main/java/org/whispersystems/textsecuregcm/controllers/OneTimeDonationController.java @@ -53,6 +53,8 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.whispersystems.textsecuregcm.auth.AuthenticatedDevice; import org.whispersystems.textsecuregcm.configuration.OneTimeDonationConfiguration; +import org.whispersystems.textsecuregcm.limits.RateLimitedByIp; +import org.whispersystems.textsecuregcm.limits.RateLimiters; import org.whispersystems.textsecuregcm.metrics.UserAgentTagUtil; import org.whispersystems.textsecuregcm.storage.IssuedReceiptsManager; import org.whispersystems.textsecuregcm.storage.OneTimeDonationsManager; @@ -161,6 +163,7 @@ public class OneTimeDonationController { properties = { @StringToClassMapItem(key = "error", value = String.class) }))) + @RateLimitedByIp(RateLimiters.For.ONE_TIME_DONATION) public CompletableFuture createBoostPaymentIntent( @Auth Optional authenticatedAccount, @NotNull @Valid CreateBoostRequest request, 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 acf5b4bcb..ad26d479c 100644 --- a/service/src/main/java/org/whispersystems/textsecuregcm/limits/RateLimiters.java +++ b/service/src/main/java/org/whispersystems/textsecuregcm/limits/RateLimiters.java @@ -61,6 +61,7 @@ public class RateLimiters extends BaseRateLimiters { DEVICE_CHECK_CHALLENGE("deviceCheckChallenge", new RateLimiterConfig(10, Duration.ofMinutes(1), false)), 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)), ; private final String id;