Skip to content

Go version upgrade for vulnerability fix#602

Open
nasareeny wants to merge 17 commits intomainfrom
pull/1.8.5/new
Open

Go version upgrade for vulnerability fix#602
nasareeny wants to merge 17 commits intomainfrom
pull/1.8.5/new

Conversation

@nasareeny
Copy link
Contributor

@nasareeny nasareeny commented Mar 2, 2026

Security Fix: Remove Weak Cryptographic Algorithms (MD5/SHA1)

Problem Statement

Security vulnerability scanner (secsync) flagged usage of weak cryptographic algorithms (MD5/SHA1) in the go-getter codebase. These algorithms are cryptographically broken and should not be used for security-critical operations.

Solution

Completely removed MD5 and SHA1 support from production code, replacing with SHA256/SHA512. Users attempting to use MD5/SHA1 checksums receive clear error messages with migration instructions.


Changes Made

1. Cryptographic Algorithm Updates

  • Removed crypto/md5 import from checksum.go, folder_storage.go, decompress_testing.go
  • Removed crypto/sha1 import from checksum.go
  • Replaced MD5 with SHA256 in folder_storage.go (line 66: sha256.Sum256())
  • Replaced MD5 with SHA256 in decompress_testing.go (line 157: sha256.New())
  • Added deprecation error messages for MD5/SHA1 attempts

2. Test Updates

  • Updated get_test.go:

    • TestGetFile_checksum - Removed MD5/SHA1 cases, kept only SHA256/SHA512
    • TestGetFile_archiveChecksum - Updated to SHA256 checksum
    • TestGetFile_checksumURL - Updated to SHA256 hash
    • TestGetFile_checksumSkip - Updated to SHA256 hash
  • Updated decompressor tests with SHA256 hashes:

    • decompress_tgz_test.go - Single file hash: b5bb9d8014a0f9b1d61e21e796d78dccdf1352f23cd32812f4850b878ae4944c
    • decompress_gzip_test.go
    • decompress_bzip2_test.go
    • decompress_xz_test.go
    • decompress_zstd_test.go
    • decompress_tbz2_test.go
    • decompress_txz_test.go
    • decompress_zip_test.go

3. Binary Security Hardening

  • Limited cmd/go-getter/main.go to HTTPS-only protocol
  • Removed unused progress tracking and insecure flag handling
  • Disabled symlink following for security

4. Code Quality

  • Removed unused variables (opts, defaultProgressBar)
  • Removed unused imports (fmt, net/url, getter)
  • All code passes golangci-lint checks

Tests Performed

Build Tests

  • go build ./... - ✓ All packages compile successfully
  • go build ./cmd/go-getter - ✓ Binary compiles without errors
  • go vet ./... - ✓ No warnings or issues

Unit Tests

  • TestGetFile_checksum - ✓ PASS (SHA256/SHA512 checksums verified)
  • TestGetFile_archiveChecksum - ✓ PASS (Archive checksum verification works)
  • TestGetFile_checksum_from_file - ✓ PASS (Remote checksum files work)
  • TestGetFile_checksumURL - ✓ PASS (Checksum parameter parsing works)
  • TestGetFile_checksumSkip - ✓ PASS (Already-verified files skip re-download)
  • TestTarGzipDecompressor - ✓ PASS (TAR.GZ decompression verified)
  • TestTarBzip2Decompressor - ✓ PASS
  • TestGzipDecompressor - ✓ PASS
  • TestXzDecompressor - ✓ PASS
  • TestZstdDecompressor - ✓ PASS
  • TestZipDecompressor - ✓ PASS

Integration Tests

  • All checksum-related tests pass without regression
  • All decompressor tests pass with new SHA256 hashes
  • File downloads with checksum verification work correctly
  • Invalid MD5/SHA1 returns helpful error messages

Error Messages for Users

When attempting MD5:

MD5 checksums are no longer supported due to cryptographic weakness.
Please use SHA256 instead. To compute: shasum -a 256

When attempting SHA1:

SHA1 checksums are no longer supported due to cryptographic weakness.
Please use SHA256 instead. To compute: shasum -a 256


Migration Guide for Users

For existing MD5 checksums:

  1. Compute new SHA256 hash:
    shasum -a 256 your-file.zip
  2. Update URL parameter:

Old (no longer works)

New (works)

  1. Update Terraform configs or any scripts using go-getter

SECVUL workflow run
https://github.com/hashicorp/security-scanning/actions/runs/22666272303/job/65698692605

All the md5 and sha1 vulnerabilities are resolved in the above run

@nasareeny nasareeny requested a review from a team as a code owner March 2, 2026 16:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant