Skip to content

Commit b41c0fe

Browse files
fix(execution): always ban-check the workflow owner so schedules are covered
1 parent 590653e commit b41c0fe

2 files changed

Lines changed: 16 additions & 7 deletions

File tree

apps/sim/lib/execution/preprocessing.test.ts

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ vi.mock('@/lib/workspaces/utils', () => ({
3838
vi.mock('@sim/workflow-authz', () => ({
3939
getActiveWorkflowRecord: vi.fn().mockResolvedValue({
4040
id: 'workflow-1',
41+
userId: 'creator-1',
4142
workspaceId: 'workspace-1',
4243
isDeployed: true,
4344
}),
@@ -197,19 +198,23 @@ describe('preprocessExecution ban gate', () => {
197198
expect(checkServerSideUsageLimits).not.toHaveBeenCalled()
198199
})
199200

200-
it('checks the billing actor and the caller-provided userId in one call', async () => {
201+
it('checks the billing actor, caller-provided userId, and workflow owner in one call', async () => {
201202
const result = await preprocessExecution(baseOptions)
202203

203204
expect(result.success).toBe(true)
204205
expect(mockGetActivelyBannedUserIds).toHaveBeenCalledTimes(1)
205-
expect(mockGetActivelyBannedUserIds).toHaveBeenCalledWith(['billed-account-1', 'owner-1'])
206+
expect(mockGetActivelyBannedUserIds).toHaveBeenCalledWith([
207+
'billed-account-1',
208+
'owner-1',
209+
'creator-1',
210+
])
206211
})
207212

208-
it('excludes the "unknown" sentinel userId from the ban check', async () => {
213+
it('excludes the "unknown" sentinel userId but still checks the workflow owner', async () => {
209214
const result = await preprocessExecution({ ...baseOptions, userId: 'unknown' })
210215

211216
expect(result.success).toBe(true)
212-
expect(mockGetActivelyBannedUserIds).toHaveBeenCalledWith(['billed-account-1'])
217+
expect(mockGetActivelyBannedUserIds).toHaveBeenCalledWith(['billed-account-1', 'creator-1'])
213218
})
214219

215220
it('fails closed with 500 when the ban check errors', async () => {

apps/sim/lib/execution/preprocessing.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -313,13 +313,17 @@ export async function preprocessExecution(
313313
}
314314

315315
// ========== STEP 3.5: Reject Banned Accounts ==========
316-
// Blocks executions when the billing actor — or, when different, the
317-
// caller-provided userId (workflow creator, chat deployer, authenticated
318-
// caller) — has an active ban or a blocked email domain.
316+
// Blocks executions when the billing actor, the workflow owner, or the
317+
// caller-provided userId (chat deployer, authenticated caller) has an
318+
// active ban or a blocked email domain. The owner comes from the workflow
319+
// record so schedules — which pass the 'unknown' sentinel — are covered.
319320
const banCandidateIds = [actorUserId]
320321
if (userId && userId !== 'unknown' && userId !== actorUserId) {
321322
banCandidateIds.push(userId)
322323
}
324+
if (workflowRecord.userId && !banCandidateIds.includes(workflowRecord.userId)) {
325+
banCandidateIds.push(workflowRecord.userId)
326+
}
323327
try {
324328
const bannedUserIds = await getActivelyBannedUserIds(banCandidateIds)
325329
if (bannedUserIds.length > 0) {

0 commit comments

Comments
 (0)