This repository was archived by the owner on Mar 20, 2026. It is now read-only.
Security fix: Use audience sts.min.io to invoke TokenReview. - #2418
Merged
pjuarezd merged 4 commits intoApr 14, 2025
Conversation
pjuarezd
requested review from
allanrogerr,
cniackz,
dvaldivia,
harshavardhana,
jiuker,
ramondeklein and
shtripat
April 6, 2025 05:43
cniackz
previously approved these changes
Apr 6, 2025
Contributor
|
Thank you @pjuarezd |
pjuarezd
force-pushed
the
use-audience-for-token-validation
branch
from
April 6, 2025 06:35
23d9560 to
a41bda5
Compare
bburky
reviewed
Apr 6, 2025
harshavardhana
previously requested changes
Apr 6, 2025
ramondeklein
reviewed
Apr 7, 2025
harshavardhana
previously approved these changes
Apr 8, 2025
ramondeklein
previously requested changes
Apr 8, 2025
5 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Prevent token leakage / privilege escalation
MinIO Operator STS: A Quick Overview
MinIO Operator STS is a native IAM Authentication for Kubernetes. MinIO Operator offers support for Secure Tokens (a.k.a. STS) which are a form of temporary access credentials for your MinIO Tenant. In essence, this allows you to control access to your MinIO tenant from your applications without having to explicitly create credentials for each application.
For an application to gain access into a MinIO Tenant, a
PolicyBindingresource is required, granting explicit access to the applications by validating the kubernetes Service Account authorization token.The service account token is validated as follows:
AssumeRoleWithWebIdentityAPI MinIO Operator provides.PolicyBindingin the Tenant namespace.Understanding Audiences in Kubernetes TokenReview
In step 2 the
TokenReviewAPI call attempts to authenticate a token to a known user, TokenReviewStatus is the result of theTokenReviewrequest.Audiences are audience identifiers chosen by the authenticator that are compatible with both the TokenReview and token.
An identifier is any identifier in the intersection of the TokenReviewSpec audiences and the token's audiences.
A client of the TokenReview API that sets the
spec.audiencesfield should validate that a compatible audience identifier is returned in the status.audiences field to ensure that the TokenReview server is audience aware.If no audiences are provided, the audience will default to the audience of the Kubernetes apiserver.
Solution: Properly Issuing and Using Audience-Specific ServiceAccount Tokens
This PR ensures the Operator STS service request the Service Account JWT to belong to the audience
sts.min.ioin the TokenReviewRequest.This PR ensures the examples and documentation provided guides in how to create Service accounts with "disabled auto mount services tokens", by doing this the pods where the service account is used no longer mounts the service account automatically in the path
/var/run/secrets/kubernetes.io/serviceaccount.For illustrative purposes, here is how you disable auto mount of service account tokens at the service account level.
Additionally documentation and examples show how to request an audience-specific token with audience
sts.min.io, by asking for an ServiceAccount Token to be audience specific.For illustrative purposes, here is how you request an audience specific service account token in a pod:
How this prevent a token leakage or possible privilege escalation?.
This setup prevents privilege escalation and token leakage by combining multiple defense-in-depth mechanisms that ensure service account tokens are only usable by their intended audience, short-lived, and not exposed unnecessarily.
Audience restriction (aud: sts.min.io)
Problem: A ServiceAccount token is often valid for multiple audiences (e.g., the default Kubernetes API server). Without scoping, it can be replayed to other internal systems, which may unintentionally trust it.
Mitigation: The PR enforces that tokens are explicitly created for the sts.min.io audience using the Kubernetes TokenRequest API, and the MinIO Operator:
Sends audiences: ["sts.min.io"] in the TokenReview.
Verifies that the token was issued with this audience via status.audiences.
Effect: Even if a token is stolen or misused, it will fail validation if used outside the sts.min.io STS endpoint (e.g., reused at the API server or another service).
Token Leakage Mitigation
Disabling auto-mounted service account tokens
Problem: By default, Kubernetes mounts long-lived service account tokens into all pods at
/var/run/secrets/kubernetes.io/serviceaccount, making them vulnerable to theft if the container is compromised.Mitigation: This PR guides users to set
automountServiceAccountToken: falsein their ServiceAccount definitions.Effect: Prevents automatic token injection into all pods, reducing the attack surface.
Requesting short-lived, audience-specific tokens via serviceAccountToken projection
Problem: Long-lived tokens can be reused indefinitely if leaked.
Mitigation: You use projected service account tokens with:
Effect: Even if the token is leaked, it is:
Affected Versions and Risk Assessment
The issue affects MinIO Operator versions v5.0.x and above, when the STS feature was first introduced.
The risk is minimal, as:
Type of Change
Security fix: prevent service account token leakage.
Screenshots (if applicable e.g before/after)
Checklist