Skip to content

Commit feb6827

Browse files
waleedlatif1claude
andcommitted
fix(data-drains): apply feature-flag and enterprise gates to read routes
Only role enforcement should relax for read-only callers — feature-flag and enterprise-plan checks must apply to reads too. Otherwise on self-hosted with DATA_DRAINS_ENABLED unset any org member can enumerate drain configs (bucket names, webhook URLs), and on Cloud an org that downgraded off Enterprise still exposes its old drain configs to every member. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
1 parent 5ec4537 commit feb6827

1 file changed

Lines changed: 20 additions & 16 deletions

File tree

apps/sim/lib/data-drains/access.ts

Lines changed: 20 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -59,16 +59,32 @@ export async function authorizeDrainAccess(
5959
}
6060
}
6161

62-
if (options.requireMutating) {
63-
if (!isBillingEnabled && !isDataDrainsEnabled) {
62+
// Feature-flag and enterprise-plan gates apply to reads as well as writes —
63+
// drain configs (bucket names, webhook URLs) are sensitive enough that an
64+
// org member shouldn't be able to enumerate them on a deployment that
65+
// hasn't opted in or after a downgrade off Enterprise.
66+
if (!isBillingEnabled && !isDataDrainsEnabled) {
67+
return {
68+
ok: false,
69+
response: NextResponse.json(
70+
{ error: 'Data Drains are not enabled on this deployment' },
71+
{ status: 404 }
72+
),
73+
}
74+
}
75+
if (isBillingEnabled) {
76+
const hasEnterprise = await isOrganizationOnEnterprisePlan(organizationId)
77+
if (!hasEnterprise) {
6478
return {
6579
ok: false,
6680
response: NextResponse.json(
67-
{ error: 'Data Drains are not enabled on this deployment' },
68-
{ status: 404 }
81+
{ error: 'Data Drains are available on Enterprise plans only' },
82+
{ status: 403 }
6983
),
7084
}
7185
}
86+
}
87+
if (options.requireMutating) {
7288
if (memberEntry.role !== 'owner' && memberEntry.role !== 'admin') {
7389
return {
7490
ok: false,
@@ -78,18 +94,6 @@ export async function authorizeDrainAccess(
7894
),
7995
}
8096
}
81-
if (isBillingEnabled) {
82-
const hasEnterprise = await isOrganizationOnEnterprisePlan(organizationId)
83-
if (!hasEnterprise) {
84-
return {
85-
ok: false,
86-
response: NextResponse.json(
87-
{ error: 'Data Drains are available on Enterprise plans only' },
88-
{ status: 403 }
89-
),
90-
}
91-
}
92-
}
9397
}
9498

9599
return {

0 commit comments

Comments
 (0)