Skip to content

Commit 4b7a629

Browse files
committed
fix: verify server ownership before running IP detection
validateDomain accepted an arbitrary serverId and used it to look up the server and SSH into it, without checking it belonged to the caller's active organization. A member with domain:read could probe other orgs' servers and get their SSH/detected IPs back in the response. Addresses greptile review on Dokploy#5214
1 parent 9761616 commit 4b7a629

1 file changed

Lines changed: 11 additions & 1 deletion

File tree

‎apps/dokploy/server/api/routers/domain.ts‎

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,17 @@ export const domainRouter = createTRPCRouter({
252252
serverId: z.string().optional(),
253253
}),
254254
)
255-
.mutation(async ({ input }) => {
255+
.mutation(async ({ input, ctx }) => {
256+
if (input.serverId) {
257+
const server = await findServerById(input.serverId);
258+
if (server.organizationId !== ctx.session.activeOrganizationId) {
259+
throw new TRPCError({
260+
code: "UNAUTHORIZED",
261+
message: "You are not authorized to access this server",
262+
});
263+
}
264+
}
265+
256266
const expectedIps = await getServerIpCandidates(input.serverId);
257267
return validateDomain(input.domain, expectedIps);
258268
}),

0 commit comments

Comments
 (0)