Skip to content

Infisical is the open-source platform for securing secrets, certificates, access, and AI Agents.

do not allow turning on when not on new permission system

Thiago Araujo da Silva242b25ef8f73
diff --git a/backend/CLAUDE.md b/backend/CLAUDE.md
index 1a6067b692..5b692b84f0 100644
--- a/backend/CLAUDE.md
+++ b/backend/CLAUDE.md
@@ -1024,7 +1024,11 @@ inserts the new set, so there is no merge with what was stored before.
`PermissionBoundaryError` (not `ForbiddenRequestError`, which verifyAuth and plan gates also throw),
only for orgs on the new privilege system whose plan has audit log retention, and collapsed per
actor, project, action, subject, route and method for one minute. `recordPermissionDenied` on the
-audit log service never throws to the request.
+audit log service never throws to the request. Because a legacy org can never record a denial, the
+settings update methods reject a request that turns the authorization class on for one
+(`assertAuthorizationClassAllowed`), and the UI locks the toggle with a link to the upgrade, so the
+restriction is surfaced in the API error, the response's `shouldUseNewPrivilegeSystem`, the UI, and
+the docs rather than stored as a setting that does nothing.
The collapse itself is generic. `createCollapsedAuditLog` on the audit log service takes any
`TCreateAuditLogDTO` plus `collapseKeyParts` (the event type is always part of the key) and an
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.ts
index 711eb7a9dd..be581a6467 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
@@ -57,9 +57,9 @@ const orgActor = {
parentOrgId: "org-1"
} as never;
-const createHarness = ({ rows = [] as TRow[] } = {}) => {
+const createHarness = ({ rows = [] as TRow[], shouldUseNewPrivilegeSystem = true } = {}) => {
const orgDAL = {
- findById: vi.fn(async (id: string) => ({ id, shouldUseNewPrivilegeSystem: true }))
+ findById: vi.fn(async (id: string) => ({ id, shouldUseNewPrivilegeSystem }))
};
const auditLogSettingsDAL = {
find: vi.fn(async (filter: { orgId: string; projectId?: string | null }) =>
@@ -176,6 +176,38 @@ describe("updateOrgSettings", () => {
expect(auditLogSettingsDAL.transaction).not.toHaveBeenCalled();
});
+ test("refuses to turn on authorization for an org on the legacy privilege system", async () => {
+ const { service, auditLogSettingsDAL } = createHarness({ shouldUseNewPrivilegeSystem: false });
+
+ await expect(
+ service.updateOrgSettings({
+ actor: orgActor,
+ eventClasses: [
+ { eventClass: AuditLogEventClass.DataAccess, isEnabled: true },
+ { eventClass: AuditLogEventClass.Authentication, isEnabled: true },
+ { eventClass: AuditLogEventClass.Authorization, isEnabled: true }
+ ]
+ })
+ ).rejects.toThrow("Permission denials are only recorded for organizations on the new privilege system");
+ expect(auditLogSettingsDAL.transaction).not.toHaveBeenCalled();
+ });
+
+ test("still lets an org on the legacy privilege system save with authorization off", async () => {
+ const { service, auditLogSettingsDAL } = createHarness({ shouldUseNewPrivilegeSystem: false });
+
+ const result = await service.updateOrgSettings({
+ actor: orgActor,
+ eventClasses: [
+ { eventClass: AuditLogEventClass.DataAccess, isEnabled: false },
+ { eventClass: AuditLogEventClass.Authentication, isEnabled: true },
+ { eventClass: AuditLogEventClass.Authorization, isEnabled: false }
+ ]
+ });
+
+ expect(auditLogSettingsDAL.transaction).toHaveBeenCalledTimes(1);
+ expect(result.shouldUseNewPrivilegeSystem).toBe(false);
+ });
+
test("replaces the scope's rows and answers from the request, 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.ts
index 8bcb4208d8..227d0ef2e6 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
@@ -95,6 +95,20 @@ const toFullOverrides = (eventClasses: TAuditLogEventClassSetting[]): TFullOverr
return Object.fromEntries(eventClasses.map((el) => [el.eventClass, el.isEnabled])) as TFullOverrides;
};
+// Denials are never recorded on the legacy privilege system, so accepting the toggle would store a
+// setting that silently does nothing.
+const assertAuthorizationClassAllowed = (
+ org: { shouldUseNewPrivilegeSystem?: boolean | null },
+ overrides: TFullOverrides
+) => {
+ if (overrides[AuditLogEventClass.Authorization] && !org.shouldUseNewPrivilegeSystem) {
+ throw new BadRequestError({
+ message:
+ "Permission denials are only recorded for organizations on the new privilege system. Upgrade the privilege system under Access Control before turning on the authorization class."
+ });
+ }
+};
+
export const auditLogSettingsServiceFactory = ({
auditLogSettingsDAL,
orgDAL,
@@ -205,6 +219,7 @@ export const auditLogSettingsServiceFactory = ({
await assertOrgSettingsPermission(actor, OrgPermissionActions.Edit);
const org = await findOrgOrThrow(actor.orgId);
const overrides = toFullOverrides(eventClasses);
+ assertAuthorizationClassAllowed(org, overrides);
await writeScopeSettings({ orgId: org.id, projectId: null }, overrides);
return toResponse(overrides, org);
};
@@ -250,6 +265,7 @@ export const auditLogSettingsServiceFactory = ({
const project = await findProjectOrThrow(dto.projectId);
const org = await findOrgOrThrow(project.orgId);
const overrides = toFullOverrides(eventClasses);
+ assertAuthorizationClassAllowed(org, overrides);
await writeScopeSettings({ orgId: org.id, projectId: project.id }, overrides);
return toResponse(overrides, org);
};
diff --git a/backend/src/lib/api-docs/constants.ts b/backend/src/lib/api-docs/constants.ts
index 866c0b267a..44fabf2bd3 100644
--- a/backend/src/lib/api-docs/constants.ts
+++ b/backend/src/lib/api-docs/constants.ts
@@ -2086,7 +2086,7 @@ 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.",
eventClasses:
- "Every event class except management, each exactly once. The request replaces the current settings. Management events are always recorded, so a request that includes the management class is rejected.",
+ "Every event class except management, each exactly once. The request replaces the current settings. Management events are always recorded, so a request that includes the management class is rejected. The authorization class can only be turned on for organizations on the new privilege system; otherwise the request is rejected.",
UPDATE_ORG: {
isEnabled:
"Whether to record events of this class for the organization. This only covers organization-level events; each project has its own setting."
diff --git a/docs/documentation/platform/audit-logs.mdx b/docs/documentation/platform/audit-logs.mdx
index 8d428d3a9c..2d7bc819d6 100644
--- a/docs/documentation/platform/audit-logs.mdx
+++ b/docs/documentation/platform/audit-logs.mdx
@@ -304,7 +304,7 @@ If a user or machine identity calls an endpoint that its role doesn't allow, Inf
- `projectId`: the project the request was scoped to, if any
- `suppressedRepeats`, `suppressedFrom`, and `suppressedUntil`: on a summary event, how many identical denials Infisical counted instead of recording, and the minute they fell in
-Denials are only recorded for organizations on the new privilege system. If your organization still uses legacy privilege management, the **Authorization** toggle is disabled. To upgrade, go to **Access Control** in your organization and select **Learn More & Upgrade**.
+Denials are only recorded for organizations on the new privilege system. If your organization still uses legacy privilege management, the **Authorization** toggle is disabled, and an API request that turns the `authorization` class on is rejected with a `400` response that says so. The `shouldUseNewPrivilegeSystem` field in the settings response tells you which system your organization is on. To upgrade, go to **Access Control** in your organization and select **Learn More & Upgrade**.
To keep a misconfigured client from filling the log, Infisical records the first `permission-denied` event per actor, project, action, subject, and endpoint in each minute. Denials that repeat inside that minute are counted rather than recorded. When the minute ends, Infisical writes one more `permission-denied` event for the same combination with the count in `suppressedRepeats` and the minute in `suppressedFrom` and `suppressedUntil`. If nothing repeated, no summary event is written.
diff --git a/frontend/src/components/auditLogSettings/AuditLogEventClassesForm.tsx b/frontend/src/components/auditLogSettings/AuditLogEventClassesForm.tsx
index e8f5defaf3..7a7f921046 100644
--- a/frontend/src/components/auditLogSettings/AuditLogEventClassesForm.tsx
+++ b/frontend/src/components/auditLogSettings/AuditLogEventClassesForm.tsx
@@ -79,7 +79,10 @@ export const AuditLogEventClassesForm = ({
const onSubmit = async (form: TForm) => {
const eventClasses = CONFIGURABLE_AUDIT_LOG_EVENT_CLASSES.map((eventClass) => ({
eventClass,
- isEnabled: form[eventClass]
+ isEnabled:
+ eventClass === AuditLogEventClass.Authorization && !shouldUseNewPrivilegeSystem
+ ? false
+ : form[eventClass]
}));
try {