Skip to content

Commit c7cd4ae

Browse files
committed
fix(security): guard NaN timestamp before replay-protection window check
Number(timestamp) returns NaN for non-numeric strings; Math.abs(Date.now() - NaN) is NaN which is never > FIVE_MINUTES_MS, silently bypassing replay protection. Add isNaN guard in both Webflow and HubSpot v3 timestamp checks.
1 parent 7607898 commit c7cd4ae

2 files changed

Lines changed: 4 additions & 2 deletions

File tree

apps/sim/lib/webhooks/providers/hubspot.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,8 @@ export const hubspotHandler: WebhookProviderHandler = {
7272
)
7373
return new NextResponse('Unauthorized - Missing HubSpot v3 timestamp', { status: 401 })
7474
}
75-
if (Math.abs(Date.now() - Number(timestamp)) > FIVE_MINUTES_MS) {
75+
const ts = Number(timestamp)
76+
if (isNaN(ts) || Math.abs(Date.now() - ts) > FIVE_MINUTES_MS) {
7677
logger.warn(`[${requestId}] HubSpot webhook timestamp too old, possible replay attack`)
7778
return new NextResponse('Unauthorized - HubSpot timestamp expired', { status: 401 })
7879
}

apps/sim/lib/webhooks/providers/webflow.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,8 @@ export const webflowHandler: WebhookProviderHandler = {
5353
return new NextResponse('Unauthorized - Missing Webflow signature', { status: 401 })
5454
}
5555

56-
if (Math.abs(Date.now() - Number(timestamp)) > FIVE_MINUTES_MS) {
56+
const ts = Number(timestamp)
57+
if (isNaN(ts) || Math.abs(Date.now() - ts) > FIVE_MINUTES_MS) {
5758
logger.warn(`[${requestId}] Webflow webhook timestamp too old, possible replay attack`)
5859
return new NextResponse('Unauthorized - Webflow timestamp expired', { status: 401 })
5960
}

0 commit comments

Comments
 (0)