Security Best Practices
Best practices for securing Flux deployments.
Version 2.2 of the documentation is no longer actively maintained. The site that you are currently viewing is an archived snapshot. For up-to-date documentation, see the latest version.
Flux has a multi-component design, and integrates with many other systems.
This document outlines an overview of security considerations for Flux components, project processes, artifacts, as well as Flux configurable options and what they enable for both Kubernetes cluster and external system security.
See our security processes document for vulnerability reporting, handling, and disclosure of information for the Flux project and community.
Please also have a look at our security-related blog posts. We are writing there to inform you what we are doing to keep Flux and you safe!
The Flux CLI and the controllers’ images are signed using Sigstore Cosign and GitHub OIDC. The container images along with their signatures are published on GitHub Container Registry and Docker Hub.
To verify the authenticity of Flux’s container images, install cosign v2 and run:
$ cosign verify ghcr.io/fluxcd/source-controller:v1.0.0 \
--certificate-identity-regexp=^https://github\\.com/fluxcd/.*$ \
--certificate-oidc-issuer=https://token.actions.githubusercontent.com
Verification for ghcr.io/fluxcd/source-controller:v1.0.0 --
The following checks were performed on each of these signatures:
- The cosign claims were validated
- Existence of the claims in the transparency log was verified offline
- The code-signing certificate was verified using trusted certificate authority certificates
We also wrote a blog post which discusses this in some more detail.
For the Flux project we publish a Software Bill of Materials (SBOM) with each release. The SBOM is generated with Syft in the SPDX format.
The spdx.json
file is available for download on the GitHub release page e.g.:
curl -sL https://github.com/fluxcd/flux2/releases/download/v2.0.0/flux_2.0.0_sbom.spdx.json | jq
The Flux controllers’ images come with SBOMs for each CPU architecture, you can extract the SPDX JSON using Docker’s inspect command:
docker buildx imagetools inspect ghcr.io/fluxcd/source-controller:v1.0.0 \
--format "{{ json (index .SBOM \"linux/amd64\").SPDX}}"
Or by using Docker’s sbom command:
docker sbom fluxcd/source-controller:v1.0.0
Please also refer to this blog post which discusses the idea and value of SBOMs.
Starting with Flux version 2.0.0, the build, release and provenance portions of the Flux project supply chain provisionally meet SLSA Build Level 3.
Please see the SLSA Assessment documentation for more details on how the provenance is generated and how Flux complies with the SLSA requirements.
The provenance of the Flux release artifacts (binaries, container images, SBOMs, deploy manifests) can be verified using the official SLSA verifier tool and Sigstore Cosign. Please see the SLSA provenance verification documentation for more details on how to verify the provenance of Flux release artifacts.
The Flux controllers’ images come with provenance attestations which follow the SLSA provenance schema version 0.2.
The provenance attestations are generated at build time with Docker Buildkit and include facts about the build process such as:
To extract the SLSA provenance JSON for a specific CPU architecture, you can use Docker’s inspect command:
docker buildx imagetools inspect ghcr.io/fluxcd/source-controller:v1.0.0 \
--format "{{ json (index .Provenance \"linux/amd64\").SLSA}}"
Note that the linux/amd64
can be replaced with another architecture variation of the image,
for example linux/arm64
or linux/arm/v7
.
The Flux controllers’ images are based on Alpine, they contain very few OS packages and the controller’s binary which is statically built using Go.
To properly scan Flux container images, the scanner must be able to detect the Alpine apk packages and the Go modules included in the controller’s Go binary. The Go modules and apk packages are also available for inspection in the attached SBOM.
The Flux team recommends users to scan the container images for CVEs using Trivy, which is an OSS scanner made by Aqua Security.
To scan a controller image with Trivy:
trivy image ghcr.io/fluxcd/source-controller:v1.0.0
We ask users to keep Flux up-to-date on their clusters, this is the only way to ensure a Flux deployment is free of CVEs. New Flux versions are published periodically, and the container images are based on the latest Alpine and Go releases. We offer a fully automated solution for keeping Flux up-to-date, please see the Flux GitHub Actions documentation for more details.
The Flux controllers are constantly being monitored for new CVEs, and the attack surface for any vulnerability is assessed by maintainers. If a controller is considered to be vulnerable, a new patch release will be issued immediately.
Given this, and while we do appreciate the effort, reporting CVEs found by a security scanner through issues and/or the security mailing list is not necessary.
The controller deployments are configured in conformance with the Kubernetes restricted pod security standard:
While Flux integrates with other systems it is built on Kubernetes core controller-runtime and properly adheres to Kubernetes security model including RBAC 1.
Flux installs a set of RBAC manifests. These include:
crd-controller
ClusterRole
, which:crd-controller
ClusterRoleBinding
:crd-controller
ClusterRole
abovecluster-reconciler
ClusterRoleBinding
:cluster-admin
ClusterRole
kustomize-controller
and helm-controller
flux-view
ClusterRole
:view
role read-only access to Flux Custom Resourcesflux-edit
ClusterRole
:edit
and admin
roles write access to Flux Custom ResourcesFlux uses these two ClusterRoleBinding
strategies in order to allow for clear access separation using tools
purpose-built for policy enforcement (OPA, Kyverno, admission controllers).
For example, the design allows all controllers to access Flux CRDs (binds to crd-controller
ClusterRole
),
but only binds the Flux reconciler controllers for Kustomize and Helm to cluster-admin
ClusterRole
,
as these are the only two controllers that manage resources in the cluster.
However in a
soft multi-tenancy setup,
Flux does not reconcile a tenant’s repo under the cluster-admin
role.
Instead, you specify a different service account in your manifest, and the Flux controllers will use
the Kubernetes Impersonation API under cluster-admin
to impersonate that service account 2.
In this way, policy restrictions for this service account are applied to the manifests being reconciled.
If the binding is not defined for the correct service account and namespace, it will fail.
The roles and permissions for this multi-tenancy approach
are described in detail here:
https://github.com/fluxcd/flux2-multi-tenancy.
Flux’s general premise is to follow Kubernetes best RBAC practices which forbid cross-namespace references to potential sensitive data, i.e. Secrets and ConfigMaps. For sources and events, Flux allows referencing resources from other Namespaces. In these cases, the policy is governed by each controller’s --no-cross-namespace-refs
flag. See the
Flux multi-tenancy configuration page for further information on this flag.
Beyond the baked-in security features of Flux, there are further best practices that can be implemented to ensure your Flux deployment is as secure as it can be. For more information, checkout the Flux Security Best Practices.
However, by design cross-namespace references are an exception to RBAC. Platform admins have the option to turn off cross-namespace references as described in the installation documentation. ↩︎
Platform admins have to option to enforce impersonation as described in the installation documentation. ↩︎
Best practices for securing Flux deployments.
Contextual Authorization for securing Flux deployments.
Managing Secrets in a GitOps way using Flux.
Flux assessment of SLSA Level 3 requirements.