Skip to content

Allow non-approved MD5 use under GODEBUG=fips140=only - #1133

Open
sameerforge wants to merge 1 commit into
carvel-dev:v0.65.xfrom
sameerforge:topic/sameerkh/fips140-md5-without-enforcement
Open

Allow non-approved MD5 use under GODEBUG=fips140=only#1133
sameerforge wants to merge 1 commit into
carvel-dev:v0.65.xfrom
sameerforge:topic/sameerkh/fips140-md5-without-enforcement

Conversation

@sameerforge

@sameerforge sameerforge commented Aug 11, 2026

Copy link
Copy Markdown

Problem

kapp uses crypto/md5.Sum() in three places, purely as a non-security convenience hash — never for authentication or integrity verification:

  • AssociationLabel.v1Value() — builds a short, stable Kubernetes label value
  • OpsDiff.MinimalMD5() / TextDiff.MinimalMD5() — key/dedup diffs

When built with GOFIPS140 and run under GODEBUG=fips140=only (Go's native FIPS 140-3 enforcement mode, Go 1.24+), any call to a non-approved cryptographic primitive panics at runtime regardless of how the result is used. Because AssociationLabel is applied to essentially every resource kapp touches, this panics on the first resource of any real kapp deploy — making kapp unusable under strict FIPS 140-3 enforcement.

Fix

Wrap each md5.Sum() call in crypto/fips140.WithoutEnforcement(func() { ... }) (Go 1.26+). Per its documented contract, this disables strict enforcement only for the duration of the scoped callback, and is a no-op when fips140=only isn't active — so behavior under any other build/run configuration (no FIPS, fips140=on, etc.) is unchanged.

go.mod is bumped from Go 1.25.10 to 1.26.5 since WithoutEnforcement requires Go 1.26+.

Testing

  • The previously-panicking test path (TestChangeSet_WithoutNew_And_WithoutUnexpectedChanges_And_IgnoredFields, which exercises AssociationLabel) now passes under GOFIPS140=v1.0.0 GODEBUG=fips140=only.
  • Verified the wrapper introduces zero behavioral change: a direct comparison of md5.Sum() output with and without the WithoutEnforcement wrapper produces byte-identical hashes under both a plain build and GODEBUG=fips140=on.
  • Ran the full go test ./... suite under GOFIPS140=v1.0.0 GODEBUG=fips140=only and again under GODEBUG=fips140=on: zero panics in both, and no new test failures relative to an unmodified baseline run.

Note
kapp's embedded ytt library also exposes an md5.sum() Starlark function to user-authored overlayContractV1 rebase rules and wait rules, which has the same panic under fips140=only. That's already being addressed upstream in ytt itself (carvel-dev/ytt#1001) rather than in this PR, since the fix belongs in the dependency that owns the exposure. This PR only addresses kapp's own direct MD5 use.

kapp's own resource-labeling and diff code calls crypto/md5.Sum() to
build short, stable keys for a k8s label (AssociationLabel.v1Value)
and to key/dedup diffs (OpsDiff.MinimalMD5, TextDiff.MinimalMD5). None
of these are security-relevant: they aren't used for authentication or
integrity verification, just to keep values short/stable and to detect
duplicate diffs.

Building with GOFIPS140 and running with GODEBUG=fips140=only (Go's
native FIPS 140-3 mode) panics on any non-approved primitive regardless
of how it's used, so these calls panic on the very first resource kapp
tries to label - i.e. on every real `kapp deploy`.

Wrap each call in crypto/fips140.WithoutEnforcement, which disables
strict enforcement only for the scoped callback (a documented no-op
when fips140=only isn't set, so this is a no-behavior-change for every
other build). WithoutEnforcement requires Go >= 1.26, so go.mod is
bumped from 1.25.10 to 1.26.0 to match.

Verified: the previously-panicking
TestChangeSet_WithoutNew_And_WithoutUnexpectedChanges_And_IgnoredFields
now passes under GOFIPS140=v1.0.0 GODEBUG=fips140=only, and a full
`go test ./...` baseline vs GODEBUG=fips140=only diff shows zero new
failures and zero panics.

Signed-off-by: Sameer <sameer.khan@broadcom.com>
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Signed-off-by: Sameer <sameer.khan@broadcom.com>
@sameerforge
sameerforge force-pushed the topic/sameerkh/fips140-md5-without-enforcement branch from 0610cae to fca9391 Compare August 11, 2026 09:01
@sameerforge

Copy link
Copy Markdown
Author

Wait for carvel-dev/vendir#458 to get merged.

@Siegfriedk

Copy link
Copy Markdown
Contributor

If the hashing itself is not relevant, why not changing to something like sha? Just a thought, i'm not sure if this would require any migration

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

3 participants