** Description changed:

  [Impact]
  
  * Ubuntu's package build process uses dh_strip_nondeterminism, which modifies 
the timestamps and entry order of the bundled FIPS 140 snapshot ZIPs in golang 
src packages. While the decompressed files remain identical, this metadata 
change alters the SHA-256 hash of the ZIP archives, causing a mismatch with the 
upstream fips140.sum.
- * While the Go 1.24–1.26 compilers do not strictly abort at runtime due to 
this mismatch (unlike Go 1.27), the packages currently ship with invalid 
checksums that violate FIPS integrity expectations.
+ * On Go 1.27 (stonking, tenacious), go build / go run verifies snapshot ZIPs 
against fips140.sum and aborts with a SHA-256 mismatch error, breaking native 
FIPS 140-3 builds.
+ * On Go 1.24–1.26 (Jammy, Noble, Resolute, and golang-1.26 on Stonking), go 
build / go run does not enforce fips140.sum, so FIPS builds and binaries still 
work. However, the modified ZIPs violate upstream's FIPS 140-3 security policy 
(such as CMVP #5247 for v1.0.0) and cause Go's own cmd/go/internal/fips140 
(TestSums) validation test to fail out of the box.
  * The fix resolves this by excluding usr/share/go-$(GOVER)/lib/fips140/ from 
dh_strip_nondeterminism in debian/rules, preserving the certified archives 
byte-for-byte.
  
  [Test Plan]
  
  Run the following steps for each affected Go version (1.24, 1.25, 1.26, or 
1.27):
  1. Install the matching Go compiler and source packages.
- 2. Compare the SHA-256 hash of the bundled FIPS 140 archives against the 
expected upstream digest:
-   $ sha256sum /usr/share/go-${GOVER}/lib/fips140/*.zip
-   $ cat /usr/share/go-${GOVER}/lib/fips140/fips140.sum
+ 2. Run Go's built-in FIPS 140 checksum validation test against the installed 
GOROOT:
+    $ /usr/lib/go-${GOVER}/bin/go test -C /usr/lib/go-${GOVER}/src 
cmd/go/internal/fips140
+    - Without the fix (1.24–1.27): fails in TestSums with "policy violation: 
zip file hash is changing".
+    - With the fix applied (1.24–1.27): passes ("ok  cmd/go/internal/fips140").
  
- 3. Without the fix, the hash is incorrect due to the altered metadata.
- 4. With the fix applied, the SHA-256 hash will perfectly match the expected 
certified upstream digest.
- 5. Verify the compiler still functions correctly in FIPS mode:
+ 3. Verify the compiler functions correctly in FIPS mode with a clean
+ module cache:
  
  cat >/tmp/fips-check.go <<'EOF'
  package main
  import (
   "crypto/fips140"
   "fmt"
  )
  func main() {
   if !fips140.Enabled() {
    panic("FIPS mode is disabled")
   }
   fmt.Println("FIPS mode enabled")
  }
  EOF
  
  GOFIPS140=v1.0.0 GOTOOLCHAIN=local CGO_ENABLED=0 GODEBUG= \
    GOPATH="$(mktemp -d)" GOCACHE="$(mktemp -d)" \
    /usr/lib/go-${GOVER}/bin/go run /tmp/fips-check.go
  
- 6. The command should succeed and output "FIPS mode enabled" (on Go
- 1.27, this fails prior to the fix due to the checksum mismatch).
+ 4. Expected result:
+    - Go 1.27: fails prior to the fix with a SHA-256 checksum mismatch error 
against fips140.sum; succeeds and outputs "FIPS mode enabled" with the fix.
+    - Go 1.24–1.26: regression check confirming the unmodified snapshot ZIP 
builds and outputs "FIPS mode enabled".
  
  [Where problems could occur]
  
  * The change only passes --exclude=usr/share/go-$(GOVER)/lib/fips140/ to 
dh_strip_nondeterminism in debian/rules; no Go compiler or standard library 
code is modified.
  * Because the entire lib/fips140/ directory is excluded from 
dh_strip_nondeterminism, files in that directory retain their upstream metadata 
rather than being normalized during the Debian build. If upstream were to 
introduce non-deterministic metadata in that directory in a future release, 
binary build reproducibility for golang-$(GOVER)-src could be affected, though 
upstream generates these snapshot ZIPs deterministically.

-- 
You received this bug notification because you are a member of Ubuntu
Bugs, which is subscribed to Ubuntu.
https://bugs.launchpad.net/bugs/2174696

Title:
  FIPS 140 snapshot checksum mismatch due to dh_strip_nondeterminism

To manage notifications about this bug go to:
https://bugs.launchpad.net/ubuntu/+source/golang-1.24/+bug/2174696/+subscriptions


-- 
ubuntu-bugs mailing list
[email protected]
https://lists.ubuntu.com/mailman/listinfo/ubuntu-bugs

Reply via email to