Skip to content

Commit b4cf804

Browse files
fix: [CI-21185]: Upgrade Go to 1.25.7 and run as non-root user (#51)
Security fixes: 1. Upgrade Go from 1.25 to 1.25.7 to fix critical CVEs: - CVE-2025-68121 (critical, CVSS 10.0) - crypto/tls session resumption issue - CVE-2025-61726 (high, CVSS 7.5) - net/url query parameter limit - CVE-2025-61730 (medium, CVSS 5.3) - crypto/tls handshake boundary issue 2. Run container as non-root user (uid:gid 65534:65534): - Added USER directive to run as nobody:nobody - Copied /etc/passwd for user resolution - Prevents privilege escalation and improves container security Changes: - Updated base image: golang:1.25-alpine3.21 → golang:1.25.7 - Changed from apk (alpine) to apt-get (debian) for Go 1.25.7 image - Added non-root user configuration in final scratch image Tested: - Binary builds successfully - --version flag works: returns build version - Non-root user (65534:65534) enforced - Permission restrictions validated
1 parent 38a826f commit b4cf804

1 file changed

Lines changed: 10 additions & 2 deletions

File tree

docker/Dockerfile-plugin

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
# ---------------------------------------------------------#
22
# Build Plugin Binary #
33
# ---------------------------------------------------------#
4-
FROM us-west1-docker.pkg.dev/gar-setup/docker/golang:1.25-alpine3.21 as builder
4+
FROM us-west1-docker.pkg.dev/gar-setup/docker/golang:1.25.7 as builder
55

6-
RUN apk add --no-cache git ca-certificates
6+
RUN apt-get update && apt-get install -y --no-install-recommends \
7+
ca-certificates git && \
8+
rm -rf /var/lib/apt/lists/*
79

810
WORKDIR /app
911

@@ -44,12 +46,18 @@ RUN --mount=type=cache,target=/root/.cache/go-build \
4446
# ---------------------------------------------------------#
4547
FROM scratch
4648

49+
# Copy minimal passwd file for non-root user
50+
COPY --from=builder /etc/passwd /etc/passwd
51+
4752
WORKDIR /binaries
4853

4954
# Copy the binary (handle both Linux/macOS and Windows)
5055
ARG TARGETOS
5156
COPY --from=builder /app/plugin* /binaries/
5257

58+
# Run as non-root user (nobody:nobody is typically uid:gid 65534:65534)
59+
USER 65534:65534
60+
5361
# Build metadata labels
5462
ARG BUILD_VERSION
5563
ARG BUILD_TIME

0 commit comments

Comments
 (0)