Repository navigation
Conversation
…sing
getUserEmail sliced the identity header value with an unchecked offset
(header.Get(header)[len(prefix):]), which panicked with "slice bounds
out of range" on every mutating endpoint (POST/DELETE /kfam/v1/bindings,
DELETE /kfam/v1/profiles/{name}) whenever the identity header was
missing or shorter than the configured --userid-prefix. Nothing in the
process recovers handler panics, so clients received a dropped
connection instead of a status code and no request metric was
incremented. A third mode silently truncated a header value that did
not start with the prefix to a wrong identity.
- getUserEmail now returns (string, error): it errors on a missing or
empty header value, on a value that does not start with the configured
prefix, and when nothing remains after stripping the prefix. The three
callers answer 401 (documented in api/swagger.yaml for all three
endpoints) with an explanatory body and increment request_kf_failure
with stable metric kinds.
- ReadBinding: add the missing return after the profile-list error write
(previously dereferenced a nil list and panicked).
- QueryClusterAdmin: report a fixed kind in the write-failure branch
instead of dereferencing a nil err.
- Regression tests: unit tests for getUserEmail across both common
configurations (IAP-style prefix and kubeflow-userid with an empty
prefix) and handler-level httptest through NewRouter covering the 401
responses, prefix-mismatch rejection, the preserved owner/non-owner
status codes, and both latent panic paths.
Behavior change: with an empty prefix (the values shipped in the repo
manifests), header-less requests to the mutating endpoints now answer
401 with a body instead of silently evaluating the caller as "" and
denying with 403.
Fixes kubeflow#505
Signed-off-by: Rehan Akhtar <rehan.xt5@gmail.com>
GET /kfam/v1/role/clusteradmin answered is-cluster-admin for any user named in the caller-supplied ?user= query parameter without consulting the request's authenticated identity: with no identity header at all, ?user=<admin> returned 200 true, an authenticated non-admin could ask about any other user, and the admin roster was enumerable one username at a time. This is the only KFAM handler that answers an authorization question without deriving the caller from the identity header. The handler now derives the caller via getUserEmail (the panic-safe, prefix-validating helper introduced for the missing-identity-header fix), defaults the queried user to the caller, and reserves cross-user queries for cluster admins: - no usable identity -> 401 (documented in api/swagger.yaml) - self-query (with or without ?user=) -> 200, unchanged behavior - non-admin cross-user query -> 403 - admin cross-user query -> 200, admin tooling preserved Swagger documents the identity binding and the 401/403 responses; the component README documents the identity/authorization model. Regression tests: TestQueryClusterAdminIdentityBinding covers the three former attack modes (now 401/403) plus the preserved self-query and admin flows, the prefix-mismatch rejection, and the no-panic behavior for missing/short/prefix-only headers. TestQueryClusterAdminOnWriteFailure now carries an identity header so it still reaches the response write. Signed-off-by: Rehan Akhtar <rehan.xt5@gmail.com>
KFAM now binds the clusteradmin status query to the caller's identity
header, so getWorkgroupInfo - which called it without forwarding any
headers - would receive 401 on identity-aware clusters. Forward the
user identity captured by attachUser (user.auth) in both the classic
and Angular dashboard backends, following the same pattern
handleContributor already uses for the binding endpoints. The call
sites are guarded by req.user.hasAuth, so user.auth is always
populated; the || {} fallback keeps a future unguarded caller safe by
surfacing KFAM's 401 instead of a silent wrong answer.
All v1RoleClusteradminGet jasmine spy matchers in both backends' test
suites are updated to the two-argument form (withArgs/toHaveBeenCalledWith
match on all arguments, so every mock and assertion gains the headers
object).
Signed-off-by: Rehan Akhtar <rehan.xt5@gmail.com>
google-oss-prow
Bot
requested review from
juliusvonkohout and
thesuperzapper
November 19, 2026 21:34
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
Author
|
/assign |
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 join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Fixes #515.
Stacked on #506: the branch carries that PR's commit first (already under review), then the two new commits below. The stack is forced, since the
QueryClusterAdminrewrite calls thegetUserEmailsignature #506 introduces. Once #506 merges, the diff here shrinks to just the two new commits (worst case I'll rebase onto main).KFAM handler
QueryClusterAdminincomponents/access-management/kfam/api_default.gocurrently answers?user=<anyone>for whoever asks. It now derives the caller from the identity header:usermissing from the query: defaults to the caller, soGET /v1/role/clusteradminreads as "am I an admin". The swagger claims the param is required but nothing enforced it; optional matches real usage.err.Error()on a nil err there).Dashboard backends
Both
centraldashboardandcentraldashboard-angularcall this endpoint ingetWorkgroupInfoto decide whether the logged-in user sees admin UI, and neither forwarded any headers:The identity headers captured by
attachUsernow travel with the call, the same way the contributor add/remove routes already forward them for bindings. Without this half, a caller-bound KFAM would 401 every dashboard request and take down the workgroup info for all logged-in users.Docs and tests
userdescription updated to match the binding semanticsmake testgreen at 47.4% kfam coverageTwo deliberate behavior changes to flag: requests without the identity header get 401 where they used to get an answer, and non-admins querying other users get 403. Both are the point of the fix, but if a caller I haven't thought of depends on the old behavior, I'm happy to adjust.