Skip to content

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

fix(gateway): bound the TokenReview response size

bernie-gdbb609479c59
diff --git a/backend/src/ee/services/resource-auth-method/kubernetes-auth-fns.ts b/backend/src/ee/services/resource-auth-method/kubernetes-auth-fns.ts
index 25d6f35900..58e491046b 100644
--- a/backend/src/ee/services/resource-auth-method/kubernetes-auth-fns.ts
+++ b/backend/src/ee/services/resource-auth-method/kubernetes-auth-fns.ts
@@ -20,6 +20,9 @@ import {
} from "@app/services/identity-kubernetes-auth/identity-kubernetes-auth-validators";
const TOKEN_REVIEW_TIMEOUT_MS = 10_000;
+// A TokenReview response is a few KB; the largest part is the echoed token, itself capped at 8KB
+// by the route schema. Bounded so an operator-supplied host cannot make us buffer an arbitrary body.
+const TOKEN_REVIEW_MAX_RESPONSE_BYTES = 64 * 1024;
// The host is operator-supplied and the backend POSTs to it on every login, so without this an
// org admin could use the auth config to reach hosts inside our own network. Does a DNS lookup,
@@ -123,6 +126,7 @@ export const reviewServiceAccountToken = async ({
},
signal: AbortSignal.timeout(TOKEN_REVIEW_TIMEOUT_MS),
timeout: TOKEN_REVIEW_TIMEOUT_MS,
+ maxContentLength: TOKEN_REVIEW_MAX_RESPONSE_BYTES,
// safeRequest pins the connection to the addresses it validated, so a hostname that
// re-resolves to a private address between config time and login cannot be reached.
ca: caCertificate || undefined,
diff --git a/helm-charts/infisical-gateway/values.yaml b/helm-charts/infisical-gateway/values.yaml
index b355d56472..4d27f335aa 100644
--- a/helm-charts/infisical-gateway/values.yaml
+++ b/helm-charts/infisical-gateway/values.yaml
@@ -1,7 +1,5 @@
image:
repository: infisical/cli
- # gateway.enrollment.method=kubernetes needs a CLI that understands --enroll-method=kubernetes.
- # Override this with a release that contains it until the default below is bumped.
tag: "0.43.84"
pullPolicy: IfNotPresent