Skip to content

Commit 065f9a4

Browse files
committed
fix(webhooks): restore auth-before-reachability ordering and remove dead credentialAccountUserId field
- Move reachability test back after auth to prevent path enumeration - Remove dead credentialAccountUserId from WebhookExecutionPayload - Simplify credential resolution condition in background job
1 parent 4b4e71c commit 065f9a4

File tree

2 files changed

+7
-9
lines changed

2 files changed

+7
-9
lines changed

apps/sim/app/api/webhooks/trigger/[path]/route.ts

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -73,12 +73,6 @@ export async function POST(
7373
const responses: NextResponse[] = []
7474

7575
for (const { webhook: foundWebhook, workflow: foundWorkflow } of webhooksForPath) {
76-
// Short-circuit: reachability test is a quick body-only check
77-
const reachabilityResponse = handleProviderReachabilityTest(foundWebhook, body, requestId)
78-
if (reachabilityResponse) {
79-
return reachabilityResponse
80-
}
81-
8276
const authError = await verifyProviderAuth(
8377
foundWebhook,
8478
foundWorkflow,
@@ -94,6 +88,11 @@ export async function POST(
9488
return authError
9589
}
9690

91+
const reachabilityResponse = handleProviderReachabilityTest(foundWebhook, body, requestId)
92+
if (reachabilityResponse) {
93+
return reachabilityResponse
94+
}
95+
9796
const preprocessResult = await checkWebhookPreprocessing(foundWorkflow, foundWebhook, requestId)
9897
if (preprocessResult.error) {
9998
if (webhooksForPath.length > 1) {

apps/sim/background/webhook-execution.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,6 @@ export type WebhookExecutionPayload = {
106106
blockId?: string
107107
workspaceId?: string
108108
credentialId?: string
109-
credentialAccountUserId?: string
110109
}
111110

112111
export async function executeWebhookJob(payload: WebhookExecutionPayload) {
@@ -206,9 +205,9 @@ async function executeWebhookJobInternal(
206205
const [workflowData, webhookRows, resolvedCredentialUserId] = await Promise.all([
207206
loadDeployedWorkflowState(payload.workflowId, workspaceId),
208207
db.select().from(webhook).where(eq(webhook.id, payload.webhookId)).limit(1),
209-
!payload.credentialAccountUserId && payload.credentialId
208+
payload.credentialId
210209
? resolveCredentialAccountUserId(payload.credentialId)
211-
: Promise.resolve(payload.credentialAccountUserId),
210+
: Promise.resolve(undefined),
212211
])
213212
const credentialAccountUserId = resolvedCredentialUserId
214213
if (payload.credentialId && !credentialAccountUserId) {

0 commit comments

Comments
 (0)