From 9591f8c6ce1317d7f945eac434e83d4d4436a84e Mon Sep 17 00:00:00 2001 From: Jamie Sinn Date: Fri, 28 Aug 2026 12:29:32 -0400 Subject: [PATCH 01/13] feat!: Enable FIPS 140-3 mode Also bump to 1.26, the new minimum version based on go 1.27 being released (we needed the fips detail output too) With Go 1.24+, and specifically 1.26+ it's a lot easier to be FIPS compliant for more rigorous and restricted deployment enviornments. This is a super lightweight add on in terms of complexity to the codebase (as this is just really modifying the build path. If a deployment wants to use a non-FIPS algorithm, then they can terminate the TLS connection outside of the flagd instance. If you need the outbound connections to use an insecure protocol then the flag `--require-fips=false` can be disabled. This has no impact on plaintext/insecure mdoe without TLS. Signed-off-by: Jamie Sinn --- .devcontainer/devcontainer.json | 2 +- .github/workflows/build.yaml | 58 +++++++ .github/workflows/release-please.yaml | 23 ++- .golangci.yml | 20 +++ .goreleaser.yaml | 31 ---- Makefile | 22 ++- core/go.mod | 6 +- core/pkg/fips/fips.go | 74 +++++++++ core/pkg/fips/fips_test.go | 76 +++++++++ core/pkg/utils/hash.go | 8 +- docs/reference/fips-140-3.md | 155 ++++++++++++++++++ docs/reference/fips-crypto-closure.txt | 85 ++++++++++ docs/reference/flagd-cli/flagd_start.md | 1 + flagd-proxy/build.Dockerfile | 17 +- flagd-proxy/cmd/start.go | 15 ++ flagd-proxy/go.mod | 4 +- flagd-proxy/tests/loadtest/go.mod | 4 +- flagd/build.Dockerfile | 17 +- flagd/cmd/start.go | 16 ++ flagd/cmd/version.go | 2 + flagd/go.mod | 4 +- .../flag-evaluation/connect_service.go | 3 + flagd/profile.Dockerfile | 17 +- mkdocs.yml | 1 + renovate.json | 2 +- snap/snapcraft.yaml | 4 + test/integration/go.mod | 4 +- test/loadtest/go.mod | 4 +- test/zero-downtime-flagd-proxy/go.mod | 4 +- 29 files changed, 620 insertions(+), 59 deletions(-) delete mode 100644 .goreleaser.yaml create mode 100644 core/pkg/fips/fips.go create mode 100644 core/pkg/fips/fips_test.go create mode 100644 docs/reference/fips-140-3.md create mode 100644 docs/reference/fips-crypto-closure.txt diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index f6af54863..b0156b3bd 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -1,7 +1,7 @@ { "name": "flagd dev container", // Image details: https://github.com/devcontainers/images/tree/main/src/go - "image": "mcr.microsoft.com/devcontainers/go:1.24", + "image": "mcr.microsoft.com/devcontainers/go:1.26", // Features to add to the dev container. More info: https://containers.dev/features. "features": { "ghcr.io/devcontainers/features/github-cli:1": {}, diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index 4d67df540..6f57a2976 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -15,6 +15,12 @@ on: - "README.md" - "docs/**" +env: + # CMVP-certified Go Cryptographic Module v1.0.0 (certificate #5247). + GOFIPS140: v1.0.0 + # The toolchain determines which FIPS snapshots exist, so pin it. + GOTOOLCHAIN: local + jobs: lint: runs-on: ubuntu-latest @@ -63,6 +69,58 @@ jobs: - name: Upload coverage to Codecov uses: codecov/codecov-action@e0b68c6749509c5f83f984dd99a76a1c1a231044 # v4 + fips: + name: FIPS 140-3 + runs-on: ubuntu-latest + env: + GOPATH: /home/runner/work/open-feature/flagd + GOBIN: /home/runner/work/open-feature/flagd/bin + steps: + - name: Checkout repository + uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4 + - name: Setup go + uses: actions/setup-go@0c52d547c9bc32b1aa3301fd7a9cb496313a4491 # v5 + with: + go-version-file: 'flagd/go.mod' + - run: make workspace-init + + # Fails if any tested code path reaches a non-approved algorithm. + - name: Test with strict FIPS enforcement + run: make test-fips + + - name: Build and verify the artifact carries the certified module + run: | + set -euo pipefail + make build-flagd + go version -m ./bin/flagd | grep -q 'GOFIPS140=v1\.0\.0' + go version -m ./bin/flagd | grep -q 'DefaultGODEBUG=fips140=on' + ./bin/flagd version | grep -q 'FIPS 140-3 mode: enabled' + + - name: Verify the FIPS opt-out behaves both ways + run: | + set -euo pipefail + GODEBUG=fips140=off ./bin/flagd version | grep -q 'FIPS 140-3 mode: disabled' + + # Default: refuse to start once FIPS mode has been turned off. + if GODEBUG=fips140=off ./bin/flagd start -f file:./config/samples/example_flags.flagd.json; then + echo "::error::flagd started with FIPS mode disabled and no opt-out"; exit 1 + fi + + # --require-fips=false: start anyway, with a warning. + GODEBUG=fips140=off ./bin/flagd start --require-fips=false \ + -f file:./config/samples/example_flags.flagd.json > /tmp/optout.log 2>&1 & + pid=$! + sleep 5 + kill "$pid" || true + grep -q 'running with FIPS 140-3 mode disabled' /tmp/optout.log \ + || { echo "::error::--require-fips=false did not start flagd"; cat /tmp/optout.log; exit 1; } + + - name: Check the cryptographic dependency closure has not drifted + run: | + make fips-closure + git diff --exit-code docs/reference/fips-crypto-closure.txt \ + || { echo "::error::cryptographic dependency closure changed; review docs/reference/fips-140-3.md and commit the regenerated closure"; exit 1; } + docker-local: runs-on: ubuntu-latest diff --git a/.github/workflows/release-please.yaml b/.github/workflows/release-please.yaml index cb53ccc0b..bc5edca65 100644 --- a/.github/workflows/release-please.yaml +++ b/.github/workflows/release-please.yaml @@ -8,9 +8,14 @@ env: PUBLISHABLE_ITEMS: '["flagd","flagd-proxy"]' REGISTRY: ghcr.io REPO_OWNER: ${{ github.repository_owner }} - DEFAULT_GO_VERSION: '~1.25' + DEFAULT_GO_VERSION: '~1.26' PUBLIC_KEY_FILE: publicKey.pub GOPRIVATE: buf.build/gen/go + # CMVP-certified Go Cryptographic Module v1.0.0 (certificate #5247). go build + # reads this from the environment, so it covers every build step below. + GOFIPS140: v1.0.0 + # The toolchain determines which FIPS snapshots exist, so pin it. + GOTOOLCHAIN: local name: Release Please jobs: @@ -153,7 +158,7 @@ jobs: VERSION_NO_PREFIX: ${{ needs.release-please.outputs[format('{0}_version', matrix.path)] }} COMMIT: ${{ github.sha }} DATE: ${{ needs.release-please.outputs.date }} - BUILD_ARGS: '-a -ldflags "-X main.version=${VERSION} -X main.commit=${COMMIT} -X main.date=${DATE}"' + BUILD_ARGS: '-a -trimpath -ldflags "-X main.version=${VERSION} -X main.commit=${COMMIT} -X main.date=${DATE}"' steps: - name: Checkout uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4 @@ -198,10 +203,18 @@ jobs: run: | env CGO_ENABLED=0 GOOS=windows GOARCH=amd64 go build ${{ env.BUILD_ARGS }} -o ./${{ matrix.path }}_windows_x86_64 ./${{ matrix.path }}/main.go zip -r ${{ matrix.path }}_${{ env.VERSION_NO_PREFIX }}_Windows_x86_64.zip ./${{ matrix.path }}_windows_x86_64 ./LICENSE ./CHANGELOG.md ./README.md ./sbom.xml - - name: build windows i386 + # windows/386 is not built: FIPS mode is unsupported there, so the + # binary panics at startup. + - name: Verify binaries were built against the certified crypto module run: | - env CGO_ENABLED=0 GOOS=windows GOARCH=386 go build ${{ env.BUILD_ARGS }} -o ./${{ matrix.path }}_windows_i386 ./${{ matrix.path }}/main.go - zip -r ${{ matrix.path }}_${{ env.VERSION_NO_PREFIX }}_Windows_i386.zip ./${{ matrix.path }}_windows_i386 ./LICENSE ./CHANGELOG.md ./README.md ./sbom.xml + set -euo pipefail + for suffix in darwin_arm64 darwin_x86_64 linux_arm64 linux_x86_64 linux_i386 windows_x86_64; do + bin="./${{ matrix.path }}_${suffix}" + go version -m "$bin" | grep -q 'GOFIPS140=v1\.0\.0' \ + || { echo "::error::$bin is not a FIPS 140-3 build"; exit 1; } + echo "ok: $bin" + done + # Bundle release artifacts - name: Bundle release assets uses: softprops/action-gh-release@de2c0eb89ae2a093876385947365aca7b0e5f844 # v1 diff --git a/.golangci.yml b/.golangci.yml index d985b156b..67a2220bf 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -1,8 +1,28 @@ version: "2" linters: + enable: + - depguard settings: funlen: statements: 50 + depguard: + rules: + # These sit outside the FIPS 140-3 validated module boundary. + # See docs/reference/fips-140-3.md. + fips-140-3: + files: + - "!$test" + deny: + - pkg: golang.org/x/crypto + desc: use the stdlib crypto/* equivalent so the call routes through the validated Go Cryptographic Module + - pkg: crypto/md5 + desc: MD5 is not an approved algorithm and is not part of the validated module + - pkg: crypto/sha1 + desc: SHA-1 is not an approved algorithm and is not part of the validated module + - pkg: crypto/des + desc: DES/3DES is not an approved algorithm + - pkg: crypto/rc4 + desc: RC4 is not an approved algorithm exclusions: generated: lax presets: diff --git a/.goreleaser.yaml b/.goreleaser.yaml deleted file mode 100644 index ac5ef5dd8..000000000 --- a/.goreleaser.yaml +++ /dev/null @@ -1,31 +0,0 @@ -# This is an example .goreleaser.yml file with some sensible defaults. -# Make sure to check the documentation at https://goreleaser.com -before: - hooks: - # You may remove this if you don't use go modules. - - go mod tidy - # you may remove this if you don't need go generate - - go generate ./... -builds: - - env: - - CGO_ENABLED=0 - goos: - - linux - - windows - - darwin -archives: - - name_template: >- - {{ .ProjectName }}_{{ .Version }}_{{- title .Os }}_{{- if eq .Arch "amd64" }}x86_64{{- else if eq .Arch "386" }}i386{{- else }}{{ .Arch }}{{ end }} -# Generate SBOM per each archive -sboms: - - artifacts: archive -checksum: - name_template: 'checksums.txt' -snapshot: - name_template: "{{ incpatch .Version }}-next" -changelog: - sort: asc - filters: - exclude: - - '^docs:' - - '^test:' diff --git a/Makefile b/Makefile index ab93b418d..65874c81a 100644 --- a/Makefile +++ b/Makefile @@ -3,6 +3,10 @@ PREFIX=/usr/local PUBLIC_JSON_SCHEMA_DIR=docs/schema/v0/ ALL_GO_MOD_DIRS := $(shell find . -path ./test/integration -prune -o -type f -name 'go.mod' -exec dirname {} \; | sort) +# CMVP-certified Go Cryptographic Module v1.0.0 (certificate #5247). The literal +# version is required; the "certified"/"inprocess" aliases vary by toolchain. +export GOFIPS140 ?= v1.0.0 + FLAGD_DEV_NAMESPACE ?= flagd-dev ZD_TEST_NAMESPACE_FLAGD_PROXY ?= flagd-proxy-zd-test ZD_TEST_NAMESPACE ?= flagd-zd-test @@ -38,7 +42,8 @@ docker-push-flagd: build: workspace-init # default to flagd make build-flagd build-flagd: - go build -ldflags "-X main.version=dev -X main.commit=$$(git rev-parse --short HEAD) -X main.date=$$(date +%FT%TZ)" -o ./bin/flagd ./flagd + CGO_ENABLED=0 go build -trimpath -ldflags "-X main.version=dev -X main.commit=$$(git rev-parse --short HEAD) -X main.date=$$(date +%FT%TZ)" -o ./bin/flagd ./flagd + go version -m ./bin/flagd | grep -E 'GOFIPS140=|-tags=fips140' .PHONY: test test: test-core test-flagd test-flagd-proxy test-core: @@ -47,6 +52,21 @@ test-flagd: go test -race -covermode=atomic -cover -short ./flagd/pkg/... -coverprofile=flagd-coverage.out test-flagd-proxy: go test -race -covermode=atomic -cover -short ./flagd-proxy/pkg/... -coverprofile=flagd-proxy-coverage.out +# fips140=only makes non-approved algorithms error or panic, so this fails if a +# tested path reaches MD5, SHA-1, RC4, 3DES or ChaCha20-Poly1305. Test mode only; +# released binaries run with fips140=on. +.PHONY: test-fips +test-fips: + GODEBUG=fips140=only go test -short -count=1 ./core/... ./flagd/... ./flagd-proxy/... + +# Regenerate the crypto dependency closure recorded in the FIPS docs. +.PHONY: fips-closure +fips-closure: + @go list -deps ./flagd ./flagd-proxy \ + | grep -E '^(crypto|golang\.org/x/crypto)($$|/)|/crypto($$|/)' \ + | sort -u > docs/reference/fips-crypto-closure.txt + @echo "wrote docs/reference/fips-crypto-closure.txt" + flagd-benchmark-test: go test -bench=Bench -short -benchtime=5s -benchmem ./core/... | tee benchmark.txt flagd-integration-test-harness: diff --git a/core/go.mod b/core/go.mod index f5fad884f..a4ac9a538 100644 --- a/core/go.mod +++ b/core/go.mod @@ -1,6 +1,8 @@ module github.com/open-feature/flagd/core -go 1.25.0 +go 1.26.0 + +toolchain go1.26.4 require ( buf.build/gen/go/open-feature/flagd/grpc/go v1.6.1-20260217192757-1388a552fc3c.1 @@ -29,7 +31,6 @@ require ( go.uber.org/mock v0.5.2 go.uber.org/zap v1.27.0 gocloud.dev v0.42.0 - golang.org/x/crypto v0.52.0 golang.org/x/exp v0.0.0-20250210185358-939b2ce775ac golang.org/x/mod v0.35.0 golang.org/x/oauth2 v0.36.0 @@ -148,6 +149,7 @@ require ( go.opentelemetry.io/proto/otlp v1.10.0 // indirect go.uber.org/multierr v1.11.0 // indirect go.yaml.in/yaml/v2 v2.4.3 // indirect + golang.org/x/crypto v0.52.0 // indirect golang.org/x/net v0.55.0 // indirect golang.org/x/sys v0.45.0 // indirect golang.org/x/term v0.43.0 // indirect diff --git a/core/pkg/fips/fips.go b/core/pkg/fips/fips.go new file mode 100644 index 000000000..218513311 --- /dev/null +++ b/core/pkg/fips/fips.go @@ -0,0 +1,74 @@ +// Package fips reports whether this binary is running the CMVP-certified Go +// Cryptographic Module in FIPS 140-3 approved mode. +package fips + +import ( + "crypto/fips140" + "fmt" + "runtime/debug" + "strings" +) + +// CertifiedModuleVersion is the module flagd builds against: CMVP certificate +// #5247. GOFIPS140 records a resolved snapshot ("v1.0.0-c2097c7c"), so this is +// matched as a prefix. +const CertifiedModuleVersion = "v1.0.0" + +// Status describes the FIPS 140-3 state of this process. +type Status struct { + Enabled bool + + // ModuleVersion is "latest" unless the binary was built with GOFIPS140, so + // Enabled alone does not prove the certified module is in use. + ModuleVersion string + + // BuildSetting is the GOFIPS140 value recorded at build time, if any. + BuildSetting string +} + +// Current inspects the running binary and returns its FIPS 140-3 status. +func Current() Status { + s := Status{ + Enabled: fips140.Enabled(), + ModuleVersion: fips140.Version(), + } + if info, ok := debug.ReadBuildInfo(); ok { + for _, setting := range info.Settings { + if setting.Key == "GOFIPS140" { + s.BuildSetting = setting.Value + break + } + } + } + return s +} + +// BuiltForFIPS reports whether the certified module was compiled in. Release +// artifacts always are; a plain `go build` is not. +func (s Status) BuiltForFIPS() bool { + return strings.HasPrefix(s.BuildSetting, CertifiedModuleVersion) +} + +// Certified reports whether the certified module is both compiled in and active. +func (s Status) Certified() bool { + return s.Enabled && s.BuiltForFIPS() +} + +// Degraded reports a binary built for FIPS that is running outside FIPS mode, +// which happens when GODEBUG=fips140=off is set at process start. +func (s Status) Degraded() bool { + return s.BuiltForFIPS() && !s.Enabled +} + +func (s Status) String() string { + switch { + case s.Certified(): + return fmt.Sprintf("enabled (Go Cryptographic Module %s, GOFIPS140=%s)", s.ModuleVersion, s.BuildSetting) + case s.Degraded(): + return fmt.Sprintf("disabled (built with GOFIPS140=%s but GODEBUG=fips140=off at startup)", s.BuildSetting) + case s.Enabled: + return fmt.Sprintf("enabled, uncertified (Go Cryptographic Module %s; binary not built with GOFIPS140)", s.ModuleVersion) + default: + return "disabled (binary not built with GOFIPS140)" + } +} diff --git a/core/pkg/fips/fips_test.go b/core/pkg/fips/fips_test.go new file mode 100644 index 000000000..5c9c37d8d --- /dev/null +++ b/core/pkg/fips/fips_test.go @@ -0,0 +1,76 @@ +package fips + +import ( + "crypto/fips140" + "strings" + "testing" +) + +func TestStatusClassification(t *testing.T) { + tests := []struct { + name string + status Status + builtForFIPS bool + certified bool + degraded bool + wantInString string + }{ + { + name: "released artifact in approved mode", + status: Status{Enabled: true, ModuleVersion: "v1.0.0", BuildSetting: "v1.0.0-c2097c7c"}, + builtForFIPS: true, + certified: true, + wantInString: "enabled (Go Cryptographic Module v1.0.0", + }, + { + name: "released artifact started with GODEBUG=fips140=off", + status: Status{Enabled: false, ModuleVersion: "v1.0.0", BuildSetting: "v1.0.0-c2097c7c"}, + builtForFIPS: true, + degraded: true, + wantInString: "GODEBUG=fips140=off at startup", + }, + { + name: "local build, FIPS forced on at runtime only", + status: Status{Enabled: true, ModuleVersion: "latest"}, + wantInString: "uncertified", + }, + { + name: "plain local build", + status: Status{Enabled: false, ModuleVersion: "latest"}, + wantInString: "disabled (binary not built with GOFIPS140)", + }, + } + + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + if got := tt.status.BuiltForFIPS(); got != tt.builtForFIPS { + t.Errorf("BuiltForFIPS() = %v, want %v", got, tt.builtForFIPS) + } + if got := tt.status.Certified(); got != tt.certified { + t.Errorf("Certified() = %v, want %v", got, tt.certified) + } + if got := tt.status.Degraded(); got != tt.degraded { + t.Errorf("Degraded() = %v, want %v", got, tt.degraded) + } + if got := tt.status.String(); !strings.Contains(got, tt.wantInString) { + t.Errorf("String() = %q, want it to contain %q", got, tt.wantInString) + } + }) + } +} + +// TestCurrentMatchesRuntime guards the wiring between Current and the runtime, +// so the reported state can never drift from the actual FIPS mode. +func TestCurrentMatchesRuntime(t *testing.T) { + got := Current() + if got.Enabled != fips140.Enabled() { + t.Errorf("Current().Enabled = %v, want %v", got.Enabled, fips140.Enabled()) + } + if got.ModuleVersion != fips140.Version() { + t.Errorf("Current().ModuleVersion = %q, want %q", got.ModuleVersion, fips140.Version()) + } + // When the test binary itself is built with GOFIPS140, the two must agree. + if got.BuiltForFIPS() && !got.Enabled { + t.Error("built against the certified module but FIPS mode is off; flagd would refuse to start") + } +} diff --git a/core/pkg/utils/hash.go b/core/pkg/utils/hash.go index e5f0c29e9..603c3ac77 100644 --- a/core/pkg/utils/hash.go +++ b/core/pkg/utils/hash.go @@ -2,15 +2,17 @@ package utils import ( "bytes" + "crypto/sha3" "encoding/base64" "encoding/json" + "hash" "io" - - "golang.org/x/crypto/sha3" //nolint:gosec ) +// GenerateSha returns a SHA3-256 digest of the canonicalized body. func GenerateSha(body []byte) string { - hasher := sha3.New256() + // hash.Hash rather than *sha3.SHA3: its Write never returns an error. + var hasher hash.Hash = sha3.New256() hasher.Write(canonicalize(body)) return base64.URLEncoding.EncodeToString(hasher.Sum(nil)) } diff --git a/docs/reference/fips-140-3.md b/docs/reference/fips-140-3.md new file mode 100644 index 000000000..34c0f944b --- /dev/null +++ b/docs/reference/fips-140-3.md @@ -0,0 +1,155 @@ +--- +description: FIPS 140-3 mode in flagd, how to verify it, and what it restricts +--- + +# FIPS 140-3 + +flagd is built against the Go Cryptographic Module v1.0.0, which holds NIST CMVP validation certificate #5247 and CAVP certificate A6650. +Every released binary and container image, for both flagd and flagd-proxy, runs that module in its FIPS 140-3 approved mode by default. + +The validation covers the Go Cryptographic Module. +flagd consumes the module and has not been submitted to CMVP. +A FIPS-mode deployment may still need further controls to satisfy FedRAMP, DoD SRG, CMMC or a similar programme; those determinations depend on the whole system and its assessment. + +The scope is cryptography performed inside the flagd process. +It excludes TLS terminated by a proxy or service mesh in front of flagd, the platform and container runtime, and operator-supplied key material. +flagd performs no authentication or authorization on any endpoint and expects to run inside a trust boundary. + +## Building + +Releases are compiled with `GOFIPS140=v1.0.0`. +This selects the frozen, certified module snapshot and makes the binary default to `GODEBUG=fips140=on`. + +```shell +GOFIPS140=v1.0.0 CGO_ENABLED=0 go build -trimpath -o ./bin/flagd ./flagd +``` + +Use the literal version. +The `certified` and `inprocess` aliases resolve differently per Go toolchain: Go 1.25 ships no `certified.txt`, and on Go 1.26 `inprocess` points at module v1.26.0, which is still pending CMVP review. + +## Verifying + +The build settings are recorded in the binary's `runtime/debug.BuildInfo` and survive `-trimpath` and `-ldflags "-s -w"`. + +```shell +go version -m ./bin/flagd | grep -E 'GOFIPS140|DefaultGODEBUG|fips140v1.0' +``` + +```console +build -tags=fips140v1.0 +build DefaultGODEBUG=fips140=on +build GOFIPS140=v1.0.0-c2097c7c +``` + +`v1.0.0-c2097c7c` uniquely identifies the module snapshot. + +The running process reports the same state, both from the `version` command and in its startup log. + +```shell +flagd version +``` + +```console +flagd: v0.16.2 (a1b2c3d), built at: 2026-08-28 +FIPS 140-3 mode: enabled (Go Cryptographic Module v1.0.0, GOFIPS140=v1.0.0-c2097c7c) +``` + +Binaries built without `GOFIPS140`, such as a local `go build` during development, log that FIPS mode is disabled and start normally. + +## Running without FIPS mode + +FIPS mode is fixed at process start and is turned off with `GODEBUG=fips140=off`. +By default flagd refuses to start in that state, so a stray `GODEBUG` cannot quietly drop a deployment out of approved mode. +Pass `--require-fips=false` (or `FLAGD_REQUIRE_FIPS=false`) to allow it: + +```shell +GODEBUG=fips140=off flagd start --require-fips=false --uri file:/etc/flagd/flags.json +``` + +flagd then logs a warning at startup and runs with the standard Go cryptography, lifting the [TLS restrictions](#tls-restrictions) below. + +This is worth considering when flagd terminates no TLS of its own and sits behind a proxy or service mesh that handles it. +In that topology the proxy protects the request path and the FIPS boundary covers only flagd's outbound sync connections and its internal hashing. +If a flag source or the Kubernetes API server in front of flagd negotiates something outside the approved set, the restrictions cost you compatibility without protecting the traffic your clients actually see. + +## TLS restrictions + +In FIPS mode `crypto/tls` will not negotiate a protocol version, cipher suite, curve or signature algorithm outside the approved set. + +| Parameter | Permitted | +| ---------------------- | ------------------------------------------------------------------------------------------------------------- | +| Protocol versions | TLS 1.2, TLS 1.3 | +| Key exchange | `X25519MLKEM768`, `SecP256r1MLKEM768`, `SecP384r1MLKEM1024`, P-256, P-384, P-521 | +| TLS 1.3 cipher suites | `TLS_AES_128_GCM_SHA256`, `TLS_AES_256_GCM_SHA384` | +| TLS 1.2 cipher suites | `ECDHE_{RSA,ECDSA}_WITH_AES_{128,256}_GCM_SHA{256,384}`, `ECDHE_{RSA,ECDSA}_WITH_AES_128_CBC_SHA256` | +| Peer certificates | RSA 2048 bits or larger, ECDSA P-256/P-384/P-521, Ed25519 | + +Excluded: SHA-1, 3DES, RC4, ChaCha20-Poly1305, plain X25519, RSA PKCS #1 v1.5 key transport, TLS 1.0 and TLS 1.1. + +!!! warning "Upgrading from a pre-FIPS release" + + Clients that only offer ChaCha20-Poly1305 or plain X25519 will fail the handshake. + Server certificates with RSA keys under 2048 bits are rejected. + Check your clients and certificates before upgrading. + +The policy filter lives in `crypto/tls`, which sits outside the validated module boundary and tracks the Go toolchain version. +flagd pins its toolchain so the negotiable set stays fixed across releases. + +## Platform support + +Go's FIPS 140-3 mode is unavailable on `wasm`, `windows/386`, `openbsd` and `aix`. +A `windows/386` build compiles but panics at startup, so that binary is no longer released. + +## Cryptography used by flagd + +These are security functions, all serviced by the validated module. + +| Algorithm | Purpose | Location | +| ------------------------------------------ | ----------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------- | +| TLS 1.2/1.3 (AES-GCM, ECDHE, HKDF, HMAC) | Evaluation and sync transport security | `flagd/pkg/service/flag-evaluation/connect_service.go`, `flagd/pkg/service/flag-sync/sync_service.go`, `core/pkg/sync/grpc/credentials/builder.go` | +| ECDSA, RSA-PSS, RSA PKCS #1 v1.5, Ed25519 | TLS certificate and signature verification | `crypto/tls`, `crypto/x509` | +| CTR_DRBG | Random number generation | `crypto/rand` | + +The remaining uses are not security functions, so no approved-algorithm requirement applies to them. + +| Algorithm | Purpose | Location | +| --------------- | --------------------------------------------------- | --------------------------------------------------------------- | +| SHA3-256 | Detecting whether a fetched flag configuration changed | `core/pkg/utils/hash.go` | +| SHA-256 | OFREP SSE `ETag` fingerprint | `flagd/pkg/service/flag-evaluation/ofrep/sse/tracker.go` | +| MurmurHash3-32 | Fractional rollout bucketing | `core/pkg/evaluator/fractional.go` | +| FNV-1a 32 | Poll interval jitter offset | `core/pkg/sync/internal/polling/poller.go` | +| UUIDv4 | Default internal flag set identifier | `core/pkg/store/query.go` | + +SHA3-256 and SHA-256 are approved algorithms and come from the validated module; flagd uses them for change detection and HTTP cache validation. + +MurmurHash3 assigns an evaluation context to a bucket for percentage-based rollouts. +The [fractional operation specification](./specifications/custom-operations/fractional-operation-spec.md) mandates it so that every flagd provider, in every language, assigns the same unit to the same bucket. +Predicting or colliding it reveals only which variant a context receives, which evaluating the flag already tells you. + +FNV-1a spreads polling across the configured interval to avoid a thundering herd. +UUIDv4 is an internal index key that is never exposed externally, and its entropy comes from `crypto/rand`. + +## Non-approved algorithms in the dependency tree + +`core/pkg/sync/blob/blob_sync.go` links the `gocloud.dev` drivers for S3, GCS and Azure Blob so those sync sources work out of the box. +Those SDKs pull non-approved primitives into the link closure: + +- `golang.org/x/crypto/pkcs12` and its RC2 implementation, via `azidentity` +- `golang.org/x/crypto/chacha20poly1305`, via `google/s2a-go` +- `crypto/md5` and `crypto/sha1`, via gocloud's `Content-MD5` handling, the AWS checksum and SSO credential paths, and Azure AD MSAL + +A further set — `crypto/des`, `crypto/rc4`, `crypto/sha1`, `crypto/md5` — is reachable only through `crypto/tls` and `crypto/x509` legacy parsing, and the FIPS policy filter keeps all of it out of negotiation. + +flagd calls none of these for its own security functions. +They run only on cloud provider credential and object integrity paths, where the SDKs need them for protocol compatibility, and the providers offer FIPS-validated and FedRAMP-authorized endpoints. +Data in transit on those paths is protected by TLS from the validated module. + +The full closure is recorded in [`fips-crypto-closure.txt`](https://github.com/open-feature/flagd/blob/main/docs/reference/fips-crypto-closure.txt), which CI regenerates and diffs, so any change to it has to be reviewed. + +## Keys and secrets + +flagd generates, wraps, stores and zeroizes no cryptographic keys. + +TLS private keys are read from operator-supplied PEM paths (`--server-cert-path`, `--server-key-path`) via `tls.LoadX509KeyPair`. +OAuth2 client credentials and static `Authorization` headers for the HTTP sync source are read from configuration or mounted files and held in memory as Go strings, which cannot be zeroized. +Protect them with file permissions, a secret manager and short credential lifetimes. diff --git a/docs/reference/fips-crypto-closure.txt b/docs/reference/fips-crypto-closure.txt new file mode 100644 index 000000000..ddcbd1b42 --- /dev/null +++ b/docs/reference/fips-crypto-closure.txt @@ -0,0 +1,85 @@ +crypto +crypto/aes +crypto/cipher +crypto/des +crypto/dsa +crypto/ecdh +crypto/ecdsa +crypto/ed25519 +crypto/elliptic +crypto/fips140 +crypto/hkdf +crypto/hmac +crypto/hpke +crypto/internal/boring +crypto/internal/boring/bbig +crypto/internal/boring/sig +crypto/internal/constanttime +crypto/internal/entropy +crypto/internal/fips140/v1.0.0-c2097c7c +crypto/internal/fips140/v1.0.0-c2097c7c/aes +crypto/internal/fips140/v1.0.0-c2097c7c/aes/gcm +crypto/internal/fips140/v1.0.0-c2097c7c/alias +crypto/internal/fips140/v1.0.0-c2097c7c/bigmod +crypto/internal/fips140/v1.0.0-c2097c7c/check +crypto/internal/fips140/v1.0.0-c2097c7c/drbg +crypto/internal/fips140/v1.0.0-c2097c7c/ecdh +crypto/internal/fips140/v1.0.0-c2097c7c/ecdsa +crypto/internal/fips140/v1.0.0-c2097c7c/ed25519 +crypto/internal/fips140/v1.0.0-c2097c7c/edwards25519 +crypto/internal/fips140/v1.0.0-c2097c7c/edwards25519/field +crypto/internal/fips140/v1.0.0-c2097c7c/hkdf +crypto/internal/fips140/v1.0.0-c2097c7c/hmac +crypto/internal/fips140/v1.0.0-c2097c7c/mlkem +crypto/internal/fips140/v1.0.0-c2097c7c/nistec +crypto/internal/fips140/v1.0.0-c2097c7c/nistec/fiat +crypto/internal/fips140/v1.0.0-c2097c7c/pbkdf2 +crypto/internal/fips140/v1.0.0-c2097c7c/rsa +crypto/internal/fips140/v1.0.0-c2097c7c/sha256 +crypto/internal/fips140/v1.0.0-c2097c7c/sha3 +crypto/internal/fips140/v1.0.0-c2097c7c/sha512 +crypto/internal/fips140/v1.0.0-c2097c7c/subtle +crypto/internal/fips140/v1.0.0-c2097c7c/tls12 +crypto/internal/fips140/v1.0.0-c2097c7c/tls13 +crypto/internal/fips140cache +crypto/internal/fips140deps/byteorder +crypto/internal/fips140deps/cpu +crypto/internal/fips140deps/godebug +crypto/internal/fips140hash +crypto/internal/fips140only +crypto/internal/impl +crypto/internal/rand +crypto/internal/randutil +crypto/internal/sysrand +crypto/md5 +crypto/mlkem +crypto/pbkdf2 +crypto/rand +crypto/rc4 +crypto/rsa +crypto/sha1 +crypto/sha256 +crypto/sha3 +crypto/sha512 +crypto/subtle +crypto/tls +crypto/tls/internal/fips140tls +crypto/x509 +crypto/x509/internal/macos +crypto/x509/pkix +github.com/aws/aws-sdk-go-v2/internal/v4a/internal/crypto +golang.org/x/crypto/chacha20 +golang.org/x/crypto/chacha20poly1305 +golang.org/x/crypto/cryptobyte +golang.org/x/crypto/cryptobyte/asn1 +golang.org/x/crypto/hkdf +golang.org/x/crypto/internal/alias +golang.org/x/crypto/internal/poly1305 +golang.org/x/crypto/pkcs12 +golang.org/x/crypto/pkcs12/internal/rc2 +vendor/golang.org/x/crypto/chacha20 +vendor/golang.org/x/crypto/chacha20poly1305 +vendor/golang.org/x/crypto/cryptobyte +vendor/golang.org/x/crypto/cryptobyte/asn1 +vendor/golang.org/x/crypto/internal/alias +vendor/golang.org/x/crypto/internal/poly1305 diff --git a/docs/reference/flagd-cli/flagd_start.md b/docs/reference/flagd-cli/flagd_start.md index 4d98e9b4a..cd788e961 100644 --- a/docs/reference/flagd-cli/flagd_start.md +++ b/docs/reference/flagd-cli/flagd_start.md @@ -33,6 +33,7 @@ flagd start [flags] -K, --otel-key-path string tls key path to use with OpenTelemetry collector -I, --otel-reload-interval duration how long between reloading the otel tls certificate from disk (default 1h0m0s) -p, --port int32 Port to listen on (default 8013) + --require-fips Refuse to start if this binary was built for FIPS 140-3 but FIPS mode is disabled at runtime via GODEBUG=fips140=off. Set to false to run a FIPS build with FIPS mode off, for example when TLS is terminated by a proxy in front of flagd. Defaults to true. (default true) -c, --server-cert-path string Server side tls certificate path -k, --server-key-path string Server side tls key path -d, --socket-path string Flagd unix socket path. With grpc the evaluations service will become available on this address. With http(s) the grpc-gateway proxy will use this address internally. diff --git a/flagd-proxy/build.Dockerfile b/flagd-proxy/build.Dockerfile index 33941b2f8..bd8334c2f 100644 --- a/flagd-proxy/build.Dockerfile +++ b/flagd-proxy/build.Dockerfile @@ -1,6 +1,12 @@ # Main Dockerfile for flagd builds # Build the manager binary -FROM --platform=$BUILDPLATFORM golang:1.25-alpine AS builder +FROM --platform=$BUILDPLATFORM golang:1.26-alpine@sha256:28d89ee9cc0ff9fec75c82ca201e6bf7fdf9a679d4b7b24dfa04f2bb766bb468 AS builder +# CMVP-certified Go Cryptographic Module v1.0.0 (certificate #5247). The literal +# version is required; the "certified"/"inprocess" aliases vary by toolchain. +# Also makes the binary default to GODEBUG=fips140=on. +ENV GOFIPS140=v1.0.0 +# The toolchain determines which FIPS snapshots exist, so pin it. +ENV GOTOOLCHAIN=local WORKDIR /src @@ -32,11 +38,16 @@ RUN --mount=type=cache,target=/go/pkg/mod/ \ --mount=type=bind,source=./core,target=./core \ --mount=type=bind,source=./flagd,target=./flagd \ --mount=type=bind,source=./flagd-proxy,target=./flagd-proxy \ - CGO_ENABLED=0 GOOS=${TARGETOS} GOARCH=${TARGETARCH} go build -a -ldflags "-X main.version=${VERSION} -X main.commit=${COMMIT} -X main.date=${DATE}" -o /bin/flagd-proxy flagd-proxy/main.go + CGO_ENABLED=0 GOOS=${TARGETOS} GOARCH=${TARGETARCH} go build -a -trimpath -ldflags "-X main.version=${VERSION} -X main.commit=${COMMIT} -X main.date=${DATE}" -o /bin/flagd-proxy flagd-proxy/main.go + +# Fail closed if the FIPS build settings did not reach the binary. +RUN go version -m /bin/flagd-proxy | grep -q 'GOFIPS140=v1\.0\.0' \ + || (echo "ERROR: /bin/flagd-proxy is not a FIPS 140-3 build" && exit 1) \ + && go version -m /bin/flagd-proxy | grep -E 'GOFIPS140=|-tags=fips140' # # Use distroless as minimal base image to package the manager binary # # Refer to https://github.com/GoogleContainerTools/distroless for more details -FROM gcr.io/distroless/static:nonroot +FROM gcr.io/distroless/static:nonroot@sha256:1c2c046bc09ed40fad370b599a0b1ae7987f55b01e247cf27a7c27cd97e5bbc7 WORKDIR / COPY --from=builder /bin/flagd-proxy . USER 65532:65532 diff --git a/flagd-proxy/cmd/start.go b/flagd-proxy/cmd/start.go index d559b39df..0cc17249c 100644 --- a/flagd-proxy/cmd/start.go +++ b/flagd-proxy/cmd/start.go @@ -11,6 +11,7 @@ import ( "syscall" "time" + "github.com/open-feature/flagd/core/pkg/fips" "github.com/open-feature/flagd/core/pkg/logger" iService "github.com/open-feature/flagd/core/pkg/service" "github.com/open-feature/flagd/flagd-proxy/pkg/service" @@ -28,6 +29,7 @@ const ( portFlagName = "port" keepAliveMinTimeFlagName = "keep-alive-min-time" keepAlivePermitWithoutStreamFlagName = "keep-alive-permit-without-stream" + requireFIPSFlagName = "require-fips" ) func init() { @@ -39,12 +41,14 @@ func init() { flags.StringP(logFormatFlagName, "z", "console", "Set the logging format, e.g. console or json") flags.Duration(keepAliveMinTimeFlagName, 30*time.Second, "Minimum interval the flag sync gRPC server permits between client keepalive pings. Pings arriving more frequently than this are rejected with GOAWAY (ENHANCE_YOUR_CALM). Defaults to 30s.") flags.Bool(keepAlivePermitWithoutStreamFlagName, true, "Permit clients of the flag sync gRPC server to send keepalive pings even when there is no active stream. Defaults to true.") + flags.Bool(requireFIPSFlagName, true, "Refuse to start if this binary was built for FIPS 140-3 but FIPS mode is disabled at runtime via GODEBUG=fips140=off. Set to false to run a FIPS build with FIPS mode off. Defaults to true.") _ = viper.BindPFlag(logFormatFlagName, flags.Lookup(logFormatFlagName)) _ = viper.BindPFlag(managementPortFlagName, flags.Lookup(managementPortFlagName)) _ = viper.BindPFlag(portFlagName, flags.Lookup(portFlagName)) _ = viper.BindPFlag(keepAliveMinTimeFlagName, flags.Lookup(keepAliveMinTimeFlagName)) _ = viper.BindPFlag(keepAlivePermitWithoutStreamFlagName, flags.Lookup(keepAlivePermitWithoutStreamFlagName)) + _ = viper.BindPFlag(requireFIPSFlagName, flags.Lookup(requireFIPSFlagName)) } // startCmd represents the start command @@ -67,6 +71,17 @@ var startCmd = &cobra.Command{ } logger := logger.NewLogger(l, Debug) + fipsStatus := fips.Current() + logger.Info(fmt.Sprintf("FIPS 140-3 mode: %s", fipsStatus)) + if fipsStatus.Degraded() { + if viper.GetBool(requireFIPSFlagName) { + logger.Fatal("refusing to start: this flagd-proxy binary was built for FIPS 140-3 but FIPS " + + "mode is disabled at runtime; remove fips140=off from GODEBUG, or pass " + + "--require-fips=false to run without it") + } + logger.Warn("running with FIPS 140-3 mode disabled because --require-fips=false was set") + } + ctx, _ := signal.NotifyContext(context.Background(), os.Interrupt, syscall.SIGTERM) syncStore := subscriptions.NewManager(ctx, logger) diff --git a/flagd-proxy/go.mod b/flagd-proxy/go.mod index fb9be7e28..3383eefb7 100644 --- a/flagd-proxy/go.mod +++ b/flagd-proxy/go.mod @@ -1,6 +1,8 @@ module github.com/open-feature/flagd/flagd-proxy -go 1.25.5 +go 1.26.0 + +toolchain go1.26.4 require ( buf.build/gen/go/open-feature/flagd/grpc/go v1.6.1-20260217192757-1388a552fc3c.1 diff --git a/flagd-proxy/tests/loadtest/go.mod b/flagd-proxy/tests/loadtest/go.mod index 601675227..5ad8682ed 100644 --- a/flagd-proxy/tests/loadtest/go.mod +++ b/flagd-proxy/tests/loadtest/go.mod @@ -1,6 +1,8 @@ module github.com/open-feature/flagd/flagd-proxy/tests/loadtest -go 1.25.5 +go 1.26.0 + +toolchain go1.26.4 require ( buf.build/gen/go/open-feature/flagd/grpc/go v1.6.1-20260217192757-1388a552fc3c.1 diff --git a/flagd/build.Dockerfile b/flagd/build.Dockerfile index 8a67587dc..906d0f2c9 100644 --- a/flagd/build.Dockerfile +++ b/flagd/build.Dockerfile @@ -1,6 +1,12 @@ # Main Dockerfile for flagd builds # Build the manager binary -FROM --platform=$BUILDPLATFORM golang:1.25-alpine AS builder +FROM --platform=$BUILDPLATFORM golang:1.26-alpine@sha256:28d89ee9cc0ff9fec75c82ca201e6bf7fdf9a679d4b7b24dfa04f2bb766bb468 AS builder +# CMVP-certified Go Cryptographic Module v1.0.0 (certificate #5247). The literal +# version is required; the "certified"/"inprocess" aliases vary by toolchain. +# Also makes the binary default to GODEBUG=fips140=on. +ENV GOFIPS140=v1.0.0 +# The toolchain determines which FIPS snapshots exist, so pin it. +ENV GOTOOLCHAIN=local WORKDIR /src @@ -29,11 +35,16 @@ RUN --mount=type=cache,target=/go/pkg/mod/ \ --mount=type=cache,target=/root/.cache/go-build \ --mount=type=bind,source=./core,target=./core \ --mount=type=bind,source=./flagd,target=./flagd \ - CGO_ENABLED=0 GOOS=${TARGETOS} GOARCH=${TARGETARCH} go build -a -ldflags "-X main.version=${VERSION} -X main.commit=${COMMIT} -X main.date=${DATE}" -o /bin/flagd-build flagd/main.go + CGO_ENABLED=0 GOOS=${TARGETOS} GOARCH=${TARGETARCH} go build -a -trimpath -ldflags "-X main.version=${VERSION} -X main.commit=${COMMIT} -X main.date=${DATE}" -o /bin/flagd-build flagd/main.go + +# Fail closed if the FIPS build settings did not reach the binary. +RUN go version -m /bin/flagd-build | grep -q 'GOFIPS140=v1\.0\.0' \ + || (echo "ERROR: /bin/flagd-build is not a FIPS 140-3 build" && exit 1) \ + && go version -m /bin/flagd-build | grep -E 'GOFIPS140=|-tags=fips140' # # Use distroless as minimal base image to package the manager binary # # Refer to https://github.com/GoogleContainerTools/distroless for more details -FROM gcr.io/distroless/static:nonroot +FROM gcr.io/distroless/static:nonroot@sha256:1c2c046bc09ed40fad370b599a0b1ae7987f55b01e247cf27a7c27cd97e5bbc7 WORKDIR / COPY --from=builder /bin/flagd-build . USER 65532:65532 diff --git a/flagd/cmd/start.go b/flagd/cmd/start.go index d60faa832..9dcd2f3f6 100644 --- a/flagd/cmd/start.go +++ b/flagd/cmd/start.go @@ -6,6 +6,7 @@ import ( "strings" "time" + "github.com/open-feature/flagd/core/pkg/fips" "github.com/open-feature/flagd/core/pkg/logger" "github.com/open-feature/flagd/core/pkg/sync" syncbuilder "github.com/open-feature/flagd/core/pkg/sync/builder" @@ -48,6 +49,8 @@ const ( keepAliveMinTimeFlagName = "keep-alive-min-time" keepAlivePermitWithoutStreamFlagName = "keep-alive-permit-without-stream" + + requireFIPSFlagName = "require-fips" ) func init() { @@ -107,12 +110,14 @@ func init() { flags.Int64P(maxRequestHeaderFlagName, "R", 1_000_000, "Maximum allowed request header size in bytes. Requests exceeding this are rejected with HTTP 431. Set to 0 to use Go's built-in default (1 MiB). WARNING: setting a very large or zero value may allow memory exhaustion from oversized headers.") flags.Duration(keepAliveMinTimeFlagName, 30*time.Second, "Minimum interval the flag sync gRPC server permits between client keepalive pings. Pings arriving more frequently than this are rejected with GOAWAY (ENHANCE_YOUR_CALM). Defaults to 30s.") flags.Bool(keepAlivePermitWithoutStreamFlagName, true, "Permit clients of the flag sync gRPC server to send keepalive pings even when there is no active stream. Defaults to true.") + flags.Bool(requireFIPSFlagName, true, "Refuse to start if this binary was built for FIPS 140-3 but FIPS mode is disabled at runtime via GODEBUG=fips140=off. Set to false to run a FIPS build with FIPS mode off, for example when TLS is terminated by a proxy in front of flagd. Defaults to true.") bindFlags(flags) } func bindFlags(flags *pflag.FlagSet) { _ = viper.BindPFlag(corsFlagName, flags.Lookup(corsFlagName)) + _ = viper.BindPFlag(requireFIPSFlagName, flags.Lookup(requireFIPSFlagName)) _ = viper.BindPFlag(logFormatFlagName, flags.Lookup(logFormatFlagName)) _ = viper.BindPFlag(metricsExporter, flags.Lookup(metricsExporter)) _ = viper.BindPFlag(managementPortFlagName, flags.Lookup(managementPortFlagName)) @@ -165,6 +170,17 @@ var startCmd = &cobra.Command{ rtLogger.Info(fmt.Sprintf("flagd version: %s (%s), built at: %s", Version, Commit, Date)) + fipsStatus := fips.Current() + rtLogger.Info(fmt.Sprintf("FIPS 140-3 mode: %s", fipsStatus)) + if fipsStatus.Degraded() { + if viper.GetBool(requireFIPSFlagName) { + rtLogger.Fatal("refusing to start: this flagd binary was built for FIPS 140-3 but FIPS mode is " + + "disabled at runtime; remove fips140=off from GODEBUG, or pass --require-fips=false to " + + "run without it") + } + rtLogger.Warn("running with FIPS 140-3 mode disabled because --require-fips=false was set") + } + syncProviders, err := syncbuilder.ParseSyncProviderURIs(viper.GetStringSlice(uriFlagName)) if err != nil { log.Fatal(err) diff --git a/flagd/cmd/version.go b/flagd/cmd/version.go index 67abc0ceb..70b2a6db2 100644 --- a/flagd/cmd/version.go +++ b/flagd/cmd/version.go @@ -4,6 +4,7 @@ import ( "fmt" "runtime/debug" + "github.com/open-feature/flagd/core/pkg/fips" "github.com/spf13/cobra" ) @@ -28,5 +29,6 @@ var versionCmd = &cobra.Command{ } } fmt.Printf("flagd: %s (%s), built at: %s\n", Version, Commit, Date) + fmt.Printf("FIPS 140-3 mode: %s\n", fips.Current()) }, } diff --git a/flagd/go.mod b/flagd/go.mod index 6f40cebfd..9531a6542 100644 --- a/flagd/go.mod +++ b/flagd/go.mod @@ -1,6 +1,8 @@ module github.com/open-feature/flagd/flagd -go 1.25.5 +go 1.26.0 + +toolchain go1.26.4 require ( buf.build/gen/go/open-feature/flagd/connectrpc/go v1.19.1-20260217192757-1388a552fc3c.2 diff --git a/flagd/pkg/service/flag-evaluation/connect_service.go b/flagd/pkg/service/flag-evaluation/connect_service.go index d253ddbb6..08d62f170 100644 --- a/flagd/pkg/service/flag-evaluation/connect_service.go +++ b/flagd/pkg/service/flag-evaluation/connect_service.go @@ -3,6 +3,7 @@ package service import ( "context" + "crypto/tls" "errors" "fmt" "net" @@ -191,6 +192,8 @@ func (s *ConnectService) setupServer(svcConf service.Configuration) (net.Listene ReadTimeout: 5 * time.Second, Handler: svcHandler, MaxHeaderBytes: int(svcConf.MaxRequestHeaderBytes), + // Cipher suites and curves are left unset; FIPS mode filters them. + TLSConfig: &tls.Config{MinVersion: tls.VersionTLS12}, } // Add middlewares diff --git a/flagd/profile.Dockerfile b/flagd/profile.Dockerfile index 8c9f97687..ae6c1c141 100644 --- a/flagd/profile.Dockerfile +++ b/flagd/profile.Dockerfile @@ -1,6 +1,12 @@ # Dockerfile with pprof profiler # Build the manager binary -FROM --platform=$BUILDPLATFORM golang:1.25-alpine AS builder +FROM --platform=$BUILDPLATFORM golang:1.26-alpine@sha256:28d89ee9cc0ff9fec75c82ca201e6bf7fdf9a679d4b7b24dfa04f2bb766bb468 AS builder +# CMVP-certified Go Cryptographic Module v1.0.0 (certificate #5247). The literal +# version is required; the "certified"/"inprocess" aliases vary by toolchain. +# Also makes the binary default to GODEBUG=fips140=on. +ENV GOFIPS140=v1.0.0 +# The toolchain determines which FIPS snapshots exist, so pin it. +ENV GOTOOLCHAIN=local WORKDIR /src @@ -29,11 +35,16 @@ RUN --mount=type=cache,target=/go/pkg/mod/ \ --mount=type=cache,target=/root/.cache/go-build \ --mount=type=bind,source=./core,target=./core \ --mount=type=bind,source=./flagd,target=./flagd \ - CGO_ENABLED=0 GOOS=${TARGETOS} GOARCH=${TARGETARCH} go build -a -ldflags "-X main.version=${VERSION} -X main.commit=${COMMIT} -X main.date=${DATE}" -o /bin/flagd-build ./flagd/main.go ./flagd/profiler.go + CGO_ENABLED=0 GOOS=${TARGETOS} GOARCH=${TARGETARCH} go build -a -trimpath -ldflags "-X main.version=${VERSION} -X main.commit=${COMMIT} -X main.date=${DATE}" -o /bin/flagd-build ./flagd/main.go ./flagd/profiler.go + +# Fail closed if the FIPS build settings did not reach the binary. +RUN go version -m /bin/flagd-build | grep -q 'GOFIPS140=v1\.0\.0' \ + || (echo "ERROR: /bin/flagd-build is not a FIPS 140-3 build" && exit 1) \ + && go version -m /bin/flagd-build | grep -E 'GOFIPS140=|-tags=fips140' # Use distroless as minimal base image to package the manager binary # Refer to https://github.com/GoogleContainerTools/distroless for more details -FROM gcr.io/distroless/static:nonroot +FROM gcr.io/distroless/static:nonroot@sha256:1c2c046bc09ed40fad370b599a0b1ae7987f55b01e247cf27a7c27cd97e5bbc7 WORKDIR / COPY --from=builder /bin/flagd-build . USER 65532:65532 diff --git a/mkdocs.yml b/mkdocs.yml index 97707cbab..3db5d3d5f 100644 --- a/mkdocs.yml +++ b/mkdocs.yml @@ -111,6 +111,7 @@ nav: - 'String Comparison': 'reference/custom-operations/string-comparison-operation.md' - 'Schema': 'reference/schema.md' - 'Monitoring': 'reference/monitoring.md' + - 'FIPS 140-3': 'reference/fips-140-3.md' - 'Specifications': - 'Providers': 'reference/specifications/providers.md' - 'Protobuf Schemas': 'reference/specifications/protos.md' diff --git a/renovate.json b/renovate.json index b2a9199a5..941300f2c 100644 --- a/renovate.json +++ b/renovate.json @@ -1,7 +1,7 @@ { "$schema": "https://docs.renovatebot.com/renovate-schema.json", "constraints": { - "go": "1.24" + "go": "1.26" }, "extends": ["github>open-feature/community-tooling"], "includePaths": [ diff --git a/snap/snapcraft.yaml b/snap/snapcraft.yaml index 29fd5bcd1..8b90a0a9d 100644 --- a/snap/snapcraft.yaml +++ b/snap/snapcraft.yaml @@ -22,3 +22,7 @@ parts: plugin: go source-type: git source: https://github.com/open-feature/flagd.git + build-environment: + # Match the release pipeline's certified crypto module. + - GOFIPS140: v1.0.0 + - CGO_ENABLED: "0" diff --git a/test/integration/go.mod b/test/integration/go.mod index a155bd10c..44fffc254 100644 --- a/test/integration/go.mod +++ b/test/integration/go.mod @@ -1,7 +1,9 @@ // this is a intentionally an "orphaned" module so that it effectively does e2e testing independently of the rest of the code module integration_test -go 1.25.8 +go 1.26.0 + +toolchain go1.26.4 require ( github.com/go-git/go-git/v5 v5.19.2 diff --git a/test/loadtest/go.mod b/test/loadtest/go.mod index aa5aa24cb..19819f825 100644 --- a/test/loadtest/go.mod +++ b/test/loadtest/go.mod @@ -1,3 +1,5 @@ module tests.loadtest -go 1.25.5 +go 1.26.0 + +toolchain go1.26.4 diff --git a/test/zero-downtime-flagd-proxy/go.mod b/test/zero-downtime-flagd-proxy/go.mod index a87fcd8ae..d675c7a84 100644 --- a/test/zero-downtime-flagd-proxy/go.mod +++ b/test/zero-downtime-flagd-proxy/go.mod @@ -1,6 +1,8 @@ module zero-downtime-test -go 1.25.5 +go 1.26.0 + +toolchain go1.26.4 require ( buf.build/gen/go/open-feature/flagd/grpc/go v1.6.1-20260217192757-1388a552fc3c.1 From 02add5deb382ca6c31981976d118fbebf3ee4bad Mon Sep 17 00:00:00 2001 From: Jamie Sinn Date: Fri, 28 Aug 2026 12:59:13 -0400 Subject: [PATCH 02/13] fix build - CI was included in FIPS mode by accident. Signed-off-by: Jamie Sinn --- Makefile | 12 +++++++++--- docs/reference/fips-crypto-closure.txt | 1 - 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/Makefile b/Makefile index 65874c81a..8c78a46b3 100644 --- a/Makefile +++ b/Makefile @@ -55,14 +55,20 @@ test-flagd-proxy: # fips140=only makes non-approved algorithms error or panic, so this fails if a # tested path reaches MD5, SHA-1, RC4, 3DES or ChaCha20-Poly1305. Test mode only; # released binaries run with fips140=on. +# +# -exec applies the GODEBUG to the test binaries only. Setting it in the +# environment would also apply it to the go command, whose module fetches over +# TLS negotiate X25519 and fail under fips140=only. .PHONY: test-fips test-fips: - GODEBUG=fips140=only go test -short -count=1 ./core/... ./flagd/... ./flagd-proxy/... + go test -short -count=1 -exec 'env GODEBUG=fips140=only' ./core/... ./flagd/... ./flagd-proxy/... -# Regenerate the crypto dependency closure recorded in the FIPS docs. +# Regenerate the crypto dependency closure recorded in the FIPS docs. Pinned to +# linux/amd64: the closure is platform-dependent, so an unpinned run would +# differ between a developer machine and CI. .PHONY: fips-closure fips-closure: - @go list -deps ./flagd ./flagd-proxy \ + @GOOS=linux GOARCH=amd64 go list -deps ./flagd ./flagd-proxy \ | grep -E '^(crypto|golang\.org/x/crypto)($$|/)|/crypto($$|/)' \ | sort -u > docs/reference/fips-crypto-closure.txt @echo "wrote docs/reference/fips-crypto-closure.txt" diff --git a/docs/reference/fips-crypto-closure.txt b/docs/reference/fips-crypto-closure.txt index ddcbd1b42..444bcc788 100644 --- a/docs/reference/fips-crypto-closure.txt +++ b/docs/reference/fips-crypto-closure.txt @@ -65,7 +65,6 @@ crypto/subtle crypto/tls crypto/tls/internal/fips140tls crypto/x509 -crypto/x509/internal/macos crypto/x509/pkix github.com/aws/aws-sdk-go-v2/internal/v4a/internal/crypto golang.org/x/crypto/chacha20 From 104d2328ca03f6eeba4eca61cf5dbd2ea139b505 Mon Sep 17 00:00:00 2001 From: Jamie Sinn Date: Fri, 28 Aug 2026 13:51:27 -0400 Subject: [PATCH 03/13] enforce fips mode always Signed-off-by: Jamie Sinn --- .github/workflows/build.yaml | 15 ++------------- .github/workflows/release-please.yaml | 22 ++++------------------ core/go.mod | 4 +--- core/pkg/fips/fips.go | 11 ++++++----- core/pkg/fips/fips_test.go | 5 +++++ docs/reference/fips-140-3.md | 25 ++++++++----------------- docs/reference/flagd-cli/flagd_start.md | 1 - flagd-proxy/cmd/start.go | 11 ++--------- flagd-proxy/go.mod | 4 +--- flagd-proxy/tests/loadtest/go.mod | 4 +--- flagd/cmd/start.go | 12 ++---------- flagd/go.mod | 4 +--- snap/snapcraft.yaml | 5 ++++- test/integration/go.mod | 4 ++-- test/loadtest/go.mod | 4 ++-- test/zero-downtime-flagd-proxy/go.mod | 4 +--- 16 files changed, 42 insertions(+), 93 deletions(-) diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index 6f57a2976..5f8b62459 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -96,25 +96,14 @@ jobs: go version -m ./bin/flagd | grep -q 'DefaultGODEBUG=fips140=on' ./bin/flagd version | grep -q 'FIPS 140-3 mode: enabled' - - name: Verify the FIPS opt-out behaves both ways + - name: Verify flagd refuses to run outside FIPS mode run: | set -euo pipefail GODEBUG=fips140=off ./bin/flagd version | grep -q 'FIPS 140-3 mode: disabled' - - # Default: refuse to start once FIPS mode has been turned off. if GODEBUG=fips140=off ./bin/flagd start -f file:./config/samples/example_flags.flagd.json; then - echo "::error::flagd started with FIPS mode disabled and no opt-out"; exit 1 + echo "::error::flagd started with FIPS mode disabled"; exit 1 fi - # --require-fips=false: start anyway, with a warning. - GODEBUG=fips140=off ./bin/flagd start --require-fips=false \ - -f file:./config/samples/example_flags.flagd.json > /tmp/optout.log 2>&1 & - pid=$! - sleep 5 - kill "$pid" || true - grep -q 'running with FIPS 140-3 mode disabled' /tmp/optout.log \ - || { echo "::error::--require-fips=false did not start flagd"; cat /tmp/optout.log; exit 1; } - - name: Check the cryptographic dependency closure has not drifted run: | make fips-closure diff --git a/.github/workflows/release-please.yaml b/.github/workflows/release-please.yaml index bc5edca65..74d2eb757 100644 --- a/.github/workflows/release-please.yaml +++ b/.github/workflows/release-please.yaml @@ -8,7 +8,7 @@ env: PUBLISHABLE_ITEMS: '["flagd","flagd-proxy"]' REGISTRY: ghcr.io REPO_OWNER: ${{ github.repository_owner }} - DEFAULT_GO_VERSION: '~1.26' + DEFAULT_GO_VERSION: '1.26.7' PUBLIC_KEY_FILE: publicKey.pub GOPRIVATE: buf.build/gen/go # CMVP-certified Go Cryptographic Module v1.0.0 (certificate #5247). go build @@ -158,7 +158,7 @@ jobs: VERSION_NO_PREFIX: ${{ needs.release-please.outputs[format('{0}_version', matrix.path)] }} COMMIT: ${{ github.sha }} DATE: ${{ needs.release-please.outputs.date }} - BUILD_ARGS: '-a -trimpath -ldflags "-X main.version=${VERSION} -X main.commit=${COMMIT} -X main.date=${DATE}"' + BUILD_ARGS: '-a -ldflags "-X main.version=${VERSION} -X main.commit=${COMMIT} -X main.date=${DATE}"' steps: - name: Checkout uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4 @@ -194,27 +194,13 @@ jobs: run: | env CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build ${{ env.BUILD_ARGS }} -o ./${{ matrix.path }}_linux_x86_64 ./${{ matrix.path }}/main.go tar -cvzf ${{ matrix.path }}_${{ env.VERSION_NO_PREFIX }}_Linux_x86_64.tar.gz ./${{ matrix.path }}_linux_x86_64 ./LICENSE ./CHANGELOG.md ./README.md ./sbom.xml - - name: build linux i386 - run: | - env CGO_ENABLED=0 GOOS=linux GOARCH=386 go build ${{ env.BUILD_ARGS }} -o ./${{ matrix.path }}_linux_i386 ./${{ matrix.path }}/main.go - tar -cvzf ${{ matrix.path }}_${{ env.VERSION_NO_PREFIX }}_Linux_i386.tar.gz ./${{ matrix.path }}_linux_i386 ./LICENSE ./CHANGELOG.md ./README.md ./sbom.xml # Windows artifacts use .zip archive - name: build windows x86_64 run: | env CGO_ENABLED=0 GOOS=windows GOARCH=amd64 go build ${{ env.BUILD_ARGS }} -o ./${{ matrix.path }}_windows_x86_64 ./${{ matrix.path }}/main.go zip -r ${{ matrix.path }}_${{ env.VERSION_NO_PREFIX }}_Windows_x86_64.zip ./${{ matrix.path }}_windows_x86_64 ./LICENSE ./CHANGELOG.md ./README.md ./sbom.xml - # windows/386 is not built: FIPS mode is unsupported there, so the - # binary panics at startup. - - name: Verify binaries were built against the certified crypto module - run: | - set -euo pipefail - for suffix in darwin_arm64 darwin_x86_64 linux_arm64 linux_x86_64 linux_i386 windows_x86_64; do - bin="./${{ matrix.path }}_${suffix}" - go version -m "$bin" | grep -q 'GOFIPS140=v1\.0\.0' \ - || { echo "::error::$bin is not a FIPS 140-3 build"; exit 1; } - echo "ok: $bin" - done - + # 386 targets are not built: FIPS mode is unsupported on windows/386, and + # linux/386 is not a validated operating environment for the module. # Bundle release artifacts - name: Bundle release assets uses: softprops/action-gh-release@de2c0eb89ae2a093876385947365aca7b0e5f844 # v1 diff --git a/core/go.mod b/core/go.mod index a4ac9a538..7ed63fe7b 100644 --- a/core/go.mod +++ b/core/go.mod @@ -1,8 +1,6 @@ module github.com/open-feature/flagd/core -go 1.26.0 - -toolchain go1.26.4 +go 1.26.7 require ( buf.build/gen/go/open-feature/flagd/grpc/go v1.6.1-20260217192757-1388a552fc3c.1 diff --git a/core/pkg/fips/fips.go b/core/pkg/fips/fips.go index 218513311..269683821 100644 --- a/core/pkg/fips/fips.go +++ b/core/pkg/fips/fips.go @@ -6,14 +6,15 @@ import ( "crypto/fips140" "fmt" "runtime/debug" - "strings" ) -// CertifiedModuleVersion is the module flagd builds against: CMVP certificate -// #5247. GOFIPS140 records a resolved snapshot ("v1.0.0-c2097c7c"), so this is -// matched as a prefix. +// CertifiedModuleVersion is the formal module version reported by +// crypto/fips140.Version for CMVP certificate #5247. const CertifiedModuleVersion = "v1.0.0" +// CertifiedModuleSnapshot is the exact frozen snapshot GOFIPS140 records. +const CertifiedModuleSnapshot = "v1.0.0-c2097c7c" + // Status describes the FIPS 140-3 state of this process. type Status struct { Enabled bool @@ -46,7 +47,7 @@ func Current() Status { // BuiltForFIPS reports whether the certified module was compiled in. Release // artifacts always are; a plain `go build` is not. func (s Status) BuiltForFIPS() bool { - return strings.HasPrefix(s.BuildSetting, CertifiedModuleVersion) + return s.BuildSetting == CertifiedModuleSnapshot } // Certified reports whether the certified module is both compiled in and active. diff --git a/core/pkg/fips/fips_test.go b/core/pkg/fips/fips_test.go index 5c9c37d8d..8db8c3f1e 100644 --- a/core/pkg/fips/fips_test.go +++ b/core/pkg/fips/fips_test.go @@ -29,6 +29,11 @@ func TestStatusClassification(t *testing.T) { degraded: true, wantInString: "GODEBUG=fips140=off at startup", }, + { + name: "a different frozen module snapshot is not the certified one", + status: Status{Enabled: true, ModuleVersion: "v1.0.0", BuildSetting: "v1.0.0-deadbeef"}, + wantInString: "uncertified", + }, { name: "local build, FIPS forced on at runtime only", status: Status{Enabled: true, ModuleVersion: "latest"}, diff --git a/docs/reference/fips-140-3.md b/docs/reference/fips-140-3.md index 34c0f944b..4f323e2f5 100644 --- a/docs/reference/fips-140-3.md +++ b/docs/reference/fips-140-3.md @@ -54,23 +54,12 @@ flagd: v0.16.2 (a1b2c3d), built at: 2026-08-28 FIPS 140-3 mode: enabled (Go Cryptographic Module v1.0.0, GOFIPS140=v1.0.0-c2097c7c) ``` -Binaries built without `GOFIPS140`, such as a local `go build` during development, log that FIPS mode is disabled and start normally. - -## Running without FIPS mode - FIPS mode is fixed at process start and is turned off with `GODEBUG=fips140=off`. -By default flagd refuses to start in that state, so a stray `GODEBUG` cannot quietly drop a deployment out of approved mode. -Pass `--require-fips=false` (or `FLAGD_REQUIRE_FIPS=false`) to allow it: - -```shell -GODEBUG=fips140=off flagd start --require-fips=false --uri file:/etc/flagd/flags.json -``` - -flagd then logs a warning at startup and runs with the standard Go cryptography, lifting the [TLS restrictions](#tls-restrictions) below. +A released binary started that way refuses to run, so a stray `GODEBUG` cannot quietly drop a deployment out of approved mode. +There is no flag to override this. -This is worth considering when flagd terminates no TLS of its own and sits behind a proxy or service mesh that handles it. -In that topology the proxy protects the request path and the FIPS boundary covers only flagd's outbound sync connections and its internal hashing. -If a flag source or the Kubernetes API server in front of flagd negotiates something outside the approved set, the restrictions cost you compatibility without protecting the traffic your clients actually see. +Binaries built without `GOFIPS140`, such as a local `go build` during development, report FIPS mode as disabled and start normally. +That assumes the default `GODEBUG`; such a binary run with `GODEBUG=fips140=on` reports `enabled, uncertified`, because FIPS mode is active against the live `crypto/internal/fips140` tree rather than the frozen certified snapshot. ## TLS restrictions @@ -81,7 +70,7 @@ In FIPS mode `crypto/tls` will not negotiate a protocol version, cipher suite, c | Protocol versions | TLS 1.2, TLS 1.3 | | Key exchange | `X25519MLKEM768`, `SecP256r1MLKEM768`, `SecP384r1MLKEM1024`, P-256, P-384, P-521 | | TLS 1.3 cipher suites | `TLS_AES_128_GCM_SHA256`, `TLS_AES_256_GCM_SHA384` | -| TLS 1.2 cipher suites | `ECDHE_{RSA,ECDSA}_WITH_AES_{128,256}_GCM_SHA{256,384}`, `ECDHE_{RSA,ECDSA}_WITH_AES_128_CBC_SHA256` | +| TLS 1.2 cipher suites | `TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256`, `TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384`, `TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256`, `TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384`, `TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256`, `TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA256` | | Peer certificates | RSA 2048 bits or larger, ECDSA P-256/P-384/P-521, Ed25519 | Excluded: SHA-1, 3DES, RC4, ChaCha20-Poly1305, plain X25519, RSA PKCS #1 v1.5 key transport, TLS 1.0 and TLS 1.1. @@ -99,6 +88,7 @@ flagd pins its toolchain so the negotiable set stays fixed across releases. Go's FIPS 140-3 mode is unavailable on `wasm`, `windows/386`, `openbsd` and `aix`. A `windows/386` build compiles but panics at startup, so that binary is no longer released. +`linux/386` is no longer released either. FIPS mode runs there, but 32-bit x86 Linux is not among the operating environments the module was validated on, so a build for it could not carry the same claim. ## Cryptography used by flagd @@ -138,7 +128,8 @@ Those SDKs pull non-approved primitives into the link closure: - `golang.org/x/crypto/chacha20poly1305`, via `google/s2a-go` - `crypto/md5` and `crypto/sha1`, via gocloud's `Content-MD5` handling, the AWS checksum and SSO credential paths, and Azure AD MSAL -A further set — `crypto/des`, `crypto/rc4`, `crypto/sha1`, `crypto/md5` — is reachable only through `crypto/tls` and `crypto/x509` legacy parsing, and the FIPS policy filter keeps all of it out of negotiation. +The standard library contributes `crypto/des`, `crypto/rc4`, `crypto/sha1` and `crypto/md5` on its own account, through `crypto/tls` and `crypto/x509` legacy parsing. +The FIPS policy filter keeps that set out of negotiation. flagd calls none of these for its own security functions. They run only on cloud provider credential and object integrity paths, where the SDKs need them for protocol compatibility, and the providers offer FIPS-validated and FedRAMP-authorized endpoints. diff --git a/docs/reference/flagd-cli/flagd_start.md b/docs/reference/flagd-cli/flagd_start.md index cd788e961..4d98e9b4a 100644 --- a/docs/reference/flagd-cli/flagd_start.md +++ b/docs/reference/flagd-cli/flagd_start.md @@ -33,7 +33,6 @@ flagd start [flags] -K, --otel-key-path string tls key path to use with OpenTelemetry collector -I, --otel-reload-interval duration how long between reloading the otel tls certificate from disk (default 1h0m0s) -p, --port int32 Port to listen on (default 8013) - --require-fips Refuse to start if this binary was built for FIPS 140-3 but FIPS mode is disabled at runtime via GODEBUG=fips140=off. Set to false to run a FIPS build with FIPS mode off, for example when TLS is terminated by a proxy in front of flagd. Defaults to true. (default true) -c, --server-cert-path string Server side tls certificate path -k, --server-key-path string Server side tls key path -d, --socket-path string Flagd unix socket path. With grpc the evaluations service will become available on this address. With http(s) the grpc-gateway proxy will use this address internally. diff --git a/flagd-proxy/cmd/start.go b/flagd-proxy/cmd/start.go index 0cc17249c..7e70b47ea 100644 --- a/flagd-proxy/cmd/start.go +++ b/flagd-proxy/cmd/start.go @@ -29,7 +29,6 @@ const ( portFlagName = "port" keepAliveMinTimeFlagName = "keep-alive-min-time" keepAlivePermitWithoutStreamFlagName = "keep-alive-permit-without-stream" - requireFIPSFlagName = "require-fips" ) func init() { @@ -41,14 +40,12 @@ func init() { flags.StringP(logFormatFlagName, "z", "console", "Set the logging format, e.g. console or json") flags.Duration(keepAliveMinTimeFlagName, 30*time.Second, "Minimum interval the flag sync gRPC server permits between client keepalive pings. Pings arriving more frequently than this are rejected with GOAWAY (ENHANCE_YOUR_CALM). Defaults to 30s.") flags.Bool(keepAlivePermitWithoutStreamFlagName, true, "Permit clients of the flag sync gRPC server to send keepalive pings even when there is no active stream. Defaults to true.") - flags.Bool(requireFIPSFlagName, true, "Refuse to start if this binary was built for FIPS 140-3 but FIPS mode is disabled at runtime via GODEBUG=fips140=off. Set to false to run a FIPS build with FIPS mode off. Defaults to true.") _ = viper.BindPFlag(logFormatFlagName, flags.Lookup(logFormatFlagName)) _ = viper.BindPFlag(managementPortFlagName, flags.Lookup(managementPortFlagName)) _ = viper.BindPFlag(portFlagName, flags.Lookup(portFlagName)) _ = viper.BindPFlag(keepAliveMinTimeFlagName, flags.Lookup(keepAliveMinTimeFlagName)) _ = viper.BindPFlag(keepAlivePermitWithoutStreamFlagName, flags.Lookup(keepAlivePermitWithoutStreamFlagName)) - _ = viper.BindPFlag(requireFIPSFlagName, flags.Lookup(requireFIPSFlagName)) } // startCmd represents the start command @@ -74,12 +71,8 @@ var startCmd = &cobra.Command{ fipsStatus := fips.Current() logger.Info(fmt.Sprintf("FIPS 140-3 mode: %s", fipsStatus)) if fipsStatus.Degraded() { - if viper.GetBool(requireFIPSFlagName) { - logger.Fatal("refusing to start: this flagd-proxy binary was built for FIPS 140-3 but FIPS " + - "mode is disabled at runtime; remove fips140=off from GODEBUG, or pass " + - "--require-fips=false to run without it") - } - logger.Warn("running with FIPS 140-3 mode disabled because --require-fips=false was set") + logger.Fatal("refusing to start: this flagd-proxy binary was built for FIPS 140-3 but FIPS mode " + + "is disabled at runtime; remove fips140=off from GODEBUG") } ctx, _ := signal.NotifyContext(context.Background(), os.Interrupt, syscall.SIGTERM) diff --git a/flagd-proxy/go.mod b/flagd-proxy/go.mod index 3383eefb7..c440494a0 100644 --- a/flagd-proxy/go.mod +++ b/flagd-proxy/go.mod @@ -1,8 +1,6 @@ module github.com/open-feature/flagd/flagd-proxy -go 1.26.0 - -toolchain go1.26.4 +go 1.26.7 require ( buf.build/gen/go/open-feature/flagd/grpc/go v1.6.1-20260217192757-1388a552fc3c.1 diff --git a/flagd-proxy/tests/loadtest/go.mod b/flagd-proxy/tests/loadtest/go.mod index 5ad8682ed..a4682665e 100644 --- a/flagd-proxy/tests/loadtest/go.mod +++ b/flagd-proxy/tests/loadtest/go.mod @@ -1,8 +1,6 @@ module github.com/open-feature/flagd/flagd-proxy/tests/loadtest -go 1.26.0 - -toolchain go1.26.4 +go 1.26.7 require ( buf.build/gen/go/open-feature/flagd/grpc/go v1.6.1-20260217192757-1388a552fc3c.1 diff --git a/flagd/cmd/start.go b/flagd/cmd/start.go index 9dcd2f3f6..fc5c18605 100644 --- a/flagd/cmd/start.go +++ b/flagd/cmd/start.go @@ -49,8 +49,6 @@ const ( keepAliveMinTimeFlagName = "keep-alive-min-time" keepAlivePermitWithoutStreamFlagName = "keep-alive-permit-without-stream" - - requireFIPSFlagName = "require-fips" ) func init() { @@ -110,14 +108,12 @@ func init() { flags.Int64P(maxRequestHeaderFlagName, "R", 1_000_000, "Maximum allowed request header size in bytes. Requests exceeding this are rejected with HTTP 431. Set to 0 to use Go's built-in default (1 MiB). WARNING: setting a very large or zero value may allow memory exhaustion from oversized headers.") flags.Duration(keepAliveMinTimeFlagName, 30*time.Second, "Minimum interval the flag sync gRPC server permits between client keepalive pings. Pings arriving more frequently than this are rejected with GOAWAY (ENHANCE_YOUR_CALM). Defaults to 30s.") flags.Bool(keepAlivePermitWithoutStreamFlagName, true, "Permit clients of the flag sync gRPC server to send keepalive pings even when there is no active stream. Defaults to true.") - flags.Bool(requireFIPSFlagName, true, "Refuse to start if this binary was built for FIPS 140-3 but FIPS mode is disabled at runtime via GODEBUG=fips140=off. Set to false to run a FIPS build with FIPS mode off, for example when TLS is terminated by a proxy in front of flagd. Defaults to true.") bindFlags(flags) } func bindFlags(flags *pflag.FlagSet) { _ = viper.BindPFlag(corsFlagName, flags.Lookup(corsFlagName)) - _ = viper.BindPFlag(requireFIPSFlagName, flags.Lookup(requireFIPSFlagName)) _ = viper.BindPFlag(logFormatFlagName, flags.Lookup(logFormatFlagName)) _ = viper.BindPFlag(metricsExporter, flags.Lookup(metricsExporter)) _ = viper.BindPFlag(managementPortFlagName, flags.Lookup(managementPortFlagName)) @@ -173,12 +169,8 @@ var startCmd = &cobra.Command{ fipsStatus := fips.Current() rtLogger.Info(fmt.Sprintf("FIPS 140-3 mode: %s", fipsStatus)) if fipsStatus.Degraded() { - if viper.GetBool(requireFIPSFlagName) { - rtLogger.Fatal("refusing to start: this flagd binary was built for FIPS 140-3 but FIPS mode is " + - "disabled at runtime; remove fips140=off from GODEBUG, or pass --require-fips=false to " + - "run without it") - } - rtLogger.Warn("running with FIPS 140-3 mode disabled because --require-fips=false was set") + rtLogger.Fatal("refusing to start: this flagd binary was built for FIPS 140-3 but FIPS mode is " + + "disabled at runtime; remove fips140=off from GODEBUG") } syncProviders, err := syncbuilder.ParseSyncProviderURIs(viper.GetStringSlice(uriFlagName)) diff --git a/flagd/go.mod b/flagd/go.mod index 9531a6542..e062bcc18 100644 --- a/flagd/go.mod +++ b/flagd/go.mod @@ -1,8 +1,6 @@ module github.com/open-feature/flagd/flagd -go 1.26.0 - -toolchain go1.26.4 +go 1.26.7 require ( buf.build/gen/go/open-feature/flagd/connectrpc/go v1.19.1-20260217192757-1388a552fc3c.2 diff --git a/snap/snapcraft.yaml b/snap/snapcraft.yaml index 8b90a0a9d..475722d6e 100644 --- a/snap/snapcraft.yaml +++ b/snap/snapcraft.yaml @@ -23,6 +23,9 @@ parts: source-type: git source: https://github.com/open-feature/flagd.git build-environment: - # Match the release pipeline's certified crypto module. + # Match the release pipeline's certified crypto module. GOTOOLCHAIN is + # pinned because the snapcraft go plugin otherwise picks its own, which + # changes which FIPS snapshots exist. - GOFIPS140: v1.0.0 + - GOTOOLCHAIN: local - CGO_ENABLED: "0" diff --git a/test/integration/go.mod b/test/integration/go.mod index 44fffc254..43c7cc18e 100644 --- a/test/integration/go.mod +++ b/test/integration/go.mod @@ -1,9 +1,9 @@ // this is a intentionally an "orphaned" module so that it effectively does e2e testing independently of the rest of the code module integration_test -go 1.26.0 +go 1.26.7 -toolchain go1.26.4 +toolchain go1.26.7 require ( github.com/go-git/go-git/v5 v5.19.2 diff --git a/test/loadtest/go.mod b/test/loadtest/go.mod index 19819f825..7393fd87b 100644 --- a/test/loadtest/go.mod +++ b/test/loadtest/go.mod @@ -1,5 +1,5 @@ module tests.loadtest -go 1.26.0 +go 1.26.7 -toolchain go1.26.4 +toolchain go1.26.7 diff --git a/test/zero-downtime-flagd-proxy/go.mod b/test/zero-downtime-flagd-proxy/go.mod index d675c7a84..189ea5527 100644 --- a/test/zero-downtime-flagd-proxy/go.mod +++ b/test/zero-downtime-flagd-proxy/go.mod @@ -1,8 +1,6 @@ module zero-downtime-test -go 1.26.0 - -toolchain go1.26.4 +go 1.26.7 require ( buf.build/gen/go/open-feature/flagd/grpc/go v1.6.1-20260217192757-1388a552fc3c.1 From 57941f4867153b5233849d6e2d4fe7da1c5d4a08 Mon Sep 17 00:00:00 2001 From: Jamie Sinn Date: Fri, 28 Aug 2026 14:11:24 -0400 Subject: [PATCH 04/13] build a discrete `-fips` mode instead. Signed-off-by: Jamie Sinn --- .github/workflows/build.yaml | 39 +++++++++++----- .github/workflows/release-please.yaml | 65 ++++++++++++++++++++++++--- Makefile | 21 ++++++--- core/pkg/fips/fips.go | 38 ++++++++++++---- core/pkg/fips/fips_test.go | 41 +++++++++++------ core/pkg/fips/variant_fips.go | 9 ++++ core/pkg/fips/variant_standard.go | 10 +++++ docs/reference/fips-140-3.md | 61 ++++++++++++++++++------- flagd-proxy/build.Dockerfile | 23 ++++++---- flagd-proxy/cmd/start.go | 8 ++-- flagd/build.Dockerfile | 23 ++++++---- flagd/cmd/start.go | 8 ++-- flagd/cmd/version.go | 1 + flagd/profile.Dockerfile | 23 ++++++---- 14 files changed, 270 insertions(+), 100 deletions(-) create mode 100644 core/pkg/fips/variant_fips.go create mode 100644 core/pkg/fips/variant_standard.go diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index 5f8b62459..784e054a8 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -16,8 +16,6 @@ on: - "docs/**" env: - # CMVP-certified Go Cryptographic Module v1.0.0 (certificate #5247). - GOFIPS140: v1.0.0 # The toolchain determines which FIPS snapshots exist, so pin it. GOTOOLCHAIN: local @@ -85,23 +83,42 @@ jobs: - run: make workspace-init # Fails if any tested code path reaches a non-approved algorithm. - - name: Test with strict FIPS enforcement + - name: Test the FIPS variant with strict enforcement run: make test-fips - - name: Build and verify the artifact carries the certified module + - name: Build both variants run: | set -euo pipefail make build-flagd - go version -m ./bin/flagd | grep -q 'GOFIPS140=v1\.0\.0' - go version -m ./bin/flagd | grep -q 'DefaultGODEBUG=fips140=on' - ./bin/flagd version | grep -q 'FIPS 140-3 mode: enabled' + make build-flagd-fips - - name: Verify flagd refuses to run outside FIPS mode + - name: The standard build must not claim FIPS run: | set -euo pipefail - GODEBUG=fips140=off ./bin/flagd version | grep -q 'FIPS 140-3 mode: disabled' - if GODEBUG=fips140=off ./bin/flagd start -f file:./config/samples/example_flags.flagd.json; then - echo "::error::flagd started with FIPS mode disabled"; exit 1 + ./bin/flagd version | grep -q 'build variant: standard' + ./bin/flagd version | grep -q 'FIPS 140-3 mode: disabled' + # The standard build must still run with FIPS mode forced off. + GODEBUG=fips140=off ./bin/flagd version >/dev/null + + - name: The FIPS build must carry and require the certified module + run: | + set -euo pipefail + go version -m ./bin/flagd-fips | grep -q 'GOFIPS140=v1\.0\.0' + go version -m ./bin/flagd-fips | grep -q 'DefaultGODEBUG=fips140=on' + go version -m ./bin/flagd-fips | grep -q -- '-tags=fips140' + ./bin/flagd-fips version | grep -q 'build variant: fips' + ./bin/flagd-fips version | grep -q 'FIPS 140-3 mode: enabled' + # Enforcement is unconditional: no flag can turn it off. + if GODEBUG=fips140=off ./bin/flagd-fips start -f file:./config/samples/example_flags.flagd.json; then + echo "::error::the FIPS build started with FIPS mode disabled"; exit 1 + fi + + - name: A fips140-tagged build without GOFIPS140 must refuse to start + run: | + set -euo pipefail + go build -tags fips140 -o /tmp/flagd-mismatch ./flagd + if /tmp/flagd-mismatch start -f file:./config/samples/example_flags.flagd.json; then + echo "::error::a mislabelled FIPS build started"; exit 1 fi - name: Check the cryptographic dependency closure has not drifted diff --git a/.github/workflows/release-please.yaml b/.github/workflows/release-please.yaml index 74d2eb757..e9fd20cb8 100644 --- a/.github/workflows/release-please.yaml +++ b/.github/workflows/release-please.yaml @@ -11,11 +11,12 @@ env: DEFAULT_GO_VERSION: '1.26.7' PUBLIC_KEY_FILE: publicKey.pub GOPRIVATE: buf.build/gen/go - # CMVP-certified Go Cryptographic Module v1.0.0 (certificate #5247). go build - # reads this from the environment, so it covers every build step below. - GOFIPS140: v1.0.0 # The toolchain determines which FIPS snapshots exist, so pin it. GOTOOLCHAIN: local + # The FIPS variant is built against the CMVP-certified Go Cryptographic Module + # v1.0.0 (certificate #5247). + FIPS_GOFIPS140: v1.0.0 + FIPS_TAGS: fips140 name: Release Please jobs: @@ -125,12 +126,35 @@ jobs: VERSION=${{ env.VERSION }} COMMIT=${{ github.sha }} DATE=${{ needs.release-please.outputs.date }} + - name: Build FIPS variant + id: build-fips + uses: docker/build-push-action@4a13e500e55cf31b7a5d59a38ab2040ab0f42f56 # v5 + with: + builder: ${{ steps.buildx.outputs.name }} + context: . + file: ./${{ matrix.path }}/build.Dockerfile + platforms: linux/amd64,linux/arm64 + provenance: mode=max + sbom: true + push: true + tags: | + ${{ env.REGISTRY }}/${{ env.REPO_OWNER }}/${{ matrix.path }}:latest-fips + ${{ env.REGISTRY }}/${{ env.REPO_OWNER }}/${{ matrix.path }}:${{ env.VERSION }}-fips + labels: ${{ steps.meta.outputs.labels }} + build-args: | + VERSION=${{ env.VERSION }} + COMMIT=${{ github.sha }} + DATE=${{ needs.release-please.outputs.date }} + GOFIPS140=${{ env.FIPS_GOFIPS140 }} + GO_BUILD_TAGS=${{ env.FIPS_TAGS }} + - name: Install Cosign uses: sigstore/cosign-installer@e1523de7571e31dbe865fd2e80c5c7c23ae71eb4 - - name: Sign the image + - name: Sign the images run: | cosign sign --yes --key env://COSIGN_PRIVATE_KEY ${{ env.REGISTRY }}/${{ env.REPO_OWNER }}/${{ matrix.path }}@${{ steps.build.outputs.digest }} + cosign sign --yes --key env://COSIGN_PRIVATE_KEY ${{ env.REGISTRY }}/${{ env.REPO_OWNER }}/${{ matrix.path }}@${{ steps.build-fips.outputs.digest }} cosign public-key --key env://COSIGN_PRIVATE_KEY --outfile ${{ env.PUBLIC_KEY_FILE }} env: COSIGN_PRIVATE_KEY: ${{secrets.COSIGN_PRIVATE_KEY}} @@ -199,8 +223,37 @@ jobs: run: | env CGO_ENABLED=0 GOOS=windows GOARCH=amd64 go build ${{ env.BUILD_ARGS }} -o ./${{ matrix.path }}_windows_x86_64 ./${{ matrix.path }}/main.go zip -r ${{ matrix.path }}_${{ env.VERSION_NO_PREFIX }}_Windows_x86_64.zip ./${{ matrix.path }}_windows_x86_64 ./LICENSE ./CHANGELOG.md ./README.md ./sbom.xml - # 386 targets are not built: FIPS mode is unsupported on windows/386, and - # linux/386 is not a validated operating environment for the module. + - name: build windows i386 + run: | + env CGO_ENABLED=0 GOOS=windows GOARCH=386 go build ${{ env.BUILD_ARGS }} -o ./${{ matrix.path }}_windows_i386 ./${{ matrix.path }}/main.go + zip -r ${{ matrix.path }}_${{ env.VERSION_NO_PREFIX }}_Windows_i386.zip ./${{ matrix.path }}_windows_i386 ./LICENSE ./CHANGELOG.md ./README.md ./sbom.xml + + # FIPS variant. Fewer targets than the standard build: FIPS mode is + # unsupported on windows/386, and linux/386 is not a validated operating + # environment for the module. + - name: build FIPS variant + env: + GOFIPS140: ${{ env.FIPS_GOFIPS140 }} + run: | + set -euo pipefail + build_fips() { + goos="$1"; goarch="$2"; label="$3"; format="$4" + bin="./${{ matrix.path }}-fips_${goos}_${goarch}" + env CGO_ENABLED=0 GOOS="$goos" GOARCH="$goarch" go build ${{ env.BUILD_ARGS }} -tags "${{ env.FIPS_TAGS }}" -o "$bin" ./${{ matrix.path }}/main.go + go version -m "$bin" | grep -q 'GOFIPS140=v1\.0\.0' \ + || { echo "::error::$bin is not a FIPS 140-3 build"; exit 1; } + archive="${{ matrix.path }}-fips_${{ env.VERSION_NO_PREFIX }}_${label}" + if [ "$format" = tar ]; then + tar -cvzf "${archive}.tar.gz" "$bin" ./LICENSE ./CHANGELOG.md ./README.md ./sbom.xml + else + zip -r "${archive}.zip" "$bin" ./LICENSE ./CHANGELOG.md ./README.md ./sbom.xml + fi + } + build_fips darwin arm64 Darwin_arm64 tar + build_fips darwin amd64 Darwin_x86_64 tar + build_fips linux arm64 Linux_arm64 tar + build_fips linux amd64 Linux_x86_64 tar + build_fips windows amd64 Windows_x86_64 zip # Bundle release artifacts - name: Bundle release assets uses: softprops/action-gh-release@de2c0eb89ae2a093876385947365aca7b0e5f844 # v1 diff --git a/Makefile b/Makefile index 8c78a46b3..8aa902dd6 100644 --- a/Makefile +++ b/Makefile @@ -3,9 +3,12 @@ PREFIX=/usr/local PUBLIC_JSON_SCHEMA_DIR=docs/schema/v0/ ALL_GO_MOD_DIRS := $(shell find . -path ./test/integration -prune -o -type f -name 'go.mod' -exec dirname {} \; | sort) -# CMVP-certified Go Cryptographic Module v1.0.0 (certificate #5247). The literal -# version is required; the "certified"/"inprocess" aliases vary by toolchain. -export GOFIPS140 ?= v1.0.0 +# The FIPS variant builds against the CMVP-certified Go Cryptographic Module +# v1.0.0 (certificate #5247). The literal version is required; the +# "certified"/"inprocess" aliases vary by toolchain. The fips140 tag makes the +# binary require that module at startup rather than merely report on it. +FIPS_ENV := GOFIPS140=v1.0.0 CGO_ENABLED=0 +FIPS_TAGS := fips140 FLAGD_DEV_NAMESPACE ?= flagd-dev ZD_TEST_NAMESPACE_FLAGD_PROXY ?= flagd-proxy-zd-test @@ -42,8 +45,12 @@ docker-push-flagd: build: workspace-init # default to flagd make build-flagd build-flagd: - CGO_ENABLED=0 go build -trimpath -ldflags "-X main.version=dev -X main.commit=$$(git rev-parse --short HEAD) -X main.date=$$(date +%FT%TZ)" -o ./bin/flagd ./flagd - go version -m ./bin/flagd | grep -E 'GOFIPS140=|-tags=fips140' + go build -ldflags "-X main.version=dev -X main.commit=$$(git rev-parse --short HEAD) -X main.date=$$(date +%FT%TZ)" -o ./bin/flagd ./flagd + +.PHONY: build-flagd-fips +build-flagd-fips: + $(FIPS_ENV) go build -tags $(FIPS_TAGS) -ldflags "-X main.version=dev -X main.commit=$$(git rev-parse --short HEAD) -X main.date=$$(date +%FT%TZ)" -o ./bin/flagd-fips ./flagd + go version -m ./bin/flagd-fips | grep -E 'GOFIPS140=|-tags=' .PHONY: test test: test-core test-flagd test-flagd-proxy test-core: @@ -61,14 +68,14 @@ test-flagd-proxy: # TLS negotiate X25519 and fail under fips140=only. .PHONY: test-fips test-fips: - go test -short -count=1 -exec 'env GODEBUG=fips140=only' ./core/... ./flagd/... ./flagd-proxy/... + $(FIPS_ENV) go test -tags $(FIPS_TAGS) -short -count=1 -exec 'env GODEBUG=fips140=only' ./core/... ./flagd/... ./flagd-proxy/... # Regenerate the crypto dependency closure recorded in the FIPS docs. Pinned to # linux/amd64: the closure is platform-dependent, so an unpinned run would # differ between a developer machine and CI. .PHONY: fips-closure fips-closure: - @GOOS=linux GOARCH=amd64 go list -deps ./flagd ./flagd-proxy \ + @$(FIPS_ENV) GOOS=linux GOARCH=amd64 go list -tags $(FIPS_TAGS) -deps ./flagd ./flagd-proxy \ | grep -E '^(crypto|golang\.org/x/crypto)($$|/)|/crypto($$|/)' \ | sort -u > docs/reference/fips-crypto-closure.txt @echo "wrote docs/reference/fips-crypto-closure.txt" diff --git a/core/pkg/fips/fips.go b/core/pkg/fips/fips.go index 269683821..73389461f 100644 --- a/core/pkg/fips/fips.go +++ b/core/pkg/fips/fips.go @@ -1,9 +1,15 @@ // Package fips reports whether this binary is running the CMVP-certified Go // Cryptographic Module in FIPS 140-3 approved mode. +// +// flagd is released in two variants. The standard build uses the ordinary Go +// cryptography and only reports its state. The FIPS build, produced with +// GOFIPS140=v1.0.0 and -tags fips140, requires the certified module and refuses +// to run without it; see Check. package fips import ( "crypto/fips140" + "errors" "fmt" "runtime/debug" ) @@ -12,7 +18,9 @@ import ( // crypto/fips140.Version for CMVP certificate #5247. const CertifiedModuleVersion = "v1.0.0" -// CertifiedModuleSnapshot is the exact frozen snapshot GOFIPS140 records. +// CertifiedModuleSnapshot is the exact frozen snapshot GOFIPS140 records for +// that module. Matched in full rather than as a v1.0.0 prefix, so a different +// snapshot cannot be reported as the certified one. const CertifiedModuleSnapshot = "v1.0.0-c2097c7c" // Status describes the FIPS 140-3 state of this process. @@ -44,8 +52,7 @@ func Current() Status { return s } -// BuiltForFIPS reports whether the certified module was compiled in. Release -// artifacts always are; a plain `go build` is not. +// BuiltForFIPS reports whether the certified module was compiled in. func (s Status) BuiltForFIPS() bool { return s.BuildSetting == CertifiedModuleSnapshot } @@ -55,17 +62,32 @@ func (s Status) Certified() bool { return s.Enabled && s.BuiltForFIPS() } -// Degraded reports a binary built for FIPS that is running outside FIPS mode, -// which happens when GODEBUG=fips140=off is set at process start. -func (s Status) Degraded() bool { - return s.BuiltForFIPS() && !s.Enabled +// Check reports whether this build is running the cryptography it claims. +// It always returns nil in the standard build. In the FIPS build it returns an +// error unless the certified module is compiled in and active, so a binary +// carrying the fips140 tag can never serve traffic on unvalidated cryptography. +func Check() error { + if !RequireCertified { + return nil + } + s := Current() + switch { + case s.Certified(): + return nil + case !s.BuiltForFIPS(): + return fmt.Errorf("built with -tags fips140 but not against the certified module "+ + "(GOFIPS140=%q, want %q); rebuild with GOFIPS140=%s", + s.BuildSetting, CertifiedModuleSnapshot, CertifiedModuleVersion) + default: + return errors.New("FIPS 140-3 mode is disabled at runtime; remove fips140=off from GODEBUG") + } } func (s Status) String() string { switch { case s.Certified(): return fmt.Sprintf("enabled (Go Cryptographic Module %s, GOFIPS140=%s)", s.ModuleVersion, s.BuildSetting) - case s.Degraded(): + case s.BuiltForFIPS(): return fmt.Sprintf("disabled (built with GOFIPS140=%s but GODEBUG=fips140=off at startup)", s.BuildSetting) case s.Enabled: return fmt.Sprintf("enabled, uncertified (Go Cryptographic Module %s; binary not built with GOFIPS140)", s.ModuleVersion) diff --git a/core/pkg/fips/fips_test.go b/core/pkg/fips/fips_test.go index 8db8c3f1e..ecfefef62 100644 --- a/core/pkg/fips/fips_test.go +++ b/core/pkg/fips/fips_test.go @@ -12,21 +12,19 @@ func TestStatusClassification(t *testing.T) { status Status builtForFIPS bool certified bool - degraded bool wantInString string }{ { - name: "released artifact in approved mode", - status: Status{Enabled: true, ModuleVersion: "v1.0.0", BuildSetting: "v1.0.0-c2097c7c"}, + name: "released FIPS artifact in approved mode", + status: Status{Enabled: true, ModuleVersion: "v1.0.0", BuildSetting: CertifiedModuleSnapshot}, builtForFIPS: true, certified: true, wantInString: "enabled (Go Cryptographic Module v1.0.0", }, { - name: "released artifact started with GODEBUG=fips140=off", - status: Status{Enabled: false, ModuleVersion: "v1.0.0", BuildSetting: "v1.0.0-c2097c7c"}, + name: "FIPS artifact started with GODEBUG=fips140=off", + status: Status{Enabled: false, ModuleVersion: "v1.0.0", BuildSetting: CertifiedModuleSnapshot}, builtForFIPS: true, - degraded: true, wantInString: "GODEBUG=fips140=off at startup", }, { @@ -35,12 +33,12 @@ func TestStatusClassification(t *testing.T) { wantInString: "uncertified", }, { - name: "local build, FIPS forced on at runtime only", + name: "standard build with FIPS forced on at runtime", status: Status{Enabled: true, ModuleVersion: "latest"}, wantInString: "uncertified", }, { - name: "plain local build", + name: "standard build", status: Status{Enabled: false, ModuleVersion: "latest"}, wantInString: "disabled (binary not built with GOFIPS140)", }, @@ -54,9 +52,6 @@ func TestStatusClassification(t *testing.T) { if got := tt.status.Certified(); got != tt.certified { t.Errorf("Certified() = %v, want %v", got, tt.certified) } - if got := tt.status.Degraded(); got != tt.degraded { - t.Errorf("Degraded() = %v, want %v", got, tt.degraded) - } if got := tt.status.String(); !strings.Contains(got, tt.wantInString) { t.Errorf("String() = %q, want it to contain %q", got, tt.wantInString) } @@ -74,8 +69,26 @@ func TestCurrentMatchesRuntime(t *testing.T) { if got.ModuleVersion != fips140.Version() { t.Errorf("Current().ModuleVersion = %q, want %q", got.ModuleVersion, fips140.Version()) } - // When the test binary itself is built with GOFIPS140, the two must agree. - if got.BuiltForFIPS() && !got.Enabled { - t.Error("built against the certified module but FIPS mode is off; flagd would refuse to start") +} + +// TestCheckMatchesVariant runs under both build variants: the standard build +// must never refuse, and the FIPS build must refuse exactly when the certified +// module is not active. +func TestCheckMatchesVariant(t *testing.T) { + err := Check() + if !RequireCertified { + if Variant != "standard" { + t.Errorf("Variant = %q, want %q", Variant, "standard") + } + if err != nil { + t.Errorf("standard build: Check() = %v, want nil", err) + } + return + } + if Variant != "fips" { + t.Errorf("Variant = %q, want %q", Variant, "fips") + } + if certified := Current().Certified(); certified != (err == nil) { + t.Errorf("Check() = %v but Certified() = %v; they must agree", err, certified) } } diff --git a/core/pkg/fips/variant_fips.go b/core/pkg/fips/variant_fips.go new file mode 100644 index 000000000..ca1579cca --- /dev/null +++ b/core/pkg/fips/variant_fips.go @@ -0,0 +1,9 @@ +//go:build fips140 + +package fips + +// Variant names this build for logs and `flagd version`. +const Variant = "fips" + +// RequireCertified makes Check fail unless the certified module is active. +const RequireCertified = true diff --git a/core/pkg/fips/variant_standard.go b/core/pkg/fips/variant_standard.go new file mode 100644 index 000000000..f09fd7600 --- /dev/null +++ b/core/pkg/fips/variant_standard.go @@ -0,0 +1,10 @@ +//go:build !fips140 + +package fips + +// Variant names this build for logs and `flagd version`. +const Variant = "standard" + +// RequireCertified is false: the standard build reports FIPS state but does not +// require it. +const RequireCertified = false diff --git a/docs/reference/fips-140-3.md b/docs/reference/fips-140-3.md index 4f323e2f5..32025c6a6 100644 --- a/docs/reference/fips-140-3.md +++ b/docs/reference/fips-140-3.md @@ -1,11 +1,14 @@ --- -description: FIPS 140-3 mode in flagd, how to verify it, and what it restricts +description: the flagd FIPS 140-3 build variant, how to verify it, and what it restricts --- # FIPS 140-3 -flagd is built against the Go Cryptographic Module v1.0.0, which holds NIST CMVP validation certificate #5247 and CAVP certificate A6650. -Every released binary and container image, for both flagd and flagd-proxy, runs that module in its FIPS 140-3 approved mode by default. +flagd is released in two variants. + +The **standard** build is the default and uses the ordinary Go cryptography. +The **FIPS** build is compiled against the Go Cryptographic Module v1.0.0, which holds NIST CMVP validation certificate #5247 and CAVP certificate A6650, and runs it in the FIPS 140-3 approved mode. +Both variants are published for flagd and flagd-proxy on every release. The validation covers the Go Cryptographic Module. flagd consumes the module and has not been submitted to CMVP. @@ -15,33 +18,49 @@ The scope is cryptography performed inside the flagd process. It excludes TLS terminated by a proxy or service mesh in front of flagd, the platform and container runtime, and operator-supplied key material. flagd performs no authentication or authorization on any endpoint and expects to run inside a trust boundary. -## Building +## Getting the FIPS build + +Container images carry a `-fips` tag suffix: + +```shell +docker pull ghcr.io/open-feature/flagd:latest-fips +``` + +Release archives carry it in the product position, so globs that match the standard artifacts do not pick up the FIPS ones: -Releases are compiled with `GOFIPS140=v1.0.0`. -This selects the frozen, certified module snapshot and makes the binary default to `GODEBUG=fips140=on`. +```text +flagd_0.16.2_Linux_x86_64.tar.gz # standard +flagd-fips_0.16.2_Linux_x86_64.tar.gz # FIPS +``` + +To build one: ```shell -GOFIPS140=v1.0.0 CGO_ENABLED=0 go build -trimpath -o ./bin/flagd ./flagd +GOFIPS140=v1.0.0 CGO_ENABLED=0 go build -tags fips140 -o ./bin/flagd-fips ./flagd ``` -Use the literal version. -The `certified` and `inprocess` aliases resolve differently per Go toolchain: Go 1.25 ships no `certified.txt`, and on Go 1.26 `inprocess` points at module v1.26.0, which is still pending CMVP review. +`GOFIPS140=v1.0.0` selects the frozen, certified module snapshot and makes the binary default to `GODEBUG=fips140=on`. +Use the literal version: the `certified` and `inprocess` aliases resolve differently per Go toolchain, and on Go 1.26 `inprocess` points at module v1.26.0, which is still pending CMVP review. + +The `fips140` build tag is what makes the binary *require* that module rather than merely report on it. +The two belong together, and a binary built with the tag but without `GOFIPS140` refuses to start rather than presenting itself as a FIPS build. ## Verifying The build settings are recorded in the binary's `runtime/debug.BuildInfo` and survive `-trimpath` and `-ldflags "-s -w"`. ```shell -go version -m ./bin/flagd | grep -E 'GOFIPS140|DefaultGODEBUG|fips140v1.0' +go version -m ./bin/flagd-fips | grep -E 'GOFIPS140|DefaultGODEBUG|tags' ``` ```console -build -tags=fips140v1.0 +build -tags=fips140,fips140v1.0 build DefaultGODEBUG=fips140=on build GOFIPS140=v1.0.0-c2097c7c ``` `v1.0.0-c2097c7c` uniquely identifies the module snapshot. +`fips140` is flagd's own tag; `fips140v1.0` is added by the Go toolchain. The running process reports the same state, both from the `version` command and in its startup log. @@ -51,18 +70,23 @@ flagd version ```console flagd: v0.16.2 (a1b2c3d), built at: 2026-08-28 +build variant: fips FIPS 140-3 mode: enabled (Go Cryptographic Module v1.0.0, GOFIPS140=v1.0.0-c2097c7c) ``` +The standard build reports `build variant: standard` and `FIPS 140-3 mode: disabled`. + +## Enforcement + FIPS mode is fixed at process start and is turned off with `GODEBUG=fips140=off`. -A released binary started that way refuses to run, so a stray `GODEBUG` cannot quietly drop a deployment out of approved mode. -There is no flag to override this. +A FIPS build started that way refuses to run, so a stray `GODEBUG` cannot quietly drop a deployment out of approved mode. +There is no flag to override this: a binary that carries the `fips140` tag either runs the certified module or does not run. -Binaries built without `GOFIPS140`, such as a local `go build` during development, report FIPS mode as disabled and start normally. -That assumes the default `GODEBUG`; such a binary run with `GODEBUG=fips140=on` reports `enabled, uncertified`, because FIPS mode is active against the live `crypto/internal/fips140` tree rather than the frozen certified snapshot. +The standard build performs no such check and is unaffected by `GODEBUG=fips140=off`. ## TLS restrictions +These apply to the FIPS build only. In FIPS mode `crypto/tls` will not negotiate a protocol version, cipher suite, curve or signature algorithm outside the approved set. | Parameter | Permitted | @@ -75,11 +99,14 @@ In FIPS mode `crypto/tls` will not negotiate a protocol version, cipher suite, c Excluded: SHA-1, 3DES, RC4, ChaCha20-Poly1305, plain X25519, RSA PKCS #1 v1.5 key transport, TLS 1.0 and TLS 1.1. -!!! warning "Upgrading from a pre-FIPS release" +!!! warning "Moving from the standard build to the FIPS build" Clients that only offer ChaCha20-Poly1305 or plain X25519 will fail the handshake. Server certificates with RSA keys under 2048 bits are rejected. - Check your clients and certificates before upgrading. + Check your clients and certificates before switching. + + This applies to flagd's outbound sync connections as well as to the TLS it terminates. + A flag source, or a Kubernetes API server, that negotiates outside the approved set will not be reachable from the FIPS build. The policy filter lives in `crypto/tls`, which sits outside the validated module boundary and tracks the Go toolchain version. flagd pins its toolchain so the negotiable set stays fixed across releases. diff --git a/flagd-proxy/build.Dockerfile b/flagd-proxy/build.Dockerfile index bd8334c2f..786fccac7 100644 --- a/flagd-proxy/build.Dockerfile +++ b/flagd-proxy/build.Dockerfile @@ -1,10 +1,6 @@ # Main Dockerfile for flagd builds # Build the manager binary FROM --platform=$BUILDPLATFORM golang:1.26-alpine@sha256:28d89ee9cc0ff9fec75c82ca201e6bf7fdf9a679d4b7b24dfa04f2bb766bb468 AS builder -# CMVP-certified Go Cryptographic Module v1.0.0 (certificate #5247). The literal -# version is required; the "certified"/"inprocess" aliases vary by toolchain. -# Also makes the binary default to GODEBUG=fips140=on. -ENV GOFIPS140=v1.0.0 # The toolchain determines which FIPS snapshots exist, so pin it. ENV GOTOOLCHAIN=local @@ -15,6 +11,13 @@ ARG TARGETARCH ARG VERSION ARG COMMIT ARG DATE +# Build variant. The defaults produce the standard build; the FIPS variant is +# built with GOFIPS140=v1.0.0 and GO_BUILD_TAGS=fips140, which selects the +# CMVP-certified Go Cryptographic Module (certificate #5247) and makes the +# binary require it at startup. Use the literal version, not the +# "certified"/"inprocess" aliases, which vary by toolchain. +ARG GOFIPS140=off +ARG GO_BUILD_TAGS= # Download dependencies as a separate step to take advantage of Docker's caching. # Leverage a cache mount to /go/pkg/mod/ to speed up subsequent builds. @@ -38,12 +41,14 @@ RUN --mount=type=cache,target=/go/pkg/mod/ \ --mount=type=bind,source=./core,target=./core \ --mount=type=bind,source=./flagd,target=./flagd \ --mount=type=bind,source=./flagd-proxy,target=./flagd-proxy \ - CGO_ENABLED=0 GOOS=${TARGETOS} GOARCH=${TARGETARCH} go build -a -trimpath -ldflags "-X main.version=${VERSION} -X main.commit=${COMMIT} -X main.date=${DATE}" -o /bin/flagd-proxy flagd-proxy/main.go + CGO_ENABLED=0 GOFIPS140=${GOFIPS140} GOOS=${TARGETOS} GOARCH=${TARGETARCH} go build -a -tags "${GO_BUILD_TAGS}" -ldflags "-X main.version=${VERSION} -X main.commit=${COMMIT} -X main.date=${DATE}" -o /bin/flagd-proxy flagd-proxy/main.go -# Fail closed if the FIPS build settings did not reach the binary. -RUN go version -m /bin/flagd-proxy | grep -q 'GOFIPS140=v1\.0\.0' \ - || (echo "ERROR: /bin/flagd-proxy is not a FIPS 140-3 build" && exit 1) \ - && go version -m /bin/flagd-proxy | grep -E 'GOFIPS140=|-tags=fips140' +# Fail closed if a FIPS build was requested but the settings did not reach the binary. +RUN if [ "${GOFIPS140}" != "off" ]; then \ + go version -m /bin/flagd-proxy | grep -q 'GOFIPS140=v1\.0\.0' \ + || (echo "ERROR: /bin/flagd-proxy is not a FIPS 140-3 build" && exit 1); \ + go version -m /bin/flagd-proxy | grep -E 'GOFIPS140=|-tags='; \ + fi # # Use distroless as minimal base image to package the manager binary # # Refer to https://github.com/GoogleContainerTools/distroless for more details diff --git a/flagd-proxy/cmd/start.go b/flagd-proxy/cmd/start.go index 7e70b47ea..05bc9e91b 100644 --- a/flagd-proxy/cmd/start.go +++ b/flagd-proxy/cmd/start.go @@ -68,11 +68,9 @@ var startCmd = &cobra.Command{ } logger := logger.NewLogger(l, Debug) - fipsStatus := fips.Current() - logger.Info(fmt.Sprintf("FIPS 140-3 mode: %s", fipsStatus)) - if fipsStatus.Degraded() { - logger.Fatal("refusing to start: this flagd-proxy binary was built for FIPS 140-3 but FIPS mode " + - "is disabled at runtime; remove fips140=off from GODEBUG") + logger.Info(fmt.Sprintf("build variant: %s, FIPS 140-3 mode: %s", fips.Variant, fips.Current())) + if err := fips.Check(); err != nil { + logger.Fatal(fmt.Sprintf("refusing to start: %s", err)) } ctx, _ := signal.NotifyContext(context.Background(), os.Interrupt, syscall.SIGTERM) diff --git a/flagd/build.Dockerfile b/flagd/build.Dockerfile index 906d0f2c9..187d27336 100644 --- a/flagd/build.Dockerfile +++ b/flagd/build.Dockerfile @@ -1,10 +1,6 @@ # Main Dockerfile for flagd builds # Build the manager binary FROM --platform=$BUILDPLATFORM golang:1.26-alpine@sha256:28d89ee9cc0ff9fec75c82ca201e6bf7fdf9a679d4b7b24dfa04f2bb766bb468 AS builder -# CMVP-certified Go Cryptographic Module v1.0.0 (certificate #5247). The literal -# version is required; the "certified"/"inprocess" aliases vary by toolchain. -# Also makes the binary default to GODEBUG=fips140=on. -ENV GOFIPS140=v1.0.0 # The toolchain determines which FIPS snapshots exist, so pin it. ENV GOTOOLCHAIN=local @@ -15,6 +11,13 @@ ARG TARGETARCH ARG VERSION ARG COMMIT ARG DATE +# Build variant. The defaults produce the standard build; the FIPS variant is +# built with GOFIPS140=v1.0.0 and GO_BUILD_TAGS=fips140, which selects the +# CMVP-certified Go Cryptographic Module (certificate #5247) and makes the +# binary require it at startup. Use the literal version, not the +# "certified"/"inprocess" aliases, which vary by toolchain. +ARG GOFIPS140=off +ARG GO_BUILD_TAGS= # Download dependencies as a separate step to take advantage of Docker's caching. # Leverage a cache mount to /go/pkg/mod/ to speed up subsequent builds. @@ -35,12 +38,14 @@ RUN --mount=type=cache,target=/go/pkg/mod/ \ --mount=type=cache,target=/root/.cache/go-build \ --mount=type=bind,source=./core,target=./core \ --mount=type=bind,source=./flagd,target=./flagd \ - CGO_ENABLED=0 GOOS=${TARGETOS} GOARCH=${TARGETARCH} go build -a -trimpath -ldflags "-X main.version=${VERSION} -X main.commit=${COMMIT} -X main.date=${DATE}" -o /bin/flagd-build flagd/main.go + CGO_ENABLED=0 GOFIPS140=${GOFIPS140} GOOS=${TARGETOS} GOARCH=${TARGETARCH} go build -a -tags "${GO_BUILD_TAGS}" -ldflags "-X main.version=${VERSION} -X main.commit=${COMMIT} -X main.date=${DATE}" -o /bin/flagd-build flagd/main.go -# Fail closed if the FIPS build settings did not reach the binary. -RUN go version -m /bin/flagd-build | grep -q 'GOFIPS140=v1\.0\.0' \ - || (echo "ERROR: /bin/flagd-build is not a FIPS 140-3 build" && exit 1) \ - && go version -m /bin/flagd-build | grep -E 'GOFIPS140=|-tags=fips140' +# Fail closed if a FIPS build was requested but the settings did not reach the binary. +RUN if [ "${GOFIPS140}" != "off" ]; then \ + go version -m /bin/flagd-build | grep -q 'GOFIPS140=v1\.0\.0' \ + || (echo "ERROR: /bin/flagd-build is not a FIPS 140-3 build" && exit 1); \ + go version -m /bin/flagd-build | grep -E 'GOFIPS140=|-tags='; \ + fi # # Use distroless as minimal base image to package the manager binary # # Refer to https://github.com/GoogleContainerTools/distroless for more details diff --git a/flagd/cmd/start.go b/flagd/cmd/start.go index fc5c18605..f98bef568 100644 --- a/flagd/cmd/start.go +++ b/flagd/cmd/start.go @@ -166,11 +166,9 @@ var startCmd = &cobra.Command{ rtLogger.Info(fmt.Sprintf("flagd version: %s (%s), built at: %s", Version, Commit, Date)) - fipsStatus := fips.Current() - rtLogger.Info(fmt.Sprintf("FIPS 140-3 mode: %s", fipsStatus)) - if fipsStatus.Degraded() { - rtLogger.Fatal("refusing to start: this flagd binary was built for FIPS 140-3 but FIPS mode is " + - "disabled at runtime; remove fips140=off from GODEBUG") + rtLogger.Info(fmt.Sprintf("build variant: %s, FIPS 140-3 mode: %s", fips.Variant, fips.Current())) + if err := fips.Check(); err != nil { + rtLogger.Fatal(fmt.Sprintf("refusing to start: %s", err)) } syncProviders, err := syncbuilder.ParseSyncProviderURIs(viper.GetStringSlice(uriFlagName)) diff --git a/flagd/cmd/version.go b/flagd/cmd/version.go index 70b2a6db2..71a3e43d0 100644 --- a/flagd/cmd/version.go +++ b/flagd/cmd/version.go @@ -29,6 +29,7 @@ var versionCmd = &cobra.Command{ } } fmt.Printf("flagd: %s (%s), built at: %s\n", Version, Commit, Date) + fmt.Printf("build variant: %s\n", fips.Variant) fmt.Printf("FIPS 140-3 mode: %s\n", fips.Current()) }, } diff --git a/flagd/profile.Dockerfile b/flagd/profile.Dockerfile index ae6c1c141..28597d3a1 100644 --- a/flagd/profile.Dockerfile +++ b/flagd/profile.Dockerfile @@ -1,10 +1,6 @@ # Dockerfile with pprof profiler # Build the manager binary FROM --platform=$BUILDPLATFORM golang:1.26-alpine@sha256:28d89ee9cc0ff9fec75c82ca201e6bf7fdf9a679d4b7b24dfa04f2bb766bb468 AS builder -# CMVP-certified Go Cryptographic Module v1.0.0 (certificate #5247). The literal -# version is required; the "certified"/"inprocess" aliases vary by toolchain. -# Also makes the binary default to GODEBUG=fips140=on. -ENV GOFIPS140=v1.0.0 # The toolchain determines which FIPS snapshots exist, so pin it. ENV GOTOOLCHAIN=local @@ -15,6 +11,13 @@ ARG TARGETARCH ARG VERSION ARG COMMIT ARG DATE +# Build variant. The defaults produce the standard build; the FIPS variant is +# built with GOFIPS140=v1.0.0 and GO_BUILD_TAGS=fips140, which selects the +# CMVP-certified Go Cryptographic Module (certificate #5247) and makes the +# binary require it at startup. Use the literal version, not the +# "certified"/"inprocess" aliases, which vary by toolchain. +ARG GOFIPS140=off +ARG GO_BUILD_TAGS= # Download dependencies as a separate step to take advantage of Docker's caching. # Leverage a cache mount to /go/pkg/mod/ to speed up subsequent builds. @@ -35,12 +38,14 @@ RUN --mount=type=cache,target=/go/pkg/mod/ \ --mount=type=cache,target=/root/.cache/go-build \ --mount=type=bind,source=./core,target=./core \ --mount=type=bind,source=./flagd,target=./flagd \ - CGO_ENABLED=0 GOOS=${TARGETOS} GOARCH=${TARGETARCH} go build -a -trimpath -ldflags "-X main.version=${VERSION} -X main.commit=${COMMIT} -X main.date=${DATE}" -o /bin/flagd-build ./flagd/main.go ./flagd/profiler.go + CGO_ENABLED=0 GOFIPS140=${GOFIPS140} GOOS=${TARGETOS} GOARCH=${TARGETARCH} go build -a -tags "${GO_BUILD_TAGS}" -ldflags "-X main.version=${VERSION} -X main.commit=${COMMIT} -X main.date=${DATE}" -o /bin/flagd-build ./flagd/main.go ./flagd/profiler.go -# Fail closed if the FIPS build settings did not reach the binary. -RUN go version -m /bin/flagd-build | grep -q 'GOFIPS140=v1\.0\.0' \ - || (echo "ERROR: /bin/flagd-build is not a FIPS 140-3 build" && exit 1) \ - && go version -m /bin/flagd-build | grep -E 'GOFIPS140=|-tags=fips140' +# Fail closed if a FIPS build was requested but the settings did not reach the binary. +RUN if [ "${GOFIPS140}" != "off" ]; then \ + go version -m /bin/flagd-build | grep -q 'GOFIPS140=v1\.0\.0' \ + || (echo "ERROR: /bin/flagd-build is not a FIPS 140-3 build" && exit 1); \ + go version -m /bin/flagd-build | grep -E 'GOFIPS140=|-tags='; \ + fi # Use distroless as minimal base image to package the manager binary # Refer to https://github.com/GoogleContainerTools/distroless for more details From ee07c0d1f7685f59a5837d8e7db7424dbc6a50b6 Mon Sep 17 00:00:00 2001 From: Jamie Sinn Date: Fri, 28 Aug 2026 14:45:08 -0400 Subject: [PATCH 05/13] harden build arg checks Signed-off-by: Jamie Sinn --- .github/workflows/release-please.yaml | 16 +++++++--------- flagd-proxy/build.Dockerfile | 22 ++++++++-------------- flagd/build.Dockerfile | 22 ++++++++-------------- flagd/profile.Dockerfile | 22 ++++++++-------------- 4 files changed, 31 insertions(+), 51 deletions(-) diff --git a/.github/workflows/release-please.yaml b/.github/workflows/release-please.yaml index e9fd20cb8..5e0fa3f16 100644 --- a/.github/workflows/release-please.yaml +++ b/.github/workflows/release-please.yaml @@ -13,10 +13,6 @@ env: GOPRIVATE: buf.build/gen/go # The toolchain determines which FIPS snapshots exist, so pin it. GOTOOLCHAIN: local - # The FIPS variant is built against the CMVP-certified Go Cryptographic Module - # v1.0.0 (certificate #5247). - FIPS_GOFIPS140: v1.0.0 - FIPS_TAGS: fips140 name: Release Please jobs: @@ -145,8 +141,7 @@ jobs: VERSION=${{ env.VERSION }} COMMIT=${{ github.sha }} DATE=${{ needs.release-please.outputs.date }} - GOFIPS140=${{ env.FIPS_GOFIPS140 }} - GO_BUILD_TAGS=${{ env.FIPS_TAGS }} + FIPS=on - name: Install Cosign uses: sigstore/cosign-installer@e1523de7571e31dbe865fd2e80c5c7c23ae71eb4 @@ -233,14 +228,17 @@ jobs: # environment for the module. - name: build FIPS variant env: - GOFIPS140: ${{ env.FIPS_GOFIPS140 }} + # The CMVP-certified Go Cryptographic Module v1.0.0 (certificate #5247). + GOFIPS140: v1.0.0 run: | set -euo pipefail build_fips() { goos="$1"; goarch="$2"; label="$3"; format="$4" bin="./${{ matrix.path }}-fips_${goos}_${goarch}" - env CGO_ENABLED=0 GOOS="$goos" GOARCH="$goarch" go build ${{ env.BUILD_ARGS }} -tags "${{ env.FIPS_TAGS }}" -o "$bin" ./${{ matrix.path }}/main.go - go version -m "$bin" | grep -q 'GOFIPS140=v1\.0\.0' \ + env CGO_ENABLED=0 GOOS="$goos" GOARCH="$goarch" go build ${{ env.BUILD_ARGS }} -tags fips140 -o "$bin" ./${{ matrix.path }}/main.go + # The toolchain adds fips140v1.0 only when GOFIPS140 is set, so both + # tags together prove the binary built as the FIPS variant. + go version -m "$bin" | grep -q -- '-tags=fips140,fips140v1.0' \ || { echo "::error::$bin is not a FIPS 140-3 build"; exit 1; } archive="${{ matrix.path }}-fips_${{ env.VERSION_NO_PREFIX }}_${label}" if [ "$format" = tar ]; then diff --git a/flagd-proxy/build.Dockerfile b/flagd-proxy/build.Dockerfile index 786fccac7..e3225afaa 100644 --- a/flagd-proxy/build.Dockerfile +++ b/flagd-proxy/build.Dockerfile @@ -11,13 +11,9 @@ ARG TARGETARCH ARG VERSION ARG COMMIT ARG DATE -# Build variant. The defaults produce the standard build; the FIPS variant is -# built with GOFIPS140=v1.0.0 and GO_BUILD_TAGS=fips140, which selects the -# CMVP-certified Go Cryptographic Module (certificate #5247) and makes the -# binary require it at startup. Use the literal version, not the -# "certified"/"inprocess" aliases, which vary by toolchain. -ARG GOFIPS140=off -ARG GO_BUILD_TAGS= +# Set to "on" for the FIPS variant, built against the CMVP-certified Go +# Cryptographic Module v1.0.0 (certificate #5247). +ARG FIPS=off # Download dependencies as a separate step to take advantage of Docker's caching. # Leverage a cache mount to /go/pkg/mod/ to speed up subsequent builds. @@ -41,14 +37,12 @@ RUN --mount=type=cache,target=/go/pkg/mod/ \ --mount=type=bind,source=./core,target=./core \ --mount=type=bind,source=./flagd,target=./flagd \ --mount=type=bind,source=./flagd-proxy,target=./flagd-proxy \ - CGO_ENABLED=0 GOFIPS140=${GOFIPS140} GOOS=${TARGETOS} GOARCH=${TARGETARCH} go build -a -tags "${GO_BUILD_TAGS}" -ldflags "-X main.version=${VERSION} -X main.commit=${COMMIT} -X main.date=${DATE}" -o /bin/flagd-proxy flagd-proxy/main.go + if [ "${FIPS}" = on ]; then export GOFIPS140=v1.0.0 TAGS=fips140; else TAGS=; fi; \ + CGO_ENABLED=0 GOOS=${TARGETOS} GOARCH=${TARGETARCH} go build -a -tags "${TAGS}" -ldflags "-X main.version=${VERSION} -X main.commit=${COMMIT} -X main.date=${DATE}" -o /bin/flagd-proxy flagd-proxy/main.go -# Fail closed if a FIPS build was requested but the settings did not reach the binary. -RUN if [ "${GOFIPS140}" != "off" ]; then \ - go version -m /bin/flagd-proxy | grep -q 'GOFIPS140=v1\.0\.0' \ - || (echo "ERROR: /bin/flagd-proxy is not a FIPS 140-3 build" && exit 1); \ - go version -m /bin/flagd-proxy | grep -E 'GOFIPS140=|-tags='; \ - fi +# Both tags together prove the variant built as intended: the toolchain adds +# fips140v1.0 only when GOFIPS140 is set, and fips140 is flagd's own. +RUN [ "${FIPS}" != on ] || go version -m /bin/flagd-proxy | grep -q -- '-tags=fips140,fips140v1.0' # # Use distroless as minimal base image to package the manager binary # # Refer to https://github.com/GoogleContainerTools/distroless for more details diff --git a/flagd/build.Dockerfile b/flagd/build.Dockerfile index 187d27336..fdd400389 100644 --- a/flagd/build.Dockerfile +++ b/flagd/build.Dockerfile @@ -11,13 +11,9 @@ ARG TARGETARCH ARG VERSION ARG COMMIT ARG DATE -# Build variant. The defaults produce the standard build; the FIPS variant is -# built with GOFIPS140=v1.0.0 and GO_BUILD_TAGS=fips140, which selects the -# CMVP-certified Go Cryptographic Module (certificate #5247) and makes the -# binary require it at startup. Use the literal version, not the -# "certified"/"inprocess" aliases, which vary by toolchain. -ARG GOFIPS140=off -ARG GO_BUILD_TAGS= +# Set to "on" for the FIPS variant, built against the CMVP-certified Go +# Cryptographic Module v1.0.0 (certificate #5247). +ARG FIPS=off # Download dependencies as a separate step to take advantage of Docker's caching. # Leverage a cache mount to /go/pkg/mod/ to speed up subsequent builds. @@ -38,14 +34,12 @@ RUN --mount=type=cache,target=/go/pkg/mod/ \ --mount=type=cache,target=/root/.cache/go-build \ --mount=type=bind,source=./core,target=./core \ --mount=type=bind,source=./flagd,target=./flagd \ - CGO_ENABLED=0 GOFIPS140=${GOFIPS140} GOOS=${TARGETOS} GOARCH=${TARGETARCH} go build -a -tags "${GO_BUILD_TAGS}" -ldflags "-X main.version=${VERSION} -X main.commit=${COMMIT} -X main.date=${DATE}" -o /bin/flagd-build flagd/main.go + if [ "${FIPS}" = on ]; then export GOFIPS140=v1.0.0 TAGS=fips140; else TAGS=; fi; \ + CGO_ENABLED=0 GOOS=${TARGETOS} GOARCH=${TARGETARCH} go build -a -tags "${TAGS}" -ldflags "-X main.version=${VERSION} -X main.commit=${COMMIT} -X main.date=${DATE}" -o /bin/flagd-build flagd/main.go -# Fail closed if a FIPS build was requested but the settings did not reach the binary. -RUN if [ "${GOFIPS140}" != "off" ]; then \ - go version -m /bin/flagd-build | grep -q 'GOFIPS140=v1\.0\.0' \ - || (echo "ERROR: /bin/flagd-build is not a FIPS 140-3 build" && exit 1); \ - go version -m /bin/flagd-build | grep -E 'GOFIPS140=|-tags='; \ - fi +# Both tags together prove the variant built as intended: the toolchain adds +# fips140v1.0 only when GOFIPS140 is set, and fips140 is flagd's own. +RUN [ "${FIPS}" != on ] || go version -m /bin/flagd-build | grep -q -- '-tags=fips140,fips140v1.0' # # Use distroless as minimal base image to package the manager binary # # Refer to https://github.com/GoogleContainerTools/distroless for more details diff --git a/flagd/profile.Dockerfile b/flagd/profile.Dockerfile index 28597d3a1..3c947680f 100644 --- a/flagd/profile.Dockerfile +++ b/flagd/profile.Dockerfile @@ -11,13 +11,9 @@ ARG TARGETARCH ARG VERSION ARG COMMIT ARG DATE -# Build variant. The defaults produce the standard build; the FIPS variant is -# built with GOFIPS140=v1.0.0 and GO_BUILD_TAGS=fips140, which selects the -# CMVP-certified Go Cryptographic Module (certificate #5247) and makes the -# binary require it at startup. Use the literal version, not the -# "certified"/"inprocess" aliases, which vary by toolchain. -ARG GOFIPS140=off -ARG GO_BUILD_TAGS= +# Set to "on" for the FIPS variant, built against the CMVP-certified Go +# Cryptographic Module v1.0.0 (certificate #5247). +ARG FIPS=off # Download dependencies as a separate step to take advantage of Docker's caching. # Leverage a cache mount to /go/pkg/mod/ to speed up subsequent builds. @@ -38,14 +34,12 @@ RUN --mount=type=cache,target=/go/pkg/mod/ \ --mount=type=cache,target=/root/.cache/go-build \ --mount=type=bind,source=./core,target=./core \ --mount=type=bind,source=./flagd,target=./flagd \ - CGO_ENABLED=0 GOFIPS140=${GOFIPS140} GOOS=${TARGETOS} GOARCH=${TARGETARCH} go build -a -tags "${GO_BUILD_TAGS}" -ldflags "-X main.version=${VERSION} -X main.commit=${COMMIT} -X main.date=${DATE}" -o /bin/flagd-build ./flagd/main.go ./flagd/profiler.go + if [ "${FIPS}" = on ]; then export GOFIPS140=v1.0.0 TAGS=fips140; else TAGS=; fi; \ + CGO_ENABLED=0 GOOS=${TARGETOS} GOARCH=${TARGETARCH} go build -a -tags "${TAGS}" -ldflags "-X main.version=${VERSION} -X main.commit=${COMMIT} -X main.date=${DATE}" -o /bin/flagd-build ./flagd/main.go ./flagd/profiler.go -# Fail closed if a FIPS build was requested but the settings did not reach the binary. -RUN if [ "${GOFIPS140}" != "off" ]; then \ - go version -m /bin/flagd-build | grep -q 'GOFIPS140=v1\.0\.0' \ - || (echo "ERROR: /bin/flagd-build is not a FIPS 140-3 build" && exit 1); \ - go version -m /bin/flagd-build | grep -E 'GOFIPS140=|-tags='; \ - fi +# Both tags together prove the variant built as intended: the toolchain adds +# fips140v1.0 only when GOFIPS140 is set, and fips140 is flagd's own. +RUN [ "${FIPS}" != on ] || go version -m /bin/flagd-build | grep -q -- '-tags=fips140,fips140v1.0' # Use distroless as minimal base image to package the manager binary # Refer to https://github.com/GoogleContainerTools/distroless for more details From 22f626f0f5b402d765410474d734dd5e86a8e978 Mon Sep 17 00:00:00 2001 From: Jamie Sinn Date: Fri, 28 Aug 2026 14:53:15 -0400 Subject: [PATCH 06/13] integration test mod file updates Signed-off-by: Jamie Sinn --- test/integration/go.mod | 2 -- 1 file changed, 2 deletions(-) diff --git a/test/integration/go.mod b/test/integration/go.mod index 43c7cc18e..a9d084db6 100644 --- a/test/integration/go.mod +++ b/test/integration/go.mod @@ -3,8 +3,6 @@ module integration_test go 1.26.7 -toolchain go1.26.7 - require ( github.com/go-git/go-git/v5 v5.19.2 github.com/open-feature/go-sdk-contrib/providers/flagd v0.6.0 From ce80d7956c8a719d436bdc0e709a728260625299 Mon Sep 17 00:00:00 2001 From: Jamie Sinn Date: Sat, 29 Aug 2026 21:27:35 -0400 Subject: [PATCH 07/13] Update .github/workflows/release-please.yaml Co-authored-by: Roman Dmytrenko Signed-off-by: Jamie Sinn --- .github/workflows/release-please.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/release-please.yaml b/.github/workflows/release-please.yaml index 5e0fa3f16..45c7fc9cb 100644 --- a/.github/workflows/release-please.yaml +++ b/.github/workflows/release-please.yaml @@ -8,7 +8,7 @@ env: PUBLISHABLE_ITEMS: '["flagd","flagd-proxy"]' REGISTRY: ghcr.io REPO_OWNER: ${{ github.repository_owner }} - DEFAULT_GO_VERSION: '1.26.7' + DEFAULT_GO_VERSION: '~1.27' PUBLIC_KEY_FILE: publicKey.pub GOPRIVATE: buf.build/gen/go # The toolchain determines which FIPS snapshots exist, so pin it. From 10fc77a38ccd930300b3ffe2038e748cb2db805f Mon Sep 17 00:00:00 2001 From: Jamie Sinn Date: Sat, 29 Aug 2026 21:52:24 -0400 Subject: [PATCH 08/13] Set base compat for core to 1.26 and all others to 1.27 Signed-off-by: Jamie Sinn --- core/go.mod | 2 +- flagd-proxy/go.mod | 2 +- flagd-proxy/tests/loadtest/go.mod | 2 +- flagd/go.mod | 2 +- test/integration/go.mod | 2 +- test/loadtest/go.mod | 4 ++-- test/zero-downtime-flagd-proxy/go.mod | 2 +- 7 files changed, 8 insertions(+), 8 deletions(-) diff --git a/core/go.mod b/core/go.mod index 7ed63fe7b..d5035b77e 100644 --- a/core/go.mod +++ b/core/go.mod @@ -1,6 +1,6 @@ module github.com/open-feature/flagd/core -go 1.26.7 +go 1.26.0 require ( buf.build/gen/go/open-feature/flagd/grpc/go v1.6.1-20260217192757-1388a552fc3c.1 diff --git a/flagd-proxy/go.mod b/flagd-proxy/go.mod index c440494a0..3c6456306 100644 --- a/flagd-proxy/go.mod +++ b/flagd-proxy/go.mod @@ -1,6 +1,6 @@ module github.com/open-feature/flagd/flagd-proxy -go 1.26.7 +go 1.27 require ( buf.build/gen/go/open-feature/flagd/grpc/go v1.6.1-20260217192757-1388a552fc3c.1 diff --git a/flagd-proxy/tests/loadtest/go.mod b/flagd-proxy/tests/loadtest/go.mod index a4682665e..d061fecbe 100644 --- a/flagd-proxy/tests/loadtest/go.mod +++ b/flagd-proxy/tests/loadtest/go.mod @@ -1,6 +1,6 @@ module github.com/open-feature/flagd/flagd-proxy/tests/loadtest -go 1.26.7 +go 1.27 require ( buf.build/gen/go/open-feature/flagd/grpc/go v1.6.1-20260217192757-1388a552fc3c.1 diff --git a/flagd/go.mod b/flagd/go.mod index e062bcc18..8cce7e9c1 100644 --- a/flagd/go.mod +++ b/flagd/go.mod @@ -1,6 +1,6 @@ module github.com/open-feature/flagd/flagd -go 1.26.7 +go 1.27 require ( buf.build/gen/go/open-feature/flagd/connectrpc/go v1.19.1-20260217192757-1388a552fc3c.2 diff --git a/test/integration/go.mod b/test/integration/go.mod index a9d084db6..49b5d9808 100644 --- a/test/integration/go.mod +++ b/test/integration/go.mod @@ -1,7 +1,7 @@ // this is a intentionally an "orphaned" module so that it effectively does e2e testing independently of the rest of the code module integration_test -go 1.26.7 +go 1.27 require ( github.com/go-git/go-git/v5 v5.19.2 diff --git a/test/loadtest/go.mod b/test/loadtest/go.mod index 7393fd87b..72d252550 100644 --- a/test/loadtest/go.mod +++ b/test/loadtest/go.mod @@ -1,5 +1,5 @@ module tests.loadtest -go 1.26.7 +go 1.27 -toolchain go1.26.7 +toolchain go1.27 diff --git a/test/zero-downtime-flagd-proxy/go.mod b/test/zero-downtime-flagd-proxy/go.mod index 189ea5527..15c7d5e52 100644 --- a/test/zero-downtime-flagd-proxy/go.mod +++ b/test/zero-downtime-flagd-proxy/go.mod @@ -1,6 +1,6 @@ module zero-downtime-test -go 1.26.7 +go 1.27 require ( buf.build/gen/go/open-feature/flagd/grpc/go v1.6.1-20260217192757-1388a552fc3c.1 From eaa52eb63a5a64a0ec8d0245db926b8e09e64c3b Mon Sep 17 00:00:00 2001 From: Jamie Sinn Date: Sat, 29 Aug 2026 22:16:18 -0400 Subject: [PATCH 09/13] bump go lint and add post quantum algos Signed-off-by: Jamie Sinn --- Makefile | 4 ++-- docs/reference/fips-140-3.md | 2 +- docs/reference/fips-crypto-closure.txt | 1 + 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/Makefile b/Makefile index 8aa902dd6..e9d1d6f53 100644 --- a/Makefile +++ b/Makefile @@ -107,10 +107,10 @@ uninstall: rm /etc/systemd/system/flagd.service rm -f $(DESTDIR)$(PREFIX)/bin/flagd lint: - go install -v github.com/golangci/golangci-lint/v2/cmd/golangci-lint@v2.7.2 + go install -v github.com/golangci/golangci-lint/v2/cmd/golangci-lint@v2.13.2 $(foreach module, $(ALL_GO_MOD_DIRS), ${GOPATH}/bin/golangci-lint run $(module)/...;) lint-fix: - go install -v github.com/golangci/golangci-lint/v2/cmd/golangci-lint@v2.7.2 + go install -v github.com/golangci/golangci-lint/v2/cmd/golangci-lint@v2.13.2 $(foreach module, $(ALL_GO_MOD_DIRS), ${GOPATH}/bin/golangci-lint run --fix $(module)/...;) install-mockgen: go install go.uber.org/mock/mockgen@v0.4.0 diff --git a/docs/reference/fips-140-3.md b/docs/reference/fips-140-3.md index 32025c6a6..5774bb0b8 100644 --- a/docs/reference/fips-140-3.md +++ b/docs/reference/fips-140-3.md @@ -155,7 +155,7 @@ Those SDKs pull non-approved primitives into the link closure: - `golang.org/x/crypto/chacha20poly1305`, via `google/s2a-go` - `crypto/md5` and `crypto/sha1`, via gocloud's `Content-MD5` handling, the AWS checksum and SSO credential paths, and Azure AD MSAL -The standard library contributes `crypto/des`, `crypto/rc4`, `crypto/sha1` and `crypto/md5` on its own account, through `crypto/tls` and `crypto/x509` legacy parsing. +The standard library contributes `crypto/des`, `crypto/rc4`, `crypto/sha1` and `crypto/md5` on its own account, through `crypto/tls` and `crypto/x509` legacy parsing, plus `crypto/mldsa` for post-quantum certificate signatures. The FIPS policy filter keeps that set out of negotiation. flagd calls none of these for its own security functions. diff --git a/docs/reference/fips-crypto-closure.txt b/docs/reference/fips-crypto-closure.txt index 444bcc788..6c2acd33e 100644 --- a/docs/reference/fips-crypto-closure.txt +++ b/docs/reference/fips-crypto-closure.txt @@ -52,6 +52,7 @@ crypto/internal/rand crypto/internal/randutil crypto/internal/sysrand crypto/md5 +crypto/mldsa crypto/mlkem crypto/pbkdf2 crypto/rand From 4e0acf514cbcf8bf7446a7057ae00cd6f948537d Mon Sep 17 00:00:00 2001 From: Jamie Sinn Date: Sat, 29 Aug 2026 22:32:46 -0400 Subject: [PATCH 10/13] update go version in docker Signed-off-by: Jamie Sinn --- flagd-proxy/build.Dockerfile | 2 +- flagd/build.Dockerfile | 2 +- flagd/profile.Dockerfile | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/flagd-proxy/build.Dockerfile b/flagd-proxy/build.Dockerfile index e3225afaa..bd32d8ea3 100644 --- a/flagd-proxy/build.Dockerfile +++ b/flagd-proxy/build.Dockerfile @@ -1,6 +1,6 @@ # Main Dockerfile for flagd builds # Build the manager binary -FROM --platform=$BUILDPLATFORM golang:1.26-alpine@sha256:28d89ee9cc0ff9fec75c82ca201e6bf7fdf9a679d4b7b24dfa04f2bb766bb468 AS builder +FROM --platform=$BUILDPLATFORM golang:1.27-alpine@sha256:4c9fe60190a2a3350ddc51de80d0224b8a6698d12bdfc999fee45ea9d6c46dbc AS builder # The toolchain determines which FIPS snapshots exist, so pin it. ENV GOTOOLCHAIN=local diff --git a/flagd/build.Dockerfile b/flagd/build.Dockerfile index fdd400389..f65832991 100644 --- a/flagd/build.Dockerfile +++ b/flagd/build.Dockerfile @@ -1,6 +1,6 @@ # Main Dockerfile for flagd builds # Build the manager binary -FROM --platform=$BUILDPLATFORM golang:1.26-alpine@sha256:28d89ee9cc0ff9fec75c82ca201e6bf7fdf9a679d4b7b24dfa04f2bb766bb468 AS builder +FROM --platform=$BUILDPLATFORM golang:1.27-alpine@sha256:4c9fe60190a2a3350ddc51de80d0224b8a6698d12bdfc999fee45ea9d6c46dbc AS builder # The toolchain determines which FIPS snapshots exist, so pin it. ENV GOTOOLCHAIN=local diff --git a/flagd/profile.Dockerfile b/flagd/profile.Dockerfile index 3c947680f..b4f934cc5 100644 --- a/flagd/profile.Dockerfile +++ b/flagd/profile.Dockerfile @@ -1,6 +1,6 @@ # Dockerfile with pprof profiler # Build the manager binary -FROM --platform=$BUILDPLATFORM golang:1.26-alpine@sha256:28d89ee9cc0ff9fec75c82ca201e6bf7fdf9a679d4b7b24dfa04f2bb766bb468 AS builder +FROM --platform=$BUILDPLATFORM golang:1.27-alpine@sha256:4c9fe60190a2a3350ddc51de80d0224b8a6698d12bdfc999fee45ea9d6c46dbc AS builder # The toolchain determines which FIPS snapshots exist, so pin it. ENV GOTOOLCHAIN=local From 2453f91ab73c813e9942b1f718ccd620446e60a9 Mon Sep 17 00:00:00 2001 From: Jamie Sinn Date: Sat, 29 Aug 2026 22:46:47 -0400 Subject: [PATCH 11/13] fix race condition on shutting down the sync tests Signed-off-by: Jamie Sinn --- flagd/pkg/service/flag-sync/sync_service_test.go | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/flagd/pkg/service/flag-sync/sync_service_test.go b/flagd/pkg/service/flag-sync/sync_service_test.go index 694fe9fd1..6cf508517 100644 --- a/flagd/pkg/service/flag-sync/sync_service_test.go +++ b/flagd/pkg/service/flag-sync/sync_service_test.go @@ -187,12 +187,21 @@ func TestSyncServiceDeadlineEndToEnd(t *testing.T) { socketPath := "" ctx, cancelFunc := context.WithCancel(context.Background()) - defer cancelFunc() - _, _, err := createAndStartSyncService(port, sources, flagStore, certPath, keyPath, socketPath, ctx, tc.deadline, false) + _, doneChan, err := createAndStartSyncService(port, sources, flagStore, certPath, keyPath, socketPath, ctx, tc.deadline, false) if err != nil { t.Fatal("error creating sync service") } + // wait for the listener to actually close before returning, so the + // next subtest's bind to the same port doesn't race this shutdown. + defer func() { + cancelFunc() + select { + case <-doneChan: + case <-time.After(2 * time.Second): + t.Fatal("service did not exit within sufficient timeframe") + } + }() // when - derive a client for sync service serviceClient := getSyncClient(t, "./test-cert/ca-cert.pem", "", true, port, nil) From 82b68ad889bc99400c0e712bfe59a2dba40b15ac Mon Sep 17 00:00:00 2001 From: Jamie Sinn Date: Sun, 30 Aug 2026 20:24:16 -0400 Subject: [PATCH 12/13] address pr nits Signed-off-by: Jamie Sinn --- .devcontainer/devcontainer.json | 2 +- flagd-proxy/cmd/start.go | 5 +++-- flagd/cmd/start.go | 12 ++++++++---- flagd/pkg/service/flag-sync/sync_service_test.go | 1 + 4 files changed, 13 insertions(+), 7 deletions(-) diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index b0156b3bd..b9b06b736 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -1,7 +1,7 @@ { "name": "flagd dev container", // Image details: https://github.com/devcontainers/images/tree/main/src/go - "image": "mcr.microsoft.com/devcontainers/go:1.26", + "image": "mcr.microsoft.com/devcontainers/go:1.27", // Features to add to the dev container. More info: https://containers.dev/features. "features": { "ghcr.io/devcontainers/features/github-cli:1": {}, diff --git a/flagd-proxy/cmd/start.go b/flagd-proxy/cmd/start.go index 05bc9e91b..fc6e14dc4 100644 --- a/flagd-proxy/cmd/start.go +++ b/flagd-proxy/cmd/start.go @@ -18,6 +18,7 @@ import ( "github.com/open-feature/flagd/flagd-proxy/pkg/service/subscriptions" "github.com/spf13/cobra" "github.com/spf13/viper" + "go.uber.org/zap" "go.uber.org/zap/zapcore" ) @@ -68,9 +69,9 @@ var startCmd = &cobra.Command{ } logger := logger.NewLogger(l, Debug) - logger.Info(fmt.Sprintf("build variant: %s, FIPS 140-3 mode: %s", fips.Variant, fips.Current())) + logger.Info("build info", zap.String("variant", fips.Variant), zap.Stringer("FIPS 140-3 mode", fips.Current())) if err := fips.Check(); err != nil { - logger.Fatal(fmt.Sprintf("refusing to start: %s", err)) + logger.Fatal("refusing to start", zap.Error(err)) } ctx, _ := signal.NotifyContext(context.Background(), os.Interrupt, syscall.SIGTERM) diff --git a/flagd/cmd/start.go b/flagd/cmd/start.go index f98bef568..beea4f87d 100644 --- a/flagd/cmd/start.go +++ b/flagd/cmd/start.go @@ -164,11 +164,15 @@ var startCmd = &cobra.Command{ logger := logger.NewLogger(l, Debug) rtLogger := logger.WithFields(zap.String("component", "start")) - rtLogger.Info(fmt.Sprintf("flagd version: %s (%s), built at: %s", Version, Commit, Date)) - - rtLogger.Info(fmt.Sprintf("build variant: %s, FIPS 140-3 mode: %s", fips.Variant, fips.Current())) + rtLogger.Info("flagd version", + zap.String("version", Version), + zap.String("commit", Commit), + zap.String("date", Date), + zap.String("variant", fips.Variant), + zap.Stringer("FIPS 140-3 mode", fips.Current()), + ) if err := fips.Check(); err != nil { - rtLogger.Fatal(fmt.Sprintf("refusing to start: %s", err)) + rtLogger.Fatal("refusing to start", zap.Error(err)) } syncProviders, err := syncbuilder.ParseSyncProviderURIs(viper.GetStringSlice(uriFlagName)) diff --git a/flagd/pkg/service/flag-sync/sync_service_test.go b/flagd/pkg/service/flag-sync/sync_service_test.go index 6cf508517..09c95d5cb 100644 --- a/flagd/pkg/service/flag-sync/sync_service_test.go +++ b/flagd/pkg/service/flag-sync/sync_service_test.go @@ -187,6 +187,7 @@ func TestSyncServiceDeadlineEndToEnd(t *testing.T) { socketPath := "" ctx, cancelFunc := context.WithCancel(context.Background()) + defer cancelFunc() _, doneChan, err := createAndStartSyncService(port, sources, flagStore, certPath, keyPath, socketPath, ctx, tc.deadline, false) if err != nil { From e978a1f0580476cf1470483a6c206987430c4181 Mon Sep 17 00:00:00 2001 From: Jamie Sinn Date: Mon, 31 Aug 2026 14:46:58 -0400 Subject: [PATCH 13/13] revert snap changes Signed-off-by: Jamie Sinn --- snap/snapcraft.yaml | 7 ------- 1 file changed, 7 deletions(-) diff --git a/snap/snapcraft.yaml b/snap/snapcraft.yaml index 475722d6e..29fd5bcd1 100644 --- a/snap/snapcraft.yaml +++ b/snap/snapcraft.yaml @@ -22,10 +22,3 @@ parts: plugin: go source-type: git source: https://github.com/open-feature/flagd.git - build-environment: - # Match the release pipeline's certified crypto module. GOTOOLCHAIN is - # pinned because the snapcraft go plugin otherwise picks its own, which - # changes which FIPS snapshots exist. - - GOFIPS140: v1.0.0 - - GOTOOLCHAIN: local - - CGO_ENABLED: "0"