Skip to content

Commit 94bc2e2

Browse files
committed
fix(security): close verifyFileAccess bypass, thread workflowId to processQueuedResumes, fix log level
- Fail closed in WordPress upload when userFile.key is present but authResult.userId is absent, preventing silent bypass of ownership check via JWT fallback path - Thread workflowId into processQueuedResumes in the async resume error-recovery path and in pause-persistence.ts to close residual cross-tenant gap - Change logger.error to logger.warn for credential access denial in OneDrive folder route to match all other routes in this PR
1 parent 1cdb3c6 commit 94bc2e2

4 files changed

Lines changed: 9 additions & 11 deletions

File tree

apps/sim/app/api/resume/[workflowId]/[executionId]/[contextId]/route.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,7 @@ export const POST = withRouteHandler(
250250
contextId: enqueueResult.contextId,
251251
failureReason: 'Failed to queue async resume execution',
252252
})
253-
await PauseResumeManager.processQueuedResumes(executionId)
253+
await PauseResumeManager.processQueuedResumes(executionId, workflowId)
254254
return NextResponse.json(
255255
{ error: 'Failed to queue resume execution. Please try again.' },
256256
{ status: 503 }

apps/sim/app/api/tools/onedrive/folder/route.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ export const GET = withRouteHandler(async (request: NextRequest) => {
3939
requireWorkflowIdForInternal: false,
4040
})
4141
if (!credAccess.ok || !credAccess.credentialOwnerUserId) {
42-
logger.error(`[${requestId}] Credential access denied`, { error: credAccess.error })
42+
logger.warn(`[${requestId}] Credential access denied`, { error: credAccess.error })
4343
return NextResponse.json({ error: credAccess.error || 'Unauthorized' }, { status: 401 })
4444
}
4545

apps/sim/app/api/tools/wordpress/upload/route.ts

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -79,20 +79,18 @@ export const POST = withRouteHandler(async (request: NextRequest) => {
7979
)
8080
}
8181

82-
if (userFile.key && authResult.userId) {
82+
if (userFile.key) {
83+
if (!authResult.userId) {
84+
logger.warn(`[${requestId}] File access check requires userId but none available`)
85+
return NextResponse.json({ success: false, error: 'File not found' }, { status: 404 })
86+
}
8387
const hasAccess = await verifyFileAccess(userFile.key, authResult.userId)
8488
if (!hasAccess) {
8589
logger.warn(`[${requestId}] File access denied for user`, {
8690
userId: authResult.userId,
8791
key: userFile.key,
8892
})
89-
return NextResponse.json(
90-
{
91-
success: false,
92-
error: 'File not found',
93-
},
94-
{ status: 404 }
95-
)
93+
return NextResponse.json({ success: false, error: 'File not found' }, { status: 404 })
9694
}
9795
}
9896

apps/sim/lib/workflows/executor/pause-persistence.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ export async function handlePostExecutionPauseState({
5454
}
5555
} else {
5656
try {
57-
await PauseResumeManager.processQueuedResumes(executionId)
57+
await PauseResumeManager.processQueuedResumes(executionId, workflowId)
5858
} catch (resumeError) {
5959
logger.error('Failed to process queued resumes', {
6060
executionId,

0 commit comments

Comments
 (0)