Skip to content

Commit 026405f

Browse files
committed
fix(security): harden workflowId scoping and file key guard
Replace falsy workflowId checks in PauseResumeManager (all methods now unconditionally apply the workflowId WHERE clause, preventing empty-string bypass). Flip WordPress upload file guard from truthy key check to explicit non-empty validation so key:"" fails closed with a 404 instead of silently skipping access control.
1 parent 86f3a53 commit 026405f

3 files changed

Lines changed: 121 additions & 127 deletions

File tree

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

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -78,19 +78,21 @@ export const POST = withRouteHandler(async (request: NextRequest) => {
7878
)
7979
}
8080

81-
if (userFile.key) {
82-
if (!authResult.userId) {
83-
logger.warn(`[${requestId}] File access check requires userId but none available`)
84-
return NextResponse.json({ success: false, error: 'File not found' }, { status: 404 })
85-
}
86-
const hasAccess = await verifyFileAccess(userFile.key, authResult.userId)
87-
if (!hasAccess) {
88-
logger.warn(`[${requestId}] File access denied for user`, {
89-
userId: authResult.userId,
90-
key: userFile.key,
91-
})
92-
return NextResponse.json({ success: false, error: 'File not found' }, { status: 404 })
93-
}
81+
if (typeof userFile.key !== 'string' || userFile.key.length === 0) {
82+
logger.warn(`[${requestId}] File access check rejected: missing key`)
83+
return NextResponse.json({ success: false, error: 'File not found' }, { status: 404 })
84+
}
85+
if (!authResult.userId) {
86+
logger.warn(`[${requestId}] File access check requires userId but none available`)
87+
return NextResponse.json({ success: false, error: 'File not found' }, { status: 404 })
88+
}
89+
const hasAccess = await verifyFileAccess(userFile.key, authResult.userId)
90+
if (!hasAccess) {
91+
logger.warn(`[${requestId}] File access denied for user`, {
92+
userId: authResult.userId,
93+
key: userFile.key,
94+
})
95+
return NextResponse.json({ success: false, error: 'File not found' }, { status: 404 })
9496
}
9597

9698
logger.info(`[${requestId}] Downloading file from storage`, {

0 commit comments

Comments
 (0)