Akeyless provider ignores HTTP(S)_PROXY when CABundle/CAProvider is configured
Describe the bug
When a ClusterSecretStore/SecretStore using the akeyless provider sets caBundle (or caProvider), the provider silently stops honoring the HTTP_PROXY/HTTPS_PROXY/NO_PROXY environment variables, even though they are correctly set on the controller Deployment.
This happens because getAkeylessHTTPClient builds a brand-new http.Transport when a custom CA is configured, instead of cloning http.DefaultTransport. This could well be the same case in other providers or elsewhere in the codebase:
https://github.com/external-secrets/external-secrets/blob/v0.10.7/pkg/provider/akeyless/akeyless.go#L640-L657 (same code path present on main, providers/v1/akeyless/akeyless.go):
func (a *akeylessBase) getAkeylessHTTPClient(ctx context.Context, provider *esv1beta1.AkeylessProvider) (*http.Client, error) {
client := &http.Client{Timeout: 30 * time.Second}
if len(provider.CABundle) == 0 && provider.CAProvider == nil {
return client, nil // Transport stays nil -> http.DefaultTransport is used, which sets Proxy: http.ProxyFromEnvironment
}
cert, err := utils.FetchCACertFromSource(ctx, utils.CreateCertOpts{...})
...
tlsConf := &tls.Config{
RootCAs: caCertPool,
MinVersion: tls.VersionTLS12,
}
client.Transport = &http.Transport{TLSClientConfig: tlsConf} // BUG: Proxy field left nil, so no proxy is ever used
return client, nil
}Because the replacement http.Transport{TLSClientConfig: tlsConf} is constructed from scratch instead of http.DefaultTransport.(*http.Transport).Clone(), its Proxy field defaults to nil. Go's http.Transport does not fall back to proxy environment variables unless Proxy: http.ProxyFromEnvironment is explicitly set — a nil value means "never use a proxy," regardless of HTTP_PROXY/HTTPS_PROXY/NO_PROXY.
As a result, any environment where the Akeyless Gateway is only reachable through a corporate/egress HTTP proxy (a common requirement behind restrictive network policies, e.g. inside an Istio mesh with restricted egress) will fail to authenticate as soon as a caBundle/caProvider is configured on the SecretStore, because the request bypasses the proxy entirely and is sent directly, which then fails at the network layer (e.g. connection reset by peer) instead of reaching the Akeyless Gateway.
To Reproduce
Steps to reproduce the behavior:
- Deploy
external-secretswithHTTP_PROXY/HTTPS_PROXY/NO_PROXYset viaextraEnv, in an environment where the Akeyless Gateway endpoint is only reachable via that proxy (e.g. all other egress is blocked/dropped). - Create a
ClusterSecretStorefor theakeylessprovider that setscaBundle(orcaProvider) to validate the Gateway's TLS certificate:apiVersion: external-secrets.io/v1 kind: ClusterSecretStore metadata: name: my-store spec: provider: akeyless: akeylessGWApiURL: "https://akeyless.example.internal/api/v2" authSecretRef: secretRef: accessID: { name: akeyless, key: accessId } accessType: { name: akeyless, key: accessType } accessTypeParam: { name: akeyless, key: accessTypeParam } caBundle: <base64 PEM of the internal CA that signed the Gateway cert> - Create an
ExternalSecretreferencing that store and observe theReconciler errorin the controller logs:error processing spec.data[0] (key: ...), err: authentication failed: Post "https://akeyless.example.internal/api/v2/auth": read tcp <pod-ip>:<port>-><resolved-ip>:443: read: connection reset by peer - Compare with a
ClusterSecretStorethat omitscaBundle/caProvider(relying on the system trust store instead) — the proxy is honored and authentication succeeds.
- Kubernetes version: 1.31 (GKE, Autopilot/Standard with Istio/ASM service mesh)
- ESO version: v2.10.0 (chart
external-secrets 2.10.0), also verified present inmain(providers/v1/akeyless/akeyless.go)
Expected behavior
When caBundle/caProvider is configured on an akeyless SecretStore/ClusterSecretStore, the resulting http.Transport should still respect the process's HTTP_PROXY/HTTPS_PROXY/NO_PROXY environment variables (i.e. Proxy: http.ProxyFromEnvironment), consistent with the behavior when no custom CA is configured. This can be fixed by cloning http.DefaultTransport before overriding TLSClientConfig, e.g.:
transport := http.DefaultTransport.(*http.Transport).Clone()
transport.TLSClientConfig = tlsConf
client.Transport = transportScreenshots
N/A
Additional context
- This appears to affect every provider in the codebase that manually constructs
&http.Transport{...}instead of cloninghttp.DefaultTransportwhen wiring up a customtls.Config(a quick grep ofpkg/provider/providers/v1suggests this pattern is repeated elsewhere), so the same class of bug may exist beyond the Akeyless provider. - Workaround we're using in the meantime: don't set
caBundle/caProvideron theClusterSecretStore, and instead trust the internal CA at the pod's system-trust-store level viaSSL_CERT_FILE/SSL_CERT_DIRenv vars (supported natively by Go'scrypto/x509on Linux, noupdate-ca-certificates/shell required, which also makes it compatible with thedistroless/staticcontroller image).
Source: external-secrets/external-secrets