Skip to content

SHA-256 validation fails when unzip is unavailable because distribution format is silently changed to .tar.gz #425

Description

@rhusar

When unzip is not installed, mvnw silently rewrites the distributionUrl from .zip to .tar.gz

if ! command -v unzip >/dev/null; then
  distributionUrl="${distributionUrl%.zip}.tar.gz"
  distributionUrlName="${distributionUrl##*/}"
fi

(from # Apache Maven Wrapper startup batch script, version 3.3.4)

However, the distributionSha256Sum validation on still runs against the configured checksum, which was computed for the .zip file. The .tar.gz has a different checksum, so validation always fails with:

Error: Failed to validate Maven distribution SHA-256, your Maven distribution might be compromised.
If you updated your Maven version, you need to update the specified distributionSha256Sum property.

This appears to be to be a design issue – the distibution is either zip or tar.gz but there is only ever a single distributionSha256Sum property. What is the reasong for this design? There inevitably need to be a sha sum configured for each downloadable distribution.

Steps to reproduce

  1. Configure maven-wrapper.properties with distributionSha256Sum for the .zip distribution
  2. Run ./mvnw in an environment without unzip (e.g. eclipse-temurin Docker image)
  3. Build fails with SHA-256 validation error

Expected behavior

Described above.

Environment

  • Maven Wrapper 3.3.4
  • eclipse-temurin:25 Docker image (Ubuntu 26.04, no unzip, no wget/curl)

Workaround

Install unzip in the environment before running mvnw, e.g. in Containerfile

# Install unzip required by Maven Wrapper to download the .zip distribution;
# without it, mvnw downloads .tar.gz which doesn't match distributionSha256Sum
RUN apt-get update && apt-get install -y unzip

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions