fix(storage): constrain recursive blob deletion to resource folders

This commit is contained in:
2026-11-07 11:12:08 +00:00
parent bb8c5047c8
commit 57e0c62940
5 changed files with 264 additions and 8 deletions
+17
View File
@@ -17,6 +17,15 @@ const forbidden = (res) =>
message: "Request not permitted"
});
const isValidPathSegment = (value) =>
typeof value === "string" &&
value.length > 0 &&
value.length <= 255 &&
value === value.trim() &&
value !== "." &&
value !== ".." &&
!/[\\/\u0000-\u001f\u007f]/.test(value);
ApiProxy.get(async (req, res) => {
const containerName = req.query.container;
const casefolderID = req.query.casefolderID;
@@ -39,6 +48,14 @@ ApiProxy.get(async (req, res) => {
const casefolderIDTrimmed = casefolderID.trim();
if (!isValidPathSegment(casefolderIDTrimmed)) {
return respondError(res, {
status: 400,
code: "INVALID_REQUEST",
message: "Invalid request"
});
}
const session = await getServerSession(req, res, authOptions(req, res));
if (
typeof session?.user?.id !== "string" ||
+20
View File
@@ -17,6 +17,15 @@ const forbidden = (res) =>
message: "Request not permitted"
});
const isValidPathSegment = (value) =>
typeof value === "string" &&
value.length > 0 &&
value.length <= 255 &&
value === value.trim() &&
value !== "." &&
value !== ".." &&
!/[\\/\u0000-\u001f\u007f]/.test(value);
ApiProxy.get(async (req, res) => {
const containerName = req.query.container;
const casefolderID = req.query.casefolderID;
@@ -43,6 +52,17 @@ ApiProxy.get(async (req, res) => {
const casefolderIDTrimmed = casefolderID.trim();
const repfileTrimmed = repfile.trim();
if (
!isValidPathSegment(casefolderIDTrimmed) ||
!isValidPathSegment(repfileTrimmed)
) {
return respondError(res, {
status: 400,
code: "INVALID_REQUEST",
message: "Invalid request"
});
}
const session = await getServerSession(req, res, authOptions(req, res));
if (
typeof session?.user?.id !== "string" ||