Repository navigation
🔒 fix(security): reject cross-namespace secretRef at admission + validate inventory auth mode - #377
Merged
Merged
Conversation
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
…lidate auth mode
K-04: a family-sink SecretReference is rejected at admission when its
namespace is neither the sink's own namespace nor in the operator
--allow-secret-ref-namespaces allowlist (process-wide, never a CRD field).
Covers secretRef, tls.caSecretRef, git.auth.secretRef and every per-backend
databaseRef/secretRef; test lock is webhook envtest cross-ns reject/allow.
K-12: --inventory-auth-mode is validated at startup against
{kubernetes, disabled}; only disabled bypasses auth, so a typo can no longer
leave the inventory HTTP server authentication-only. Test lock is the startup
flag enum test.
konih
force-pushed
the
fm/kollect-b2-secretref
branch
from
October 1, 2026 15:27
b28b44c to
df8c8b3
Compare
|
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.



Summary
Closes two admission/startup defects from the six-review unification register
(batch B2, findings K-04 and K-12).
secretRefconfused deputy. A namespacedfamily-sink author could point
spec.secretRef(orcaSecretRef/git.auth.secretRef/databaseRef/ per-backendsecretRef) at anothernamespace's Secret while the manager holds cluster-wide
secrets get. Thevalidating webhook now rejects any
SecretReferencewhose namespace is neitherthe sink's own namespace nor in a process-wide operator allowlist
(
--allow-secret-ref-namespaces/ HelmallowSecretRefNamespaces, empty bydefault = deny). Captain decision C-1(a).
--inventory-auth-modewas a free string; anything but the exact
kubernetesleft the inventory HTTPserver authenticating tokens without authorization. Startup now fails on any
value outside
{kubernetes, disabled}, and onlydisabledbypasses auth.What changed
internal/validation/secret_ref_namespace.goValidateSecretRefNamespaceswalking every reference path on a normalized sink specinternal/webhook/v1alpha1/family_sink_webhook.gocmd/startup_flags.go/cmd/main.go--allow-secret-ref-namespacesflag;validateInventoryAuthModefails startup;RequireInventoryGettrue for every non-disabled modeinternal/inventory/auth.goAuthDisabled()matches onlydisabled(drops the undocumentednonealias)allowSecretRefNamespacesvalue +--allow-secret-ref-namespacesrender + unittestTest lock
internal/webhook/v1alpha1/secret_ref_namespace_envtest_test.go):cross-namespace ref denied through the real API server + webhook when the
allowlist is empty (error names
spec.secretRef.namespace); admitted when thenamespace is allowlisted; same-namespace ref admitted.
cmd/startup_flags_test.go):kubernetes/disabledpass, anything else errors; allowlist flag round-trip.
internal/validation/secret_ref_namespace_test.go.Testing
go test ./internal/webhook/v1alpha1/(envtest) ✅go test ./cmd/... ./internal/inventory/... ./internal/validation/...✅task arch-lint,golangci-lint(changed packages),gofmt,go vet✅helm unittest charts/kollect,task helm-lint,task helm-docs:verify✅internal/sink/git, which hangs on a gitcredential prompt in this environment and passes with
GIT_TERMINAL_PROMPT=0(untouched package).Risk / residual
sink admitted before the control is not re-checked; a resolve-time check
against the same allowlist would close that and is a possible follow-up.
allowlisted namespace, so it should list only namespaces whose Secrets every
sink author is trusted to read. Documented in
values.yamland the security doc.Independent review
A fresh diff-only reviewer returned APPROVE, with the admission-only scope
and allowlist breadth noted above; the docs were tightened to state the control
is admission-time.