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
add a check on grant on the update additional privilege
adilson6d0bbaa06070
diff --git a/backend/e2e-test/routes/v1/access-approval-global-request-lifecycle.spec.ts b/backend/e2e-test/routes/v1/access-approval-global-request-lifecycle.spec.tsindex a51cc9f25e..ea95f5aa41 100644--- a/backend/e2e-test/routes/v1/access-approval-global-request-lifecycle.spec.ts+++ b/backend/e2e-test/routes/v1/access-approval-global-request-lifecycle.spec.ts@@ -149,6 +149,27 @@ describe("Access approval request lifecycle on the global system", () => {expect(legacyRows).toHaveLength(0);});+ test("A privilege granted through an approval request cannot be edited", async () => {+ const db = getDb();+ const { requestId } = await createApprovedTemporaryRequest("/lifecycle-edit-guard");++ const grant = await db(TableName.ApprovalRequestGrants).where({ requestId }).first();+ const privilege = await db(TableName.AdditionalPrivilege).where({ grantId: grant?.id }).first();+ expect(privilege).toBeDefined();++ const res = await testServer.inject({+ method: "PATCH",+ url: `/api/v1/user-project-additional-privilege/${privilege?.id}`,+ headers: authHeaders(),+ body: { isTemporary: false }+ });+ expect(res.statusCode).toBe(400);+ expect(res.json().message).toBe("Cannot update a privilege that was granted through an access approval request");++ const privilegeAfter = await db(TableName.AdditionalPrivilege).where({ id: privilege?.id }).first();+ expect(privilegeAfter?.isTemporary).toBe(true);+ });+test("Revoking an approved request revokes the grant and deletes the privilege", async () => {const db = getDb();const { requestId } = await createApprovedTemporaryRequest("/lifecycle-revoke");@@ -416,6 +437,21 @@ describe("Access approval request lifecycle on the global system", () => {expect(request?.status).toBe("pending");});+ test("Approval stands when a brace policy still covers the requested path", async () => {+ const secretPath = "/apps/blue";+ const { policy, requestId } = await openPendingRequest(secretPath);++ await getDb()(TableName.ApprovalPolicySecretEnvironment)+ .where({ policyId: policy.id })+ .update({ secretPath: "/apps/{blue,green}" });++ const approveRes = await reviewAccessRequest(requestId, { status: "approved" });+ expect(approveRes.statusCode).toBe(200);++ const request = await getDb()(TableName.ApprovalRequests).where({ id: requestId }).first();+ expect(request?.status).toBe("approved");+ });+test("Approval stands when a broader policy path still contains the requested glob", async () => {const secretPath = "/scope-broader/*";const { policy, requestId } = await openPendingRequest(secretPath);diff --git a/backend/src/ee/routes/v1/user-additional-privilege-router.ts b/backend/src/ee/routes/v1/user-additional-privilege-router.tsindex dbe9668eb8..77bd74392a 100644--- a/backend/src/ee/routes/v1/user-additional-privilege-router.ts+++ b/backend/src/ee/routes/v1/user-additional-privilege-router.ts@@ -132,6 +132,12 @@ export const registerUserAdditionalPrivilegeRouter = async (server: FastifyZodPrif (!data.privilege.actorUserId)throw new NotFoundError({ message: `Privilege with id ${req.params.privilegeId} not found` });+ if (data.privilege.grantId) {+ throw new BadRequestError({+ message: "Cannot update a privilege that was granted through an access approval request"+ });+ }+const isLinkedToAccessApproval = await server.services.additionalPrivilege.isPrivilegeLinkedToAccessApproval(req.params.privilegeId);