build: verify Maven distribution checksums (#4751)

* build: verify Maven distribution checksums

Pin distributionSha256Sum in the Maven wrapper so mvnw rejects a tampered
download, and check Apache's published SHA-512 before extracting Maven in
Dockerfile.native.

* build: require unzip when the Maven wrapper checksum is pinned

Without unzip, mvnw downloads the .tar.gz distribution and checks it
against the .zip checksum, reporting a possibly compromised download.
Stop with a clear message instead.
This commit is contained in:
Niels Kootstra authored and GitHub committed 2026-09-30 21:44:42 -05:00
1 parent 123941dd03
commit 02eb4e7297
3 files changed
+8 -1

No files matched your search

+5 -1
View File
@@ -4,7 +4,11 @@ USER root
WORKDIR /app
# Install Maven 3.9.x (system Maven is too old for Quarkus 3.31)
RUN curl -fsSL https://archive.apache.org/dist/maven/maven-3/3.9.12/binaries/apache-maven-3.9.12-bin.tar.gz | tar xz -C /opt \
# The SHA-512 is Apache's published checksum for apache-maven-3.9.12-bin.tar.gz.
RUN curl -fsSL -o /tmp/maven.tar.gz https://archive.apache.org/dist/maven/maven-3/3.9.12/binaries/apache-maven-3.9.12-bin.tar.gz \
&& echo "0a1be79f02466533fc1a80abbef8796e4f737c46c6574ede5658b110899942a94db634477dfd3745501c80aef9aac0d4f841d38574373f7e2d24cce89d694f70 /tmp/maven.tar.gz" | sha512sum -c - \
&& tar xzf /tmp/maven.tar.gz -C /opt \
&& rm /tmp/maven.tar.gz \
&& ln -sf /opt/apache-maven-3.9.12/bin/mvn /usr/local/bin/mvn
COPY pom.xml .