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: veria ai reports
adilson5375b8e52b61
diff --git a/backend/e2e-test/routes/v1/identity-folder-access.spec.ts b/backend/e2e-test/routes/v1/identity-folder-access.spec.tsindex 72a6fc36a6..5bae1264b9 100644--- a/backend/e2e-test/routes/v1/identity-folder-access.spec.ts+++ b/backend/e2e-test/routes/v1/identity-folder-access.spec.ts@@ -230,6 +230,82 @@ describe("Identity folder access CRUD", () => {expect(malformedPathRes.statusCode).toBe(400);});+ test("keeps the full-access role permanent on create and on every update path", async () => {+ const temporaryType = {+ isTemporary: true,+ temporaryMode: TemporaryPermissionMode.Relative,+ temporaryRange: "1h",+ temporaryAccessStartTime: new Date().toISOString()+ };++ const createRes = await testServer.inject({+ method: "POST",+ url: folderAccessUrl(),+ headers: authHeaders(),+ body: { ...folderTarget, permission: SecretFolderRole.FullAccess, type: temporaryType }+ });+ expect(createRes.statusCode).toBe(400);+ expect(createRes.json().message).toContain("cannot be temporary");++ const permanentRes = await testServer.inject({+ method: "POST",+ url: folderAccessUrl(),+ headers: authHeaders(),+ body: { ...folderTarget, permission: SecretFolderRole.FullAccess }+ });+ expect(permanentRes.statusCode).toBe(200);+ expect(permanentRes.json().folderAccess.isTemporary).toBe(false);++ try {+ const addExpiryRes = await testServer.inject({+ method: "PATCH",+ url: folderAccessUrl(),+ headers: authHeaders(),+ body: { ...folderTarget, type: temporaryType }+ });+ expect(addExpiryRes.statusCode).toBe(400);+ expect(addExpiryRes.json().message).toContain("cannot be temporary");++ const loweredRes = await testServer.inject({+ method: "PATCH",+ url: folderAccessUrl(),+ headers: authHeaders(),+ body: { ...folderTarget, permission: SecretFolderRole.Manage, type: temporaryType }+ });+ expect(loweredRes.statusCode).toBe(200);+ expect(loweredRes.json().folderAccess).toEqual(+ expect.objectContaining({ permission: SecretFolderRole.Manage, isTemporary: true })+ );++ const promoteRes = await testServer.inject({+ method: "PATCH",+ url: folderAccessUrl(),+ headers: authHeaders(),+ body: { ...folderTarget, permission: SecretFolderRole.FullAccess }+ });+ expect(promoteRes.statusCode).toBe(400);+ expect(promoteRes.json().message).toContain("cannot be temporary");++ const promotePermanentRes = await testServer.inject({+ method: "PATCH",+ url: folderAccessUrl(),+ headers: authHeaders(),+ body: { ...folderTarget, permission: SecretFolderRole.FullAccess, type: { isTemporary: false } }+ });+ expect(promotePermanentRes.statusCode).toBe(200);+ expect(promotePermanentRes.json().folderAccess).toEqual(+ expect.objectContaining({ permission: SecretFolderRole.FullAccess, isTemporary: false })+ );+ } finally {+ await testServer.inject({+ method: "DELETE",+ url: folderAccessUrl(),+ headers: authHeaders(),+ body: { ...folderTarget }+ });+ }+ });+describe("roster", () => {const listIdentities = async (query = ""diff --git a/backend/e2e-test/routes/v1/user-folder-access.spec.ts b/backend/e2e-test/routes/v1/user-folder-access.spec.tsindex d21729c1c8..948f57f7f4 100644--- a/backend/e2e-test/routes/v1/user-folder-access.spec.ts+++ b/backend/e2e-test/routes/v1/user-folder-access.spec.ts@@ -392,6 +392,82 @@ describe("User folder access CRUD", () => {}});+ test("keeps the full-access role permanent on create and on every update path", async () => {+ const temporaryType = {+ isTemporary: true,+ temporaryMode: TemporaryPermissionMode.Relative,+ temporaryRange: "1h",+ temporaryAccessStartTime: new Date().toISOString()+ };++ const createRes = await testServer.inject({+ method: "POST",+ url: folderAccessUrl(),+ headers: authHeaders(),+ body: { ...folderTarget, permission: SecretFolderRole.FullAccess, type: temporaryType }+ });+ expect(createRes.statusCode).toBe(400);+ expect(createRes.json().message).toContain("cannot be temporary");++ const permanentRes = await testServer.inject({+ method: "POST",+ url: folderAccessUrl(),+ headers: authHeaders(),+ body: { ...folderTarget, permission: SecretFolderRole.FullAccess }+ });+ expect(permanentRes.statusCode).toBe(200);+ expect(permanentRes.json().folderAccess.isTemporary).toBe(false);++ try {+ const addExpiryRes = await testServer.inject({+ method: "PATCH",+ url: folderAccessUrl(),+ headers: authHeaders(),+ body: { ...folderTarget, type: temporaryType }+ });+ expect(addExpiryRes.statusCode).toBe(400);+ expect(addExpiryRes.json().message).toContain("cannot be temporary");++ const loweredRes = await testServer.inject({+ method: "PATCH",+ url: folderAccessUrl(),+ headers: authHeaders(),+ body: { ...folderTarget, permission: SecretFolderRole.Manage, type: temporaryType }+ });+ expect(loweredRes.statusCode).toBe(200);+ expect(loweredRes.json().folderAccess).toEqual(+ expect.objectContaining({ permission: SecretFolderRole.Manage, isTemporary: true })+ );++ const promoteRes = await testServer.inject({+ method: "PATCH",+ url: folderAccessUrl(),+ headers: authHeaders(),+ body: { ...folderTarget, permission: SecretFolderRole.FullAccess }+ });+ expect(promoteRes.statusCode).toBe(400);+ expect(promoteRes.json().message).toContain("cannot be temporary");++ const promotePermanentRes = await testServer.inject({+ method: "PATCH",+ url: folderAccessUrl(),+ headers: authHeaders(),+ body: { ...folderTarget, permission: SecretFolderRole.FullAccess, type: { isTemporary: false } }+ });+ expect(promotePermanentRes.statusCode).toBe(200);+ expect(promotePermanentRes.json().folderAccess).toEqual(+ expect.objectContaining({ permission: SecretFolderRole.FullAccess, isTemporary: false })+ );+ } finally {+ await testServer.inject({+ method: "DELETE",+ url: folderAccessUrl(),+ headers: authHeaders(),+ body: { ...folderTarget }+ });+ }+ });+describe("roster", () => {const listUsers = async (query = ""diff --git a/backend/src/lib/api-docs/constants.ts b/backend/src/lib/api-docs/constants.tsindex 02f69cc663..44355111d2 100644--- a/backend/src/lib/api-docs/constants.ts+++ b/backend/src/lib/api-docs/constants.ts@@ -1799,8 +1799,10 @@ export const FOLDER_ACCESS = {secretPath: "The path of the folder to grant access on.",userId: "The ID of the user to grant folder access to.",identityId: "The ID of the machine identity to grant folder access to.",- permission: "The folder role to grant. One of: list, read, edit, manage, full-access.",- isTemporary: "Whether the folder access is temporary. Omit the type object for permanent access.",+ permission:+ "The folder role to grant. One of: list, read, edit, manage, full-access. The full-access role cannot be temporary.",+ isTemporary:+ "Whether the folder access is temporary. Omit the type object for permanent access. The full-access role must be permanent.",temporaryMode: "Type of temporary access given. Types: relative.",temporaryRange: "How long the access lasts from its start time. Eg: 30m, 4h, 1d.",temporaryAccessStartTime: "ISO time the temporary access starts."@@ -1811,9 +1813,10 @@ export const FOLDER_ACCESS = {secretPath: "The path of the folder the access is on.",userId: "The ID of the user whose folder access to update.",identityId: "The ID of the machine identity whose folder access to update.",- permission: "The folder role to change the access to. One of: list, read, edit, manage, full-access.",+ permission:+ "The folder role to change the access to. One of: list, read, edit, manage, full-access. The full-access role cannot be temporary.",isTemporary:- "Whether the folder access is temporary. Pass isTemporary false to make it permanent; omit the type object to leave the current temporal state unchanged.",+ "Whether the folder access is temporary. Pass isTemporary false to make it permanent; omit the type object to leave the current temporal state unchanged. The full-access role must be permanent, so making an access temporary also requires lowering its role.",temporaryMode: "Type of temporary access given. Types: relative.",temporaryRange: "How long the access lasts from its start time. Eg: 30m, 4h, 1d.",temporaryAccessStartTime: "ISO time the temporary access starts."diff --git a/backend/src/services/folder-permission/folder-permission-fns.test.ts b/backend/src/services/folder-permission/folder-permission-fns.test.tsindex 21258f8152..94bd1f0133 100644--- a/backend/src/services/folder-permission/folder-permission-fns.test.ts+++ b/backend/src/services/folder-permission/folder-permission-fns.test.ts@@ -1,9 +1,9 @@-import { TemporaryPermissionMode } from "@app/db/schemas";+import { SecretFolderRole, TemporaryPermissionMode } from "@app/db/schemas";import { BadRequestError, NotFoundError } from "@app/lib/errors";import { ms } from "@app/lib/ms";import { TSecretFolderDALFactory } from "../secret-folder/secret-folder-dal";-import { computeTemporaryFields, resolveFolder } from "./folder-permission-fns";+import { assertFullAccessIsPermanent, computeTemporaryFields, resolveFolder } from "./folder-permission-fns";describe("computeTemporaryFields", () => {test.each([undefined, { isTemporary: false as const }])("returns permanent fields for %o", (input) => {@@ -33,6 +33,24 @@ describe("computeTemporaryFields", () => {});});+describe("assertFullAccessIsPermanent", () => {+ test("rejects a temporary full-access grant", () => {+ expect(() => assertFullAccessIsPermanent(SecretFolderRole.FullAccess, true)).toThrow(BadRequestError);+ expect(() => assertFullAccessIsPermanent(SecretFolderRole.FullAccess, true)).toThrow(/cannot be temporary/);+ });++ test("allows a permanent full-access grant", () => {+ expect(() => assertFullAccessIsPermanent(SecretFolderRole.FullAccess, false)).not.toThrow();+ });++ test.each([SecretFolderRole.List, SecretFolderRole.Read, SecretFolderRole.Edit, SecretFolderRole.Manage])(+ "allows a temporary %s grant",+ (role) => {+ expect(() => assertFullAccessIsPermanent(role, true)).not.toThrow();+ }+ );+});+describe("resolveFolder", () => {const stubSecretFolderDAL = (result: unknown) =>({diff --git a/backend/src/services/folder-permission/folder-permission-fns.ts b/backend/src/services/folder-permission/folder-permission-fns.tsindex 7adc0567b6..b7c16ff635 100644--- a/backend/src/services/folder-permission/folder-permission-fns.ts+++ b/backend/src/services/folder-permission/folder-permission-fns.ts@@ -36,6 +36,17 @@ export const computeTemporaryFields = (type: TFolderGrantTypeInput | undefined)};};+// full-access is the only tier that confers ManageAccess, so a temporary holder could mint permanent+// grants that outlive their own expiration. Bounding that tier by time therefore bounds nothing.+export const assertFullAccessIsPermanent = (role: SecretFolderRole, isTemporary: boolean) => {+ if (role === SecretFolderRole.FullAccess && isTemporary) {+ throw new BadRequestError({+ message:+ "Folder access with the 'full-access' role cannot be temporary. A full-access holder can grant folder access to others, and those grants would outlive the expiration. Grant 'full-access' permanently, or use the 'manage' role for temporary access."+ });+ }+};+export const resolveFolder = async (projectId: string,environmentSlug: string,diff --git a/backend/src/services/folder-permission/folder-permission-service.ts b/backend/src/services/folder-permission/folder-permission-service.tsindex 44fe531023..acf4c07395 100644--- a/backend/src/services/folder-permission/folder-permission-service.ts+++ b/backend/src/services/folder-permission/folder-permission-service.ts@@ -1,5 +1,6 @@import slugify from "@sindresorhus/slugify";+import { SecretFolderRole } from "@app/db/schemas";import { TPermissionServiceFactory } from "@app/ee/services/permission/permission-service-types";import { DatabaseErrorCode } from "@app/lib/error-codes";import { BadRequestError, DatabaseError, NotFoundError } from "@app/lib/errors";@@ -9,6 +10,7 @@ import { TAdditionalPrivilegeDALFactory } from "../additional-privilege/additionimport { TSecretFolderDALFactory } from "../secret-folder/secret-folder-dal";import { TFolderPermissionDALFactory } from "./folder-permission-dal";import {+ assertFullAccessIsPermanent,assertGrantTargetEligible,assertManageFolderAccess,computeTemporaryFields,@@ -47,6 +49,8 @@ export const folderPermissionServiceFactory = ({}: TFolderPermissionServiceFactoryDep) => {const createFolderGrant = async (dto: TCreateFolderGrantDTO) => {const { projectId, environmentSlug, secretPath, target } = dto;+ assertFullAccessIsPermanent(dto.role, Boolean(dto.type?.isTemporary));+const folder = await resolveFolder(projectId, environmentSlug, secretPath, secretFolderDAL);await assertManageFolderAccess(dto.permission, projectId, folder, permissionService);await assertGrantTargetEligible(dto.permission.orgId, projectId, target, folderPermissionDAL);@@ -106,6 +110,11 @@ export const folderPermissionServiceFactory = ({});}+ assertFullAccessIsPermanent(+ (dto.role ?? existing.role) as SecretFolderRole,+ dto.type === undefined ? existing.isTemporary : dto.type.isTemporary+ );+const doc = await additionalPrivilegeDAL.updateById(existing.id,{diff --git a/backend/src/services/secret-folder/secret-folder-service.ts b/backend/src/services/secret-folder/secret-folder-service.tsindex 36557a88c4..fed5b4ec12 100644--- a/backend/src/services/secret-folder/secret-folder-service.ts+++ b/backend/src/services/secret-folder/secret-folder-service.ts@@ -1970,7 +1970,10 @@ export const secretFolderServiceFactory = ({operation: "move",relocations: plan.map((entry) => ({folderId: entry.sourceFolderId,- managePaths: [{ environment: sourceEnvironment, secretPath: entry.sourceAbsPath }]+ managePaths: [+ { environment: sourceEnvironment, secretPath: entry.sourceAbsPath },+ { environment: destinationEnvironment, secretPath: entry.destinationAbsPath }+ ]}))},tx