Skip to content

Commit 83d2416

Browse files
authored
Merge pull request #1224 from stripe/remi-fix-event-validation
Improve tolerance verification to check both past and future timestamps
2 parents e6420d8 + c5e73db commit 83d2416

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/Stripe.net/Services/Events/StripeEventUtility.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,8 @@ public static StripeEvent ConstructEvent(string json, string stripeSignatureHead
4747

4848
var webhookUtc = Convert.ToInt32(signatureItems["t"].FirstOrDefault());
4949

50-
if (utcNow - webhookUtc > tolerance)
51-
throw new StripeException("The webhook cannot be processed because the current timestamp is above the allowed tolerance.");
50+
if (Math.Abs(utcNow - webhookUtc) > tolerance)
51+
throw new StripeException("The webhook cannot be processed because the current timestamp is outside of the allowed tolerance.");
5252

5353
return Mapper<StripeEvent>.MapFromJson(json);
5454
}

0 commit comments

Comments
 (0)