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(agent-vault): require a license for session logs on self-hosted (#8990)
Saif Ur Rahman49ee460fce0f
diff --git a/backend/src/ee/services/agent-vault/AGENTS.md b/backend/src/ee/services/agent-vault/AGENTS.mdindex 2363480fc6..cf14cedb83 100644--- a/backend/src/ee/services/agent-vault/AGENTS.md+++ b/backend/src/ee/services/agent-vault/AGENTS.md@@ -473,7 +473,7 @@ hostile input: nothing it sends may erase or hide its own records, so the proxy- **Default storage problems go to the server logs, never to an org.** The operator, not an org admin, owns thatbucket: at boot, API pods list it, write a tagged test file, read it back and send a CORS preflight for `SITE_URL`,and log what failed; health skips default storage, and failed reads tell everyone, admins too, to contact support.-- **Each storage type has its own plan flag**: `agentVaultManagedStorage` (default on) and `agentVaultByoS3`. The flag+- **Each storage type has its own plan flag**: `agentVaultManagedStorage` and `agentVaultByoS3`. Cloud plans always include default storage unless the org's plan or an override turns it off (`withCloudPlanDefaults`), and self-hosted needs a license that includes it. The flagfor the storage in use gates uploads and reads, so an org without it can't record or view session logs: unlikemost paid features, which read from Infisical's database, each read is a billed S3 request. Keep the read check.Turning off is never gated, and turning off clears the saved storage, so it always frees the connection. The rowdiff --git a/backend/src/ee/services/license/cloud-plan-defaults.test.ts b/backend/src/ee/services/license/cloud-plan-defaults.test.tsnew file mode 100644index 0000000000..4cbc35dd8b--- /dev/null+++ b/backend/src/ee/services/license/cloud-plan-defaults.test.ts@@ -0,0 +1,44 @@+import { describe, expect, test } from "vitest";++import { projectV2ToFeatureSet } from "@app/services/license-client/entitlement-projection";+import { TEntitlementsResponse } from "@app/services/license-client/license-client-types";++import { withCloudPlanDefaults } from "./cloud-plan-defaults";+import { getDefaultOnPremFeatures } from "./license-fns";++const entitlements = (features: TEntitlementsResponse["features"]) =>+ ({ slug: null, features, products: [] }) as unknown as TEntitlementsResponse;++const cloudPlan = (features: TEntitlementsResponse["features"]) => {+ const ent = entitlements(features);+ return withCloudPlanDefaults(projectV2ToFeatureSet(getDefaultOnPremFeatures(), ent), ent);+};++describe("cloud plan defaults for session log default storage", () => {+ test("is on when the License Server doesn't send the key", () => {+ expect(cloudPlan({}).agentVaultManagedStorage).toBe(true);+ });++ test("is on when the License Server sends its default, even an off one", () => {+ const plan = cloudPlan({ agent_vault_managed_storage: { value: false, source: "default" } });+ expect(plan.agentVaultManagedStorage).toBe(true);+ });++ test("is off when the org's plan turns it off", () => {+ const plan = cloudPlan({ agent_vault_managed_storage: { value: false, source: "plan" } });+ expect(plan.agentVaultManagedStorage).toBe(false);+ });++ test("is off when an override turns it off", () => {+ const plan = cloudPlan({ agent_vault_managed_storage: { value: false, source: "override" } });+ expect(plan.agentVaultManagedStorage).toBe(false);+ });++ test("is on when the License Server doesn't say where the value came from", () => {+ expect(cloudPlan({ agent_vault_managed_storage: { value: false } }).agentVaultManagedStorage).toBe(true);+ });++ test("is on in the stand-in plan used while the License Server can't be reached", () => {+ expect(withCloudPlanDefaults(getDefaultOnPremFeatures(), null).agentVaultManagedStorage).toBe(true);+ });+});diff --git a/backend/src/ee/services/license/cloud-plan-defaults.ts b/backend/src/ee/services/license/cloud-plan-defaults.tsnew file mode 100644index 0000000000..a9eac958f2--- /dev/null+++ b/backend/src/ee/services/license/cloud-plan-defaults.ts@@ -0,0 +1,14 @@+import { TEntitlementsResponse } from "@app/services/license-client/license-client-types";++import { TFeatureSet } from "./license-types";++// Every cloud plan includes default storage for session logs, free orgs included, unless the org's plan or an override+// turns it off. The License Server's default for the key is off, which is what self-hosted licenses get, so only a+// value a plan or override set is taken here. Without entitlements (the stand-in plan while the License Server can't+// be reached) it's on. getFeature() reads the License Server directly and skips this rule, so session logs have to+// read the flag from the plan.+export const withCloudPlanDefaults = (plan: TFeatureSet, entitlements: TEntitlementsResponse | null): TFeatureSet => {+ const source = entitlements?.features.agent_vault_managed_storage?.source;+ if (source && source !== "default") return plan;+ return { ...plan, agentVaultManagedStorage: true };+};diff --git a/backend/src/ee/services/license/license-fns.ts b/backend/src/ee/services/license/license-fns.tsindex f90a1b95e4..9830ad727d 100644--- a/backend/src/ee/services/license/license-fns.ts+++ b/backend/src/ee/services/license/license-fns.ts@@ -110,8 +110,8 @@ export const getDefaultOnPremFeatures = (): TFeatureSet => ({honeyTokenLimit: 0,secretsBrokering: true,agentVaultByoS3: false,- // On by default, like secretsBrokering, until the License Server sets it per plan.- agentVaultManagedStorage: true,+ // Cloud turns it on in withCloudPlanDefaults; self-hosted needs a license that includes it.+ agentVaultManagedStorage: false,agentVaultSessionLogRetentionDays: 30,secretSyncLimit: null,maxPamAccounts: null,diff --git a/backend/src/ee/services/license/license-service.ts b/backend/src/ee/services/license/license-service.tsindex 73138df163..48548b895d 100644--- a/backend/src/ee/services/license/license-service.ts+++ b/backend/src/ee/services/license/license-service.ts@@ -18,6 +18,7 @@ import { TOrgDALFactory } from "@app/services/org/org-dal";import { TProjectDALFactory } from "@app/services/project/project-dal";import { TPermissionServiceFactory } from "../permission/permission-service-types";+import { withCloudPlanDefaults } from "./cloud-plan-defaults";import { TLicenseDALFactory } from "./license-dal";import { getDefaultOnPremFeatures, getLicenseKeyConfig } from "./license-fns";import {@@ -207,7 +208,10 @@ export const licenseServiceFactory = ({if (!entitlements) {throw new BadRequestError({ message: "License Server entitlements are unavailable" });}- const currentPlan = projectV2ToFeatureSet(getDefaultOnPremFeatures(), entitlements);+ const currentPlan = withCloudPlanDefaults(+ projectV2ToFeatureSet(getDefaultOnPremFeatures(), entitlements),+ entitlements+ );currentPlan.workspacesUsed = await projectDAL.countOfBillableOrgProjects(rootOrgId);@@ -291,13 +295,14 @@ export const licenseServiceFactory = ({`getPlan: encountered an error when fetching pan [orgId=${orgId}] [projectId=${projectId}] [error]`);const fallbackTtl = jitteredLicenseCloudPlanTtl();+ const fallbackPlan = withCloudPlanDefaults(onPremFeatures, null);await keyStore.setItemWithExpiry(KeyStorePrefixes.LicenseCloudPlan(orgId),fallbackTtl,- JSON.stringify(onPremFeatures)+ JSON.stringify(fallbackPlan));await keyStore.setItemWithExpiry(KeyStorePrefixes.LicenseCloudPlanFallback(orgId), fallbackTtl, "1");- return onPremFeatures;+ return fallbackPlan;} finally {logger.info(`getPlan: Process done for [orgId=${orgId}] [projectId=${projectId}]`);}diff --git a/backend/src/ee/services/license/license-types.ts b/backend/src/ee/services/license/license-types.tsindex 80169c94d4..4ff29e88d2 100644--- a/backend/src/ee/services/license/license-types.ts+++ b/backend/src/ee/services/license/license-types.ts@@ -114,7 +114,7 @@ export type TFeatureSet = {honeyTokenLimit: 0;secretsBrokering: true;agentVaultByoS3: false;- agentVaultManagedStorage: true;+ agentVaultManagedStorage: boolean;agentVaultSessionLogRetentionDays: number | null;secretSyncLimit: null;maxPamAccounts: null;diff --git a/backend/src/ee/services/license/self-hosted-license-base.test.ts b/backend/src/ee/services/license/self-hosted-license-base.test.tsindex 52c827853f..372fcce0b9 100644--- a/backend/src/ee/services/license/self-hosted-license-base.test.ts+++ b/backend/src/ee/services/license/self-hosted-license-base.test.ts@@ -78,3 +78,24 @@ describe("self-hosted license CA cap", () => {expect(plan.maxCas).toBe(1);});});++describe("self-hosted session log default storage", () => {+ test("an unlicensed instance doesn't get it", async () => {+ const plan = await loadPlan({ licenseKey: "" });+ expect(plan.agentVaultManagedStorage).toBe(false);+ });++ test("a license gets it only when its entitlements turn it on", async () => {+ const off = await loadPlan({+ licenseKey: "online-license-key",+ onlineEntitlements: entitlements({ agent_vault_managed_storage: { value: false, source: "default" } })+ });+ expect(off.agentVaultManagedStorage).toBe(false);++ const on = await loadPlan({+ licenseKey: "online-license-key",+ onlineEntitlements: entitlements({ agent_vault_managed_storage: { value: true, source: "plan" } })+ });+ expect(on.agentVaultManagedStorage).toBe(true);+ });+});diff --git a/backend/src/services/license-client/feature-mapping.ts b/backend/src/services/license-client/feature-mapping.tsindex 9a803bc186..ec79c085aa 100644--- a/backend/src/services/license-client/feature-mapping.ts+++ b/backend/src/services/license-client/feature-mapping.ts@@ -367,7 +367,7 @@ const pamMappings: TFeatureMapping[] = [];// Agent Vault session logs: external storage (the customer's own bucket), default storage (the instance's bucket),-// and how many days default storage keeps them. The last two keys are placeholders until the License Server has them.+// and how many days default storage keeps them. The retention key is a placeholder until the License Server has it.const agentVaultMappings: TFeatureMapping[] = [{v2Key: "agent_vault_byo_s3",diff --git a/docs/documentation/platform/agent-vault/session-logs.mdx b/docs/documentation/platform/agent-vault/session-logs.mdxindex 05162b3d9d..e74dd99add 100644--- a/docs/documentation/platform/agent-vault/session-logs.mdx+++ b/docs/documentation/platform/agent-vault/session-logs.mdx@@ -10,7 +10,7 @@ import AgentVaultSessionLogsCorsRule from "/snippets/app-connections/aws/agent-vA session log is a record of every request an agent makes during a [session](/documentation/platform/agent-vault/sessions): the method, host, path, status code, whether the proxy attached a credential, and for an [MCP server](/documentation/platform/agent-vault/mcp-servers), the tool the agent called. The [proxy](/documentation/platform/agent-vault/proxies) adds every request it receives to the session log, including requests to hosts that no [access bundle](/documentation/platform/agent-vault/access-bundles) covers.-The proxy encrypts the records before they leave your network, and Infisical stores them for you. If you self-host Infisical, your server administrator [sets up where Infisical stores them](/self-hosting/guides/session-log-storage).+The proxy encrypts the records before they leave your network, and Infisical stores them for you. If you self-host Infisical, session logs need an enterprise license, and your server administrator [sets up where Infisical stores them](/self-hosting/guides/session-log-storage).## Viewing session logsdiff --git a/docs/self-hosting/guides/session-log-storage.mdx b/docs/self-hosting/guides/session-log-storage.mdxindex 449c1da21b..211a6d1fb7 100644--- a/docs/self-hosting/guides/session-log-storage.mdx+++ b/docs/self-hosting/guides/session-log-storage.mdx@@ -6,6 +6,10 @@ description: "Give your instance an Amazon S3 bucket so organizations can recordAgent Vault [session logs](/documentation/platform/agent-vault/session-logs) record every request an AI agent makes. Organizations can store them in their own S3 bucket, called external storage, or in default storage: one S3 bucket that you set up for the whole instance.+<Info>+ Session logs are a paid feature if you self-host Infisical. Contact [email protected] to purchase an enterprise license to use them.+</Info>+After you set up default storage, organizations on your instance can record session logs with nothing to set up.## Prerequisites