Infisical is the open-source platform for securing secrets, certificates, access, and AI Agents.
TypeScript acmeagentsai-agentscertificate-managementdevsecopsenvironment-variableskubernetesopen-sourcepampkipostgresprivate-caprivileged-access-managementsecret-managementsecret-managersecretssecrets-managementsecuritysecurity-toolsvault
Fix: Add recursive search max depth (20)
Daniel Hougaard75267987fce6
diff --git a/backend/src/services/secret/secret-fns.ts b/backend/src/services/secret/secret-fns.tsindex 24c2bd811c..edd656b55d 100644--- a/backend/src/services/secret/secret-fns.ts+++ b/backend/src/services/secret/secret-fns.ts@@ -92,7 +92,8 @@ const buildHierarchy = (folders: TSecretFolders[]): FolderMap => {const generatePaths = (map: FolderMap,parentId: string = "null",- basePath: string = ""+ basePath: string = "",+ currentDepth: number = 0): { path: string; folderId: string }[] => {const children = map[parentId || "null"] || [];let paths: { path: string; folderId: string }[] = [];@@ -105,13 +106,19 @@ const generatePaths = (// eslint-disable-next-line no-nested-ternaryconst currPath = basePath === "" ? (isRootFolder ? "/" : `/${child.name}`) : `${basePath}/${child.name}`;+ // Add the current pathpaths.push({path: currPath,folderId: child.id- }); // Add the current path+ });- // Recursively generate paths for children, passing down the formatted pathh- const childPaths = generatePaths(map, child.id, currPath);+ // We make sure that the max depth doesn't exceed 20.+ // We do this to make as a "circuit break", basically to ensure that we can't encounter any potential memory leaks.+ if (currentDepth >= 20) {+ return;+ }+ // Recursively generate paths for children, passing down the formatted path+ const childPaths = generatePaths(map, child.id, currPath, currentDepth + 1);paths = paths.concat(childPaths.map((p) => ({path: p.path,