Skip to content

Fix extensions apiserver to authenticate requests via RequestHeader CA#4557

Open
anandppatil wants to merge 1 commit intoagones-dev:mainfrom
anandppatil:fix/extensions-apiserver-auth
Open

Fix extensions apiserver to authenticate requests via RequestHeader CA#4557
anandppatil wants to merge 1 commit intoagones-dev:mainfrom
anandppatil:fix/extensions-apiserver-auth

Conversation

@anandppatil
Copy link
Copy Markdown

What

Fixes an authentication bypass in the agones-extensions apiserver where
any in-cluster workload could directly call the aggregated APIService
endpoint and allocate GameServers in any namespace, bypassing Kubernetes RBAC.

Why

The extensions apiserver serves /apis/allocation.agones.dev/v1/... as a
Kubernetes aggregated APIService but did not implement the client-side
authentication required by the Kubernetes aggregation layer specification.

How

  • Loads extension-apiserver-authentication ConfigMap from kube-system
  • Configures TLS ClientAuth: VerifyClientCertIfGiven with the RequestHeader CA
  • Verifies proxy client certificate CN against requestheader-allowed-names
  • Extracts X-Remote-User / X-Remote-Group headers
  • Performs SubjectAccessReview for create gameserverallocations

Testing

  • Unit tests for LoadRequestHeaderConfig, AuthenticateRequest, and
    parseJSONStringArray added in pkg/util/apiserver/auth_test.go
  • Manual verification: deploy to a Kind cluster, confirm that direct
    curl to the service without a valid proxy client cert returns 401.

Fixes: https://issuetracker.google.com/issues/505221322

@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 7, 2026

This PR exceeds the recommended size of 1000 lines. Please make sure you are NOT addressing multiple issues with one PR. Note this PR might be rejected due to its size.

The agones-extensions apiserver serves the allocation.agones.dev/v1
aggregated APIService but did not verify that incoming requests came
from the kube-apiserver aggregator. Any workload with network reach
to agones-controller-service:443 could bypass Kubernetes RBAC and
allocate GameServers in arbitrary namespaces.

This change:
- Loads the extension-apiserver-authentication ConfigMap at startup
  to obtain the RequestHeader CA and allowed proxy client CNs.
- Configures the TLS server to verify client certificates against
  the RequestHeader CA (VerifyClientCertIfGiven).
- Authenticates API requests by verifying the proxy client cert CN
  and extracting X-Remote-User/X-Remote-Group headers.
- Authorizes allocation requests via SubjectAccessReview before
  processing them.

The system:auth-delegator ClusterRoleBinding (already present in
the Helm chart) grants the agones-controller ServiceAccount the
necessary permission to create SubjectAccessReviews.

Ref: https://kubernetes.io/docs/tasks/extend-kubernetes/configure-aggregation-layer/
Signed-off-by: anandppatil <anandppatil4383@gmail.com>
@anandppatil anandppatil force-pushed the fix/extensions-apiserver-auth branch from e4e6c38 to 4ae6955 Compare May 7, 2026 12:18
@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 7, 2026

This PR exceeds the recommended size of 1000 lines. Please make sure you are NOT addressing multiple issues with one PR. Note this PR might be rejected due to its size.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant