diff --git a/packages/server/src/db/schema/user.ts b/packages/server/src/db/schema/user.ts index 75b0aab2e..9f6c3b613 100644 --- a/packages/server/src/db/schema/user.ts +++ b/packages/server/src/db/schema/user.ts @@ -1,3 +1,4 @@ +import { paths } from "@dokploy/server/constants"; import { relations, sql } from "drizzle-orm"; import { boolean, @@ -172,29 +173,31 @@ export const apiModifyTraefikConfig = z.object({ serverId: z.string().optional(), }); export const apiReadTraefikConfig = z.object({ - path: z.string().min(1), - // .refine( - // (path) => { - // // Prevent directory traversal attacks - // if (path.includes("../") || path.includes("..\\")) { - // return false; - // } + path: z + .string() + .min(1) + .refine( + (path) => { + // Prevent directory traversal attacks + if (path.includes("../") || path.includes("..\\")) { + return false; + } - // const { MAIN_TRAEFIK_PATH } = paths(); - // if (path.startsWith("/") && !path.startsWith(MAIN_TRAEFIK_PATH)) { - // return false; - // } - // // Prevent null bytes and other dangerous characters - // if (path.includes("\0") || path.includes("\x00")) { - // return false; - // } - // return true; - // }, - // { - // message: - // "Invalid path: path traversal or unauthorized directory access detected", - // }, - // ), + const { MAIN_TRAEFIK_PATH } = paths(); + if (path.startsWith("/") && !path.startsWith(MAIN_TRAEFIK_PATH)) { + return false; + } + // Prevent null bytes and other dangerous characters + if (path.includes("\0") || path.includes("\x00")) { + return false; + } + return true; + }, + { + message: + "Invalid path: path traversal or unauthorized directory access detected", + }, + ), serverId: z.string().optional(), });