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
block change from API as well
Thiago Araujo da Silvac37e8d10a05a
diff --git a/backend/CLAUDE.md b/backend/CLAUDE.mdindex efa6eb4a7d..e9c63e891d 100644--- a/backend/CLAUDE.md+++ b/backend/CLAUDE.md@@ -1004,7 +1004,7 @@ fails if a type lands in two lists. Reads, lists, dashboards, insights views, CMand the dynamic secret lease lifecycle are data access; VIEW_AUDIT_LOGS and privileged sessionlifecycle are management on purpose.-Any class can be turned off per scope, and scopes do not inherit: an org (root or sub-org) has its own+Every class but management can be turned off per scope, and scopes do not inherit: an org (root or sub-org) has its ownrows for org-level events, each project has its own rows for its events, and a scope without a row usesthe default in `AUDIT_LOG_EVENT_CLASS_DEFAULTS` (data access on, authorization off). The rows live in`audit_log_settings` (one per scope and class, `projectId` null for the org scope) behind@@ -1012,8 +1012,10 @@ the default in `AUDIT_LOG_EVENT_CLASS_DEFAULTS` (data access on, authorization okeystore for 5 minutes (`getEffectiveSettings`, never throws: a lookup failure records everything).Enforcement is `isAuditLogEventEnabled` in the settings service, called from `buildStreamEntry` in`audit-log-queue.ts` with the settings memoized per request so a batch of events costs one read.-Suppressed events are dropped silently and do not count on the dropped counter.-`UPDATE_AUDIT_LOG_SETTINGS` is exempt inside the helper so turning a class off is always recorded.+Suppressed events are dropped silently and do not count on the dropped counter. Management is+always on: the helper returns true for it before looking at any row, `toSettings` reports it as+enabled, and the update methods reject any request that names it, so the change that turns a+class off is itself always recorded.`PERMISSION_DENIED` is recorded by the `onError` hook in`src/server/plugins/audit-log-permission-denied.ts` for every CASL `ForbiddenError` anddiff --git a/backend/src/ee/services/audit-log/audit-log-queue.test.ts b/backend/src/ee/services/audit-log/audit-log-queue.test.tsindex a5b3b8a4aa..f2e41e70e8 100644--- a/backend/src/ee/services/audit-log/audit-log-queue.test.ts+++ b/backend/src/ee/services/audit-log/audit-log-queue.test.ts@@ -270,13 +270,13 @@ describe("audit-log-queue event class settings", () => {expect(keyStore.streamAdd).toHaveBeenCalledTimes(1);});- test("drops a management event when the org turned the class off", async () => {+ test("records a management event even if a row says the class is off", async () => {const { service, keyStore, auditLogSettingsService } = await createHarness();auditLogSettingsService.getEffectiveSettings.mockResolvedValueOnce(settings({ org: { management: false } }));await service.pushToLog(dto({ event: { type: "update-secret", metadata: {} } }) as never);- expect(keyStore.streamAdd).not.toHaveBeenCalled();+ expect(keyStore.streamAdd).toHaveBeenCalledTimes(1);});test("records a management event when no scope has a setting", async () => {@@ -330,15 +330,6 @@ describe("audit-log-queue event class settings", () => {expect(keyStore.streamAdd).toHaveBeenCalledTimes(1);});- test("records a settings change even when the org turned management off", async () => {- const { service, keyStore, auditLogSettingsService } = await createHarness();- auditLogSettingsService.getEffectiveSettings.mockResolvedValueOnce(settings({ org: { management: false } }));-- await service.pushToLog(dto({ event: { type: "update-audit-log-settings", metadata: {} } }) as never);-- expect(keyStore.streamAdd).toHaveBeenCalledTimes(1);- });-test("records the event when the settings lookup returns nothing", async () => {const { service, keyStore, auditLogSettingsService } = await createHarness();auditLogSettingsService.getEffectiveSettings.mockResolvedValueOnce(null);diff --git a/backend/src/ee/services/audit-log/audit-log-settings-service.test.ts b/backend/src/ee/services/audit-log/audit-log-settings-service.test.tsindex 71d0b6bb76..5968474198 100644--- a/backend/src/ee/services/audit-log/audit-log-settings-service.test.ts+++ b/backend/src/ee/services/audit-log/audit-log-settings-service.test.ts@@ -35,10 +35,10 @@ describe("isAuditLogEventEnabled", () => {expect(isAuditLogEventEnabled(settings(), EventType.PERMISSION_DENIED)).toBe(false);});- test("a settings change is recorded even when management is off", () => {+ test("management is always recorded, even with a row that says otherwise", () => {const off = settings({ org: { [AuditLogEventClass.Management]: false } });+ expect(isAuditLogEventEnabled(off, EventType.UPDATE_SECRET)).toBe(true);expect(isAuditLogEventEnabled(off, EventType.UPDATE_AUDIT_LOG_SETTINGS)).toBe(true);- expect(isAuditLogEventEnabled(off, EventType.UPDATE_SECRET)).toBe(false);});test("records everything when the lookup failed", () => {@@ -131,6 +131,21 @@ describe("updateOrgSettings", () => {vi.clearAllMocks();});+ test.each([false, true])("refuses any management entry (isEnabled=%s)", async (isEnabled) => {+ const { service, auditLogSettingsDAL } = createHarness();++ await expect(+ service.updateOrgSettings({+ actor: orgActor,+ eventClasses: [+ { eventClass: AuditLogEventClass.DataAccess, isEnabled: false },+ { eventClass: AuditLogEventClass.Management, isEnabled }+ ]+ })+ ).rejects.toThrow("Management events are always recorded and cannot be changed");+ expect(auditLogSettingsDAL.transaction).not.toHaveBeenCalled();+ });+test("answers from the rows it wrote and the scope's untouched rows, without re-reading", async () => {const { service, auditLogSettingsDAL, keyStore } = createHarness({rows: [diff --git a/backend/src/ee/services/audit-log/audit-log-settings-service.ts b/backend/src/ee/services/audit-log/audit-log-settings-service.tsindex 63e0156833..11ba6bac27 100644--- a/backend/src/ee/services/audit-log/audit-log-settings-service.ts+++ b/backend/src/ee/services/audit-log/audit-log-settings-service.ts@@ -2,7 +2,7 @@ import { ForbiddenError } from "@casl/ability";import { ActionProjectType, OrganizationActionScope, ProjectMembershipRole } from "@app/db/schemas";import { KeyStorePrefixes, KeyStoreTtls, TKeyStoreFactory } from "@app/keystore/keystore";-import { ForbiddenRequestError, NotFoundError } from "@app/lib/errors";+import { BadRequestError, ForbiddenRequestError, NotFoundError } from "@app/lib/errors";import { logger } from "@app/lib/logger";import { TOrgDALFactory } from "@app/services/org/org-dal";import { TProjectDALFactory } from "@app/services/project/project-dal";@@ -21,7 +21,6 @@ import {TUpdateOrgAuditLogSettingsDTO,TUpdateProjectAuditLogSettingsDTO} from "./audit-log-settings-types";-import { EventType } from "./audit-log-types";type TAuditLogSettingsServiceFactoryDep = {auditLogSettingsDAL: TAuditLogSettingsDALFactory;@@ -46,9 +45,9 @@ export const isAuditLogEventEnabled = (eventType: string,projectId?: string | null) => {- if (eventType === EventType.UPDATE_AUDIT_LOG_SETTINGS) return true;- if (!settings) return true;const eventClass = getAuditLogEventClass(eventType);+ if (eventClass === AuditLogEventClass.Management) return true;+ if (!settings) return true;const scope = projectId ? settings.projects[projectId] : settings.org;return scope?.[eventClass] ?? AUDIT_LOG_EVENT_CLASS_DEFAULTS[eventClass];};@@ -59,9 +58,19 @@ const isKnownEventClass = (value: string): value is AuditLogEventClass =>const toSettings = (overrides: TAuditLogEventClassOverrides): TAuditLogEventClassSetting[] =>ORDERED_EVENT_CLASSES.map((eventClass) => ({eventClass,- isEnabled: overrides[eventClass] ?? AUDIT_LOG_EVENT_CLASS_DEFAULTS[eventClass]+ isEnabled:+ eventClass === AuditLogEventClass.Management+ ? true+ : (overrides[eventClass] ?? AUDIT_LOG_EVENT_CLASS_DEFAULTS[eventClass])}));+const toChanges = (eventClasses: TAuditLogEventClassSetting[]): [AuditLogEventClass, boolean][] => {+ if (eventClasses.some((el) => el.eventClass === AuditLogEventClass.Management)) {+ throw new BadRequestError({ message: "Management events are always recorded and cannot be changed" });+ }+ return [...new Map(eventClasses.map((el) => [el.eventClass, el.isEnabled])).entries()];+};+export const auditLogSettingsServiceFactory = ({auditLogSettingsDAL,orgDAL,@@ -174,7 +183,7 @@ export const auditLogSettingsServiceFactory = ({const org = await orgDAL.findById(actor.orgId);if (!org) throw new NotFoundError({ message: `Organization with ID '${actor.orgId}' not found` });- const changed = [...new Map(eventClasses.map((el) => [el.eventClass, el.isEnabled])).entries()];+ const changed = toChanges(eventClasses);if (!changed.length) return getOrgSettings({ actor });const overrides = await writeScopeSettings({ orgId: actor.orgId, projectId: null }, changed);@@ -234,7 +243,7 @@ export const auditLogSettingsServiceFactory = ({const org = await orgDAL.findById(project.orgId);if (!org) throw new NotFoundError({ message: `Organization with ID '${project.orgId}' not found` });- const changed = [...new Map(eventClasses.map((el) => [el.eventClass, el.isEnabled])).entries()];+ const changed = toChanges(eventClasses);if (!changed.length) return getProjectSettings(dto);const overrides = await writeScopeSettings({ orgId: project.orgId, projectId: dto.projectId }, changed);diff --git a/backend/src/lib/api-docs/constants.ts b/backend/src/lib/api-docs/constants.tsindex 2fb419afab..6a0626aaa6 100644--- a/backend/src/lib/api-docs/constants.ts+++ b/backend/src/lib/api-docs/constants.ts@@ -2086,13 +2086,15 @@ export const AUDIT_LOG_SETTINGS = {shouldUseNewPrivilegeSystem:"Whether the organization is on the new privilege system. Permission denials (the authorization class) are only recorded on the new privilege system.",UPDATE_ORG: {- eventClasses: "The event classes to update.",+ eventClasses:+ "The event classes to update. Management events are always recorded, so a request that includes the management class is rejected.",isEnabled:"Whether to record events of this class for the organization. This only covers organization-level events; each project has its own setting."},UPDATE_PROJECT: {projectId: "The ID of the project to update the audit log settings for.",- eventClasses: "The event classes to update.",+ eventClasses:+ "The event classes to update. Management events are always recorded, so a request that includes the management class is rejected.",isEnabled:"Whether to record events of this class for the project. A project that has never saved a setting uses the default."},diff --git a/docs/documentation/platform/audit-logs.mdx b/docs/documentation/platform/audit-logs.mdxindex cbe0505dda..d0fc9dfc29 100644--- a/docs/documentation/platform/audit-logs.mdx+++ b/docs/documentation/platform/audit-logs.mdx@@ -231,7 +231,7 @@ Every event type belongs to exactly one of four classes. The class tells you wha| Class | What it covers | Default || ---------------- | -------------------------------------------------------------------------------------------------------------------------- | ------- |-| `management` | Creates, updates, deletes, membership, roles, policies, background jobs, and the start and end of privileged sessions | On |+| `management` | Creates, updates, deletes, membership, roles, policies, background jobs, and the start and end of privileged sessions | Always on || `data-access` | Reads and lists, plus the crypto operations that return or operate on secret material, such as KMS encrypt and decrypt | On || `authentication` | Logins, failed logins, organization selection, machine identity authentication, and Gateway and Relay connections | On || `authorization` | [Permission denials](#permission-denials) | Off |@@ -240,7 +240,7 @@ A class follows the operation that was attempted, not its outcome, so a failed l### Choose which classes to record-By default, Infisical records every class except `authorization`. Each organization, sub-organization, and project has its own settings, and they don't inherit from each other. The organization settings cover organization-level events such as membership and login changes. A project's settings cover that project's events, so turning a class off for the organization doesn't turn it off for its projects.+By default, Infisical records every class except `authorization`. The `management` class is always recorded and can't be turned off, so every configuration change stays in the log, including changes to these settings. Each organization, sub-organization, and project has its own settings, and they don't inherit from each other. The organization settings cover organization-level events such as membership and login changes. A project's settings cover that project's events, so turning a class off for the organization doesn't turn it off for its projects.<Tabs><Tab title="For an organization">diff --git a/frontend/src/components/auditLogSettings/AuditLogEventClassRow.tsx b/frontend/src/components/auditLogSettings/AuditLogEventClassRow.tsxindex 6346c8f91d..afafd2462c 100644--- a/frontend/src/components/auditLogSettings/AuditLogEventClassRow.tsx+++ b/frontend/src/components/auditLogSettings/AuditLogEventClassRow.tsx@@ -49,8 +49,6 @@ export const AuditLogEventClassRow = ({className}: Props) => {const id = `audit-log-event-class-${eventClass}`;- let status = isEnabled ? "Recording" : "Not recorded";- if (lockedReason && !isEnabled) status = lockedReason;const toggle = (<Toggle@@ -66,7 +64,7 @@ export const AuditLogEventClassRow = ({return (<Field orientation="horizontal" className={twMerge("gap-8 px-6 py-6", className)}><FieldContent>- <FieldTitle className="text-base">+ <FieldTitle className="text-base leading-5"><label htmlFor={id}>{auditLogEventClassToNameMap[eventClass]}</label>{badge}</FieldTitle>@@ -96,7 +94,6 @@ export const AuditLogEventClassRow = ({) : (toggle)}- <span className="max-w-48 text-right text-sm text-muted">{status}</span>{action}</div></Field>diff --git a/frontend/src/hooks/api/auditLogSettings/constants.tsx b/frontend/src/hooks/api/auditLogSettings/constants.tsxindex a3bf23dd13..a35f954c17 100644--- a/frontend/src/hooks/api/auditLogSettings/constants.tsx+++ b/frontend/src/hooks/api/auditLogSettings/constants.tsx@@ -15,7 +15,7 @@ export const auditLogEventClassToDescriptionMap: Record<AuditLogEventClass, stri[AuditLogEventClass.DataAccess]:"Reads and lists, plus crypto use operations that hand back or operate on secret material.",[AuditLogEventClass.Authorization]:- "Permission denials, recording the actor, the action, the subject and the endpoint. Repeats by the same actor within a minute are collapsed into one event."+ "Permission denials. Repeats by the same actor within a minute are collapsed into one event."};// Mirrors the backend defaults.diff --git a/frontend/src/pages/organization/AuditLogsPage/components/AuditLogSettingsTab/AuditLogSettingsTab.tsx b/frontend/src/pages/organization/AuditLogsPage/components/AuditLogSettingsTab/AuditLogSettingsTab.tsxindex f585c9c7dc..2b642b0499 100644--- a/frontend/src/pages/organization/AuditLogsPage/components/AuditLogSettingsTab/AuditLogSettingsTab.tsx+++ b/frontend/src/pages/organization/AuditLogsPage/components/AuditLogSettingsTab/AuditLogSettingsTab.tsx@@ -31,6 +31,7 @@ import { AuditLogEventClass } from "@app/hooks/api/auditLogSettings/types";type TForm = Record<AuditLogEventClass, boolean>;const REQUIRES_NEW_PRIVILEGE_SYSTEM = "Requires the new privilege system";+const ALWAYS_RECORDED = "Management events are always recorded";export const AuditLogSettingsTab = withPermission(() => {@@ -64,7 +65,7 @@ export const AuditLogSettingsTab = withPermission(const onSubmit = async (form: TForm) => {const eventClasses = AUDIT_LOG_EVENT_CLASSES.filter(- (eventClass) => dirtyFields[eventClass]+ (eventClass) => eventClass !== AuditLogEventClass.Management && dirtyFields[eventClass]).map((eventClass) => ({ eventClass, isEnabled: form[eventClass] }));if (!eventClasses.length) return;@@ -94,8 +95,12 @@ export const AuditLogSettingsTab = withPermission() : (<div className="divide-y divide-border">{AUDIT_LOG_EVENT_CLASSES.map((eventClass) => {+ const isManagement = eventClass === AuditLogEventClass.Management;const isAuthorization = eventClass === AuditLogEventClass.Authorization;const isLocked = isAuthorization && !shouldUseNewPrivilegeSystem;+ let lockedReason: string | undefined;+ if (isManagement) lockedReason = ALWAYS_RECORDED;+ else if (isLocked) lockedReason = REQUIRES_NEW_PRIVILEGE_SYSTEM;return (<Controllerkey={eventClass}@@ -104,10 +109,10 @@ export const AuditLogSettingsTab = withPermission(render={({ field }) => (<AuditLogEventClassRoweventClass={eventClass}- isEnabled={isLocked ? false : field.value}+ isEnabled={isManagement || (!isLocked && field.value)}variant={scopeVariant}isDisabled={!canEdit}- lockedReason={isLocked ? REQUIRES_NEW_PRIVILEGE_SYSTEM : undefined}+ lockedReason={lockedReason}onCheckedChange={field.onChange}warning={eventClass === AuditLogEventClass.DataAccess && !field.valuediff --git a/frontend/src/pages/project/SettingsPage/components/AuditLogEventClassesSection/AuditLogEventClassesSection.tsx b/frontend/src/pages/project/SettingsPage/components/AuditLogEventClassesSection/AuditLogEventClassesSection.tsxindex 4aeb302680..39decf7a2e 100644--- a/frontend/src/pages/project/SettingsPage/components/AuditLogEventClassesSection/AuditLogEventClassesSection.tsx+++ b/frontend/src/pages/project/SettingsPage/components/AuditLogEventClassesSection/AuditLogEventClassesSection.tsx@@ -25,6 +25,7 @@ import { ProjectMembershipRole } from "@app/hooks/api/roles/types";type TForm = Record<AuditLogEventClass, boolean>;const REQUIRES_NEW_PRIVILEGE_SYSTEM = "Requires the new privilege system";+const ALWAYS_RECORDED = "Management events are always recorded";export const AuditLogEventClassesSection = () => {const { currentProject } = useProject();@@ -55,7 +56,7 @@ export const AuditLogEventClassesSection = () => {const onSubmit = async (form: TForm) => {const eventClasses = AUDIT_LOG_EVENT_CLASSES.filter(- (eventClass) => dirtyFields[eventClass]+ (eventClass) => eventClass !== AuditLogEventClass.Management && dirtyFields[eventClass]).map((eventClass) => ({ eventClass, isEnabled: form[eventClass] }));if (!eventClasses.length) return;@@ -82,8 +83,12 @@ export const AuditLogEventClassesSection = () => {) : (<div className="divide-y divide-border">{AUDIT_LOG_EVENT_CLASSES.map((eventClass) => {+ const isManagement = eventClass === AuditLogEventClass.Management;const isAuthorization = eventClass === AuditLogEventClass.Authorization;const isLocked = isAuthorization && !shouldUseNewPrivilegeSystem;+ let lockedReason: string | undefined;+ if (isManagement) lockedReason = ALWAYS_RECORDED;+ else if (isLocked) lockedReason = REQUIRES_NEW_PRIVILEGE_SYSTEM;return (<Controllerkey={eventClass}@@ -92,10 +97,10 @@ export const AuditLogEventClassesSection = () => {render={({ field }) => (<AuditLogEventClassRoweventClass={eventClass}- isEnabled={isLocked ? false : field.value}+ isEnabled={isManagement || (!isLocked && field.value)}variant="project"isDisabled={!isAdmin}- lockedReason={isLocked ? REQUIRES_NEW_PRIVILEGE_SYSTEM : undefined}+ lockedReason={lockedReason}onCheckedChange={field.onChange}warning={eventClass === AuditLogEventClass.DataAccess && !field.value