Skip to content

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

feat(identity-kubernetes-auth): add IP address validation to Kubernetes connectivity checks

Victor Santosfed2bbffc727
diff --git a/backend/src/services/identity-kubernetes-auth/identity-kubernetes-auth-validators.ts b/backend/src/services/identity-kubernetes-auth/identity-kubernetes-auth-validators.ts
index 45b578fd84..acfb1d7d01 100644
--- a/backend/src/services/identity-kubernetes-auth/identity-kubernetes-auth-validators.ts
+++ b/backend/src/services/identity-kubernetes-auth/identity-kubernetes-auth-validators.ts
@@ -4,6 +4,7 @@ import https from "https";
import { request } from "@app/lib/config/request";
import { BadRequestError } from "@app/lib/errors";
import { logger } from "@app/lib/logger";
+import { blockLocalAndPrivateIpAddresses } from "@app/lib/validator";
import { handleAxiosError, KubernetesAuthErrorContext } from "./identity-kubernetes-auth-error-handlers";
@@ -24,6 +25,8 @@ export const validateKubernetesHostConnectivity = async ({
rejectUnauthorized: Boolean(caCert)
});
+ await blockLocalAndPrivateIpAddresses(kubernetesHost);
+
await request.get(`${kubernetesHost}/version`, {
httpsAgent,
timeout: 10000,
@@ -71,6 +74,8 @@ export const validateTokenReviewerJwtPermissions = async ({
const testToken = "test-token-for-permission-validation";
+ await blockLocalAndPrivateIpAddresses(kubernetesHost);
+
const response = await request.post(
`${kubernetesHost}/apis/authentication.k8s.io/v1/tokenreviews`,
{