Skip to content

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

chore(gateway): label the update audit event, trim comments

bernie-gb65ade7e7185
diff --git a/backend/src/db/migrations/20260915135021_resource-gcp-auth.ts b/backend/src/db/migrations/20260915135021_resource-gcp-auth.ts
index 2500450f70..41f9fd93d8 100644
--- a/backend/src/db/migrations/20260915135021_resource-gcp-auth.ts
+++ b/backend/src/db/migrations/20260915135021_resource-gcp-auth.ts
@@ -9,7 +9,6 @@ export async function up(knex: Knex): Promise<void> {
t.uuid("id", { primaryKey: true }).defaultTo(knex.fn.uuid());
t.uuid("authMethodId").notNullable().unique();
t.foreign("authMethodId").references("id").inTable(TableName.ResourceAuthMethod).onDelete("CASCADE");
- // "gce" verifies a metadata-server ID token, "iam" a service-account-signed JWT.
t.string("type", 32).notNullable().defaultTo("gce");
t.string("allowedServiceAccounts", 1024).notNullable().defaultTo("");
t.string("allowedProjects", 1024).notNullable().defaultTo("");
diff --git a/backend/src/ee/routes/v3/gateway-router.ts b/backend/src/ee/routes/v3/gateway-router.ts
index f218b96218..8759f224be 100644
--- a/backend/src/ee/routes/v3/gateway-router.ts
+++ b/backend/src/ee/routes/v3/gateway-router.ts
@@ -79,16 +79,11 @@ const GcpAuthMethodInputSchema = z
allowedProjects: validateAllowedProjects.describe(GATEWAYS.AUTH_METHOD.allowedProjects),
allowedZones: validateAllowedZones.describe(GATEWAYS.AUTH_METHOD.allowedZones)
})
- // Zones are deliberately not sufficient on their own: the zone namespace is global, so any GCP
- // customer can put an instance in us-central1-a and satisfy a zone-only config. Only service
- // accounts and projects name something inside this organization.
.refine((data) => data.allowedServiceAccounts.trim().length > 0 || data.allowedProjects.trim().length > 0, {
message:
"At least one of allowedServiceAccounts or allowedProjects must be set. A zone on its own restricts nothing, because any GCP customer can create an instance in a given zone.",
path: ["allowedServiceAccounts"]
})
- // An IAM-signed JWT carries no instance details, so a project or zone allowlist on it would never
- // be checkable and every login would be refused.
.refine((data) => data.type !== GcpAuthType.Iam || (!data.allowedProjects.trim() && !data.allowedZones.trim()), {
message:
"Allowed projects and zones only apply to the Compute Engine token type. Restrict an IAM service account token by service account instead.",
@@ -330,6 +325,8 @@ export const registerGatewayV3Router = async (server: FastifyZodProvider) => {
},
onRequest: verifyAuth([AuthMode.JWT, AuthMode.IDENTITY_ACCESS_TOKEN]),
handler: async (req) => {
+ const gateway = await server.services.gatewayV2.getGatewayById({ gatewayId: req.params.gatewayId });
+
if (req.body.authMethod) {
const setInput = toSetAuthMethodArg(req.body.authMethod);
@@ -347,6 +344,7 @@ export const registerGatewayV3Router = async (server: FastifyZodProvider) => {
metadata: {
resourceType: "gateway",
resourceId: req.params.gatewayId,
+ resourceName: gateway.name,
method: result.method as "aws" | "gcp" | "kubernetes" | "token",
methodConfigId:
result.method === ResourceAuthMethodType.Aws ||
@@ -398,7 +396,6 @@ export const registerGatewayV3Router = async (server: FastifyZodProvider) => {
});
}
- const gateway = await server.services.gatewayV2.getGatewayById({ gatewayId: req.params.gatewayId });
const view = await server.services.resourceAuthMethod.getByGatewayId({
resource: { type: "gateway", id: req.params.gatewayId },
actor: req.permission
diff --git a/backend/src/ee/services/resource-auth-method/gcp-auth-fns.test.ts b/backend/src/ee/services/resource-auth-method/gcp-auth-fns.test.ts
index f8dd0fe5e3..1aae50bdeb 100644
--- a/backend/src/ee/services/resource-auth-method/gcp-auth-fns.test.ts
+++ b/backend/src/ee/services/resource-auth-method/gcp-auth-fns.test.ts
@@ -86,7 +86,6 @@ describe("validateGcpAllowlists", () => {
);
});
- // Zone names are a global namespace, so a zone-only config restricts nobody.
test("refuses a zone-only config", () => {
expect(reasonCodeOf(() => validate({ allowedZones: "us-central1-a" }))).toBe("no_allowlist_configured");
});
@@ -115,8 +114,6 @@ describe("validateGcpAllowlists", () => {
).toBe("zone_not_allowed");
});
- // A GKE workload identity token carries no compute_engine claim. Skipping the project check
- // there would authenticate any Google service account against a project-only allowlist.
test("refuses a project allowlist when the token carries no Compute Engine details", () => {
expect(
reasonCodeOf(() =>
@@ -170,8 +167,6 @@ vi.mock("@app/lib/crypto", () => ({
describe("verifyGcpTokenAndExtractCaller", () => {
const errorContext = { resourceId: "gw-1", orgId: "org-1" };
const futureExp = Math.floor(Date.now() / 1000) + 600;
- // Header and signature are irrelevant: the mocked validators stand in for the real verification,
- // and only the payload is decoded here for the lifetime check.
const jwtWith = (payload: object) => `x.${Buffer.from(JSON.stringify(payload)).toString("base64url")}.y`;
beforeEach(() => {
@@ -203,8 +198,6 @@ describe("verifyGcpTokenAndExtractCaller", () => {
});
});
- // The validators raise bare UnauthorizedErrors with no detail; those must still be wrapped so the
- // failure carries a reason code and reaches the audit log.
test("wraps an unauthorized error raised by the validator itself", async () => {
vi.mocked(validateIamIdentity).mockRejectedValue(new UnauthorizedError({ message: "Invalid audience" }));
await expect(
diff --git a/backend/src/ee/services/resource-auth-method/gcp-auth-fns.ts b/backend/src/ee/services/resource-auth-method/gcp-auth-fns.ts
index 35c1a5d934..a48550983c 100644
--- a/backend/src/ee/services/resource-auth-method/gcp-auth-fns.ts
+++ b/backend/src/ee/services/resource-auth-method/gcp-auth-fns.ts
@@ -13,10 +13,7 @@ type TVerifyGcpTokenInput = {
errorContext: Record<string, unknown>;
};
-// Google caps a signJwt expiry at 12 hours ahead, but accepts a payload with no `exp` at all, and
-// jsonwebtoken only enforces an expiry that is present. Without this, anyone who briefly holds
-// signJwt on an allowed service account can mint a proof that outlives the revocation of that
-// permission.
+// signJwt accepts a payload with no `exp`, which would make the proof replayable forever.
const MAX_IAM_TOKEN_LIFETIME_SECONDS = 12 * 60 * 60;
export const assertIamTokenLifetime = (payload: { exp?: number } | null, nowSeconds: number) => {
@@ -58,8 +55,6 @@ export const verifyGcpTokenAndExtractCaller = async ({
});
}
- // Its own reason code, so an operator can tell a token their tooling signed without a bounded
- // expiry apart from a bad signature or a wrong audience.
if (type === GcpAuthType.Iam) {
const payload = crypto.jwt().decode(jwt) as { exp?: number } | null;
const lifetimeProblem = assertIamTokenLifetime(payload, Math.floor(Date.now() / 1000));
@@ -101,9 +96,7 @@ export const validateGcpAllowlists = ({
const projects = splitAllowlist(allowedProjects);
const zones = splitAllowlist(allowedZones);
- // A zone allowlist is not an allowlist on its own. Zone names are a global namespace, so any GCP
- // customer can place an instance in one; only a service account or project names something inside
- // this organization.
+ // Zone names are a global namespace, so a zone-only config restricts nobody.
if (!serviceAccounts.length && !projects.length) {
throw new UnauthorizedError({
message: zones.length
@@ -126,9 +119,7 @@ export const validateGcpAllowlists = ({
if (!projects.length && !zones.length) return;
- // A GKE Workload Identity token carries no compute_engine claim, so there is nothing to match a
- // project or zone against. Skipping the check there would authenticate any service account that
- // cleared the (possibly empty) service account allowlist.
+ // A GKE workload identity token has no compute_engine claim; skipping would authenticate anything.
const { computeEngineDetails } = identityDetails;
if (type !== GcpAuthType.Gce || !computeEngineDetails) {
throw new UnauthorizedError({
diff --git a/backend/src/ee/services/resource-auth-method/gcp-auth-validators.ts b/backend/src/ee/services/resource-auth-method/gcp-auth-validators.ts
index e4970d3a17..6402bf88ee 100644
--- a/backend/src/ee/services/resource-auth-method/gcp-auth-validators.ts
+++ b/backend/src/ee/services/resource-auth-method/gcp-auth-validators.ts
@@ -1,11 +1,7 @@
import RE2 from "re2";
import { z } from "zod";
-// Service accounts are matched against the token's `email` claim verbatim, so no wildcards here:
-// an entry that does not parse as a service account address can never match anything. Every Google
-// service account domain is accepted, not just the user-managed `<project>.iam` one: a Compute
-// Engine default account is `<project-number>[email protected]`, and App
-// Engine's is `<project-id>@appspot.gserviceaccount.com`.
+// Every Google SA domain: the Compute Engine default lives on developer.gserviceaccount.com.
const serviceAccountEntry = new RE2("^[a-z0-9][a-z0-9-]{0,99}@[a-z0-9][a-z0-9.-]{0,99}\\.gserviceaccount\\.com$");
const projectEntry = new RE2("^[a-z][a-z0-9-]{4,28}[a-z0-9]$");
const zoneEntry = new RE2("^[a-z]([a-z0-9-]{0,62}[a-z0-9])?$");
diff --git a/backend/src/ee/services/resource-auth-method/resource-auth-method-fns.ts b/backend/src/ee/services/resource-auth-method/resource-auth-method-fns.ts
index 0d8bb0afe2..82b4dfdb0c 100644
--- a/backend/src/ee/services/resource-auth-method/resource-auth-method-fns.ts
+++ b/backend/src/ee/services/resource-auth-method/resource-auth-method-fns.ts
@@ -198,8 +198,7 @@ export const ResourceAuthMethodType = {
Identity: "identity"
} as const;
-// "gce" verifies an ID token minted by the metadata server, "iam" a JWT the service account signed
-// through iamcredentials. Mirrors the machine identity GCP auth types.
+// Mirrors the machine identity GCP auth types.
export const GcpAuthType = {
Gce: "gce",
Iam: "iam"
diff --git a/backend/src/services/identity-gcp-auth/identity-gcp-auth-fns.ts b/backend/src/services/identity-gcp-auth/identity-gcp-auth-fns.ts
index a484ef178a..eced2ddea2 100644
--- a/backend/src/services/identity-gcp-auth/identity-gcp-auth-fns.ts
+++ b/backend/src/services/identity-gcp-auth/identity-gcp-auth-fns.ts
@@ -26,10 +26,7 @@ export const validateIdTokenIdentity = async ({ audience, jwt: identityToken }:
return { email: payload.email, computeEngineDetails: payload.google?.compute_engine };
};
-// Covers every Google service account domain, not only the user-managed `<project>.iam` one: the
-// Compute Engine default account lives on `developer.gserviceaccount.com` and App Engine's on
-// `appspot.gserviceaccount.com`. This is a sanity check on `sub` before the certificate fetch, so
-// widening it grants nothing: the signature check and the allowlist are the actual controls.
+// A sanity check on `sub` before the certificate fetch, so it covers every Google SA domain.
const serviceAccountEmailRegex = new RE2(/^[a-z0-9][a-z0-9-]*@[a-z0-9][a-z0-9.-]*\.gserviceaccount\.com$/);
/**
diff --git a/frontend/src/pages/organization/NetworkingPage/GatewayDetailsByIDPage/components/GatewayAuthMethod/GcpStartCommandDialog.tsx b/frontend/src/pages/organization/NetworkingPage/GatewayDetailsByIDPage/components/GatewayAuthMethod/GcpStartCommandDialog.tsx
index 538ad31de4..894af6e1d2 100644
--- a/frontend/src/pages/organization/NetworkingPage/GatewayDetailsByIDPage/components/GatewayAuthMethod/GcpStartCommandDialog.tsx
+++ b/frontend/src/pages/organization/NetworkingPage/GatewayDetailsByIDPage/components/GatewayAuthMethod/GcpStartCommandDialog.tsx
@@ -42,10 +42,8 @@ export const GcpStartCommandContent = ({
const [relay, setRelay] = useState<{ id: string; name: string }>(AUTO_RELAY_OPTION);
const resolvedRelayName = isDirect || relay.id === "_auto" ? "" : relay.name;
- // gce is the CLI default, so only the iam type needs the flag spelled out.
const authTypePart = gcpAuthType === "iam" ? " --gcp-auth-type=iam" : "";
- // Without this annotation the chart creates an unbound service account, and the pod authenticates
- // as nothing the gateway allows. The first allowed account is the best guess available here.
+ // Without this the chart creates an unbound service account and the pod authenticates as nothing.
const workloadIdentityAccount =
allowedServiceAccounts.split(",")[0]?.trim() ||
"<gsa-name>@<project-id>.iam.gserviceaccount.com";
diff --git a/frontend/src/pages/organization/NetworkingPage/GatewayDetailsByIDPage/components/GatewayDeploySection/GatewayDeploySection.tsx b/frontend/src/pages/organization/NetworkingPage/GatewayDetailsByIDPage/components/GatewayDeploySection/GatewayDeploySection.tsx
index 7f1a99a5c7..626d3a65f2 100644
--- a/frontend/src/pages/organization/NetworkingPage/GatewayDetailsByIDPage/components/GatewayDeploySection/GatewayDeploySection.tsx
+++ b/frontend/src/pages/organization/NetworkingPage/GatewayDetailsByIDPage/components/GatewayDeploySection/GatewayDeploySection.tsx
@@ -115,7 +115,6 @@ export const GatewayDeploySection = ({
// Derived, so switching auth method can't leave a tab selected that the new method lacks.
let deploymentTabs = ["cli", "systemd"];
if (isKubernetes) deploymentTabs = ["helm", "cli"];
- // A GCP gateway runs on a Compute Engine VM or in GKE, so it gets every target.
if (isGcp) deploymentTabs = ["cli", "systemd", "helm"];
const activeTab = deploymentTabs.includes(deploymentMethod)
? deploymentMethod
diff --git a/frontend/src/pages/organization/NetworkingPage/components/NetworkingAuthMethodForm.tsx b/frontend/src/pages/organization/NetworkingPage/components/NetworkingAuthMethodForm.tsx
index c0fb76942e..315dbf5145 100644
--- a/frontend/src/pages/organization/NetworkingPage/components/NetworkingAuthMethodForm.tsx
+++ b/frontend/src/pages/organization/NetworkingPage/components/NetworkingAuthMethodForm.tsx
@@ -86,8 +86,6 @@ const schema = z
}
if (data.method === "gcp") {
- // Zones alone restrict nothing: the zone namespace is global, so any GCP customer can put an
- // instance in one. Projects are not offered on the iam type, so the message narrows there.
const isIam = data.gcpAuthType === "iam";
if (!data.allowedServiceAccounts.trim() && (isIam || !data.allowedProjects.trim())) {
ctx.addIssue({
@@ -153,8 +151,7 @@ export const toNetworkingAuthMethodInput = (form: FormData) => {
}
if (form.method === "gcp") {
- // Projects and zones are hidden on the iam type, so a value left over from a previous gce
- // config must be dropped rather than submitted against a field the user can no longer see.
+ // Hidden on the iam type, so a leftover gce value must not be submitted.
const isIam = form.gcpAuthType === "iam";
return {
method: "gcp" as const,
diff --git a/helm-charts/infisical-gateway/templates/deployment.yaml b/helm-charts/infisical-gateway/templates/deployment.yaml
index 1331c3db2d..4aa95bf3f3 100644
--- a/helm-charts/infisical-gateway/templates/deployment.yaml
+++ b/helm-charts/infisical-gateway/templates/deployment.yaml
@@ -39,8 +39,7 @@ spec:
{{- end }}
{{- if or $usePVC .Values.gateway.enrollment.method }}
strategy:
- # A gateway is one identity: every login invalidates the previous token, so a second pod
- # starting alongside the first knocks it offline before it is ready.
+ # One identity per gateway: a second pod logging in knocks the first offline.
type: Recreate
{{- end }}
selector:
diff --git a/helm-charts/infisical-gateway/values.yaml b/helm-charts/infisical-gateway/values.yaml
index afc235c190..3c255368d9 100644
--- a/helm-charts/infisical-gateway/values.yaml
+++ b/helm-charts/infisical-gateway/values.yaml
@@ -39,12 +39,10 @@ gateway:
gcp:
# Required when method=gcp. Gateway ID from the Infisical UI.
gatewayId: ""
- # How the gateway proves its GCP identity: "gce" reads an identity token from the instance
- # metadata server, which covers GKE workload identity; "iam" signs a JWT through the IAM
- # Credentials API. Leave empty for the CLI default of "gce".
+ # "gce" reads an identity token from the metadata server (covers GKE workload identity),
+ # "iam" signs one through the IAM Credentials API. Empty means "gce".
type: ""
- # Only for type=iam, and only when the pod has no workload identity to sign with. Path to a
- # service account key file, which you must mount yourself.
+ # Only for type=iam without workload identity. You must mount the key file yourself.
serviceAccountKeyFilePath: ""
# Kubernetes enrollment settings (method=kubernetes).