Skip to content

[improve][misc] Replace MD5 NAR/archive checksums with SHA-256#26152

Merged
david-streamlio merged 2 commits into
apache:masterfrom
david-streamlio:fips-qw-archive-checksums
Jul 9, 2026
Merged

[improve][misc] Replace MD5 NAR/archive checksums with SHA-256#26152
david-streamlio merged 2 commits into
apache:masterfrom
david-streamlio:fips-qw-archive-checksums

Conversation

@david-streamlio

@david-streamlio david-streamlio commented Jul 6, 2026

Copy link
Copy Markdown
Contributor

Motivation

FileUtils.calculateMd5sum backs two non-security change-detection mechanisms: the NAR extraction directory checksum (NarUnpacker) and the connector/function archive identity used for hot-reload (ConnectorUtils/FunctionUtils). MD5 is fine for change detection, but strict security providers reject it outright — under BC-FIPS in approved-only mode, MessageDigest.getInstance("md5") throws, which breaks NAR extraction (and therefore broker/worker startup with connectors) on FIPS-configured JVMs.

This is one of a set of small preparatory cleanups for FIPS-restricted deployments; a broader PIP covering TLS provider wiring, packaging, and message-crypto algorithm migration is being drafted separately.

Modifications

  • FileUtils: replaced calculateMd5sum with calculateSha256sum (SHA-256, larger read buffer); javadoc documents that the checksum is change detection, not a security control.
  • NarUnpacker: uses the SHA-256 checksum for the extraction directory and lock-file names; local variable renamed accordingly.
  • ConnectorUtils/FunctionUtils: computeArchiveMd5HexcomputeArchiveChecksumHex (SHA-256).
  • Connector/FunctionArchive: field/accessor renames (getArchiveChecksumHex), javadoc updated.

The archive checksum is only compared in-memory against values computed by the same JVM, so the algorithm change is not observable there. The NAR extraction directory name changes, causing a one-time re-extraction after upgrade; stale checksum-named directories from older versions are left behind in the extraction dir, matching existing behavior when NAR content changes.

Verifying this change

  • Make sure that the change passes the CI checks.

This change is already covered by existing tests: NarUnpackerTest (extraction/locking against the new checksum naming), ConnectorUtilsReloadTest and FunctionUtilsReloadTest (archive-identity change detection).

Does this pull request potentially affect one of the following parts:

  • Dependencies (add or upgrade a dependency)
  • The public API
  • The schema
  • The default values of configurations
  • The threading model
  • The binary protocol
  • The REST endpoints
  • The admin CLI options
  • The metrics
  • Anything that affects deployment

These digests are change-detection checksums, not security controls, but
MD5 is rejected outright by strict security providers (e.g. BC-FIPS in
approved-only mode), which would break NAR extraction and connector/function
archive reload on FIPS-configured JVMs. Switch to SHA-256 and rename the
APIs to be algorithm-accurate.

The NAR extraction directory name changes, causing a one-time re-extraction
after upgrade; stale checksum-named directories from older versions are left
behind in the extraction dir, matching existing behavior across NAR content
changes.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR updates Pulsar’s non-security checksum-based change-detection mechanisms to use SHA-256 instead of MD5, avoiding failures on FIPS-configured JVMs where weak digests can be rejected (e.g., MessageDigest.getInstance("md5") throwing under strict providers). The change affects NAR unpacking directory/lock naming and connector/function archive identity checks used for hot reload.

Changes:

  • Replaced FileUtils.calculateMd5sum with FileUtils.calculateSha256sum (SHA-256; larger read buffer; clarified javadoc that it’s for change detection).
  • Updated NarUnpacker to derive extraction directory and lockfile names from the SHA-256 checksum.
  • Renamed connector/function archive identity helpers and fields from “Md5” to generic “Checksum” and switched to SHA-256 hex.

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated no comments.

Show a summary per file
File Description
pulsar-functions/utils/src/main/java/org/apache/pulsar/functions/utils/io/ConnectorUtils.java Uses SHA-256 hex for connector archive identity during reload; renames helper to checksum-based name.
pulsar-functions/utils/src/main/java/org/apache/pulsar/functions/utils/io/Connector.java Renames stored archive digest field/accessor to checksum and computes SHA-256 via updated utility.
pulsar-functions/utils/src/main/java/org/apache/pulsar/functions/utils/functions/FunctionUtils.java Uses SHA-256 hex for function archive identity during reload; renames helper to checksum-based name.
pulsar-functions/utils/src/main/java/org/apache/pulsar/functions/utils/functions/FunctionArchive.java Renames stored archive digest field/accessor to checksum and computes SHA-256 via updated utility.
pulsar-common/src/main/java/org/apache/pulsar/common/nar/NarUnpacker.java Switches unpack directory + lock naming from MD5 to SHA-256 checksum.
pulsar-common/src/main/java/org/apache/pulsar/common/nar/FileUtils.java Implements SHA-256 checksum calculation and updates documentation accordingly.

@david-streamlio
david-streamlio merged commit a0f0f05 into apache:master Jul 9, 2026
43 checks passed
@david-streamlio
david-streamlio deleted the fips-qw-archive-checksums branch July 9, 2026 14:52
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.

5 participants