fix(kubernetes-client-api): honor source precedence between CA materi… - #8012
Open
aloktomarr wants to merge 1 commit into
Open
fix(kubernetes-client-api): honor source precedence between CA materi…#8012aloktomarr wants to merge 1 commit into
aloktomarr wants to merge 1 commit into
Conversation
…al and insecure TLS flags When kube config set insecure-skip-tls-verify (trustCerts=true) but a higher-priority source (system property or environment variable) supplied a CA cert file/data, SSLUtils evaluated isTrustCerts() before the CA material and left trust-all in effect, so the explicitly pinned CA was silently ignored - a TLS verification bypass. configFromSysPropsOrEnvVars now resolves the CA file/data together with the trust-all and hostname-verification flags using source ranks (system property > environment variable > existing/kube config value). When CA material comes from a strictly higher-priority source than the insecure flag, the insecure flag is cleared so the explicitly configured CA is enforced, matching the documented configuration precedence. Reported by @GrosQuildu (Trail of Bits), who provided a proof-of-concept and a suggested fix. Fixes fabric8io#7957
aloktomarr
requested review from
ash-thakur-rh,
manusa and
shawkins
as code owners
July 22, 2026 21:21
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.
Description
insecure-skip-tls-verify: truein a kube config maps totrustCerts=true(trust-all). When a higher-priority source — a system property or environment variable, per the documented precedence — supplies CA cert material (kubernetes.certs.ca.file/kubernetes.certs.ca.data), that explicit CA was silently ignored:SSLUtils#trustManagerschecksisTrustCerts()before the CA material, so trust-all stayed in effect and the connection was left without certificate verification.Fixes #7957.
Root cause
Config.configFromSysPropsOrEnvVarssettrustCertsand the CA file/data independently, with no notion of which source each value came from. A low-priority kube-configtrustCerts=truecould therefore coexist with a high-priority CA file, andSSLUtilsresolved the ambiguity in favor of trust-all.Fix
configFromSysPropsOrEnvVarsnow resolves the CA file/data together with thetrustCertsanddisableHostnameVerificationflags, tagging each value with a source rank (system property > environment variable > existing/kube-config value). When CA material comes from a strictly higher-priority source than the insecure flag, the insecure flag is cleared, so the explicitly configured CA is enforced — matching the documented configuration precedence. Configurations where the insecure flag is at the same or higher priority than the CA are unchanged.Testing
ConfigTlsSourcePrecedenceTest: writes a temp kube config withinsecure-skip-tls-verify: true, sets a higher-priority-Dkubernetes.certs.ca.file, and asserts the CA file is applied andisTrustCerts()isfalse. Confirmed it fails before the fix and passes after.kubernetes-client-apimodule suite: 667 tests, 0 failures, 0 errors — no regressions.Reported by @GrosQuildu (Trail of Bits), who also provided a proof-of-concept and a suggested fix.
Type of change
Checklist
insecure-skip-tls-verify: truein a kube config maps totrustCerts=true(trust-all). When a higher-priority source — a system property or environment variable, per the documented precedence — supplies CA cert material (kubernetes.certs.ca.file/kubernetes.certs.ca.data), that explicit CA was silently ignored:SSLUtils#trustManagerschecksisTrustCerts()before the CA material, so trust-all stayed in effect and the connection was left without certificate verification.Fixes #7957.
Root cause
Config.configFromSysPropsOrEnvVarssettrustCertsand the CA file/data independently, with no notion of which source each value came from. A low-priority kube-configtrustCerts=truecould therefore coexist with a high-priority CA file, andSSLUtilsresolved the ambiguity in favor of trust-all.Fix
configFromSysPropsOrEnvVarsnow resolves the CA file/data together with thetrustCertsanddisableHostnameVerificationflags, tagging each value with a source rank (system property > environment variable > existing/kube-config value). When CA material comes from a strictly higher-priority source than the insecure flag, the insecure flag is cleared, so the explicitly configured CA is enforced — matching the documented configuration precedence. Configurations where the insecure flag is at the same or higher priority than the CA are unchanged.Testing
ConfigTlsSourcePrecedenceTest: writes a temp kube config withinsecure-skip-tls-verify: true, sets a higher-priority-Dkubernetes.certs.ca.file, and asserts the CA file is applied andisTrustCerts()isfalse. Confirmed it fails before the fix and passes after.kubernetes-client-apimodule suite: 667 tests, 0 failures, 0 errors — no regressions.Reported by @GrosQuildu (Trail of Bits), who also provided a proof-of-concept and a suggested fix.
Type of change
Checklist