From 2c7b4aa3c051b45fd60880ba3557fcd2f3a1b860 Mon Sep 17 00:00:00 2001 From: inkme9 Date: Thu, 9 Apr 2026 10:40:11 +0000 Subject: [PATCH 1/2] fix: replace gosu with su-exec to eliminate Go stdlib CVE gosu 1.19 is built with Go 1.24.6 which contains CVE-2025-68121 (fixed in 1.24.13). No newer gosu release available. su-exec is a minimal C alternative available in Alpine packages, providing the same CLI interface. Symlink gosu -> su-exec maintains compatibility with docker-entrypoint.sh. Co-Authored-By: Claude Opus 4.6 (1M context) --- 18/alpine3.23/Dockerfile | 32 ++++---------------------------- 1 file changed, 4 insertions(+), 28 deletions(-) diff --git a/18/alpine3.23/Dockerfile b/18/alpine3.23/Dockerfile index 7aebb1e412..a44eacca02 100644 --- a/18/alpine3.23/Dockerfile +++ b/18/alpine3.23/Dockerfile @@ -15,35 +15,11 @@ RUN set -eux; \ # see https://github.com/docker-library/postgres/issues/274 install --verbose --directory --owner postgres --group postgres --mode 1777 /var/lib/postgresql -# grab gosu for easy step-down from root -# https://github.com/tianon/gosu/releases -ENV GOSU_VERSION 1.19 +# Use su-exec instead of gosu to avoid Go stdlib CVEs in gosu binary. +# su-exec is a minimal C alternative available in Alpine packages. RUN set -eux; \ - \ - apk add --no-cache --virtual .gosu-deps \ - ca-certificates \ - dpkg \ - gnupg \ - ; \ - \ - dpkgArch="$(dpkg --print-architecture | awk -F- '{ print $NF }')"; \ - wget -O /usr/local/bin/gosu "https://github.com/tianon/gosu/releases/download/$GOSU_VERSION/gosu-$dpkgArch"; \ - wget -O /usr/local/bin/gosu.asc "https://github.com/tianon/gosu/releases/download/$GOSU_VERSION/gosu-$dpkgArch.asc"; \ - \ -# verify the signature - export GNUPGHOME="$(mktemp -d)"; \ - gpg --batch --keyserver hkps://keys.openpgp.org --recv-keys B42F6819007F00F88E364FD4036A9C25BF357DD4; \ - gpg --batch --verify /usr/local/bin/gosu.asc /usr/local/bin/gosu; \ - gpgconf --kill all; \ - rm -rf "$GNUPGHOME" /usr/local/bin/gosu.asc; \ - \ -# clean up fetch dependencies - apk del --no-network .gosu-deps; \ - \ - chmod +x /usr/local/bin/gosu; \ -# verify that the binary works - gosu --version; \ - gosu nobody true + apk add --no-cache su-exec; \ + ln -s /sbin/su-exec /usr/local/bin/gosu # make the "en_US.UTF-8" locale so postgres will be utf-8 enabled by default # alpine doesn't require explicit locale-file generation From 4cac7c6919065abb5babdb5d1664f01ea8cfdfd7 Mon Sep 17 00:00:00 2001 From: inkme9 Date: Thu, 9 Apr 2026 10:47:44 +0000 Subject: [PATCH 2/2] chore: disable upstream CI, add SBOM workflow - Disable ci.yml and verify-templating.yml (upstream CI, not needed) - Add sbom.yml: build image, generate CycloneDX SBOM (Syft), scan vulnerabilities (Grype), upload artifact Co-Authored-By: Claude Opus 4.6 (1M context) --- .github/workflows/{ci.yml => ci.yml.disabled} | 0 .github/workflows/sbom.yml | 40 +++++++++++++++++++ ...ing.yml => verify-templating.yml.disabled} | 0 3 files changed, 40 insertions(+) rename .github/workflows/{ci.yml => ci.yml.disabled} (100%) create mode 100644 .github/workflows/sbom.yml rename .github/workflows/{verify-templating.yml => verify-templating.yml.disabled} (100%) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml.disabled similarity index 100% rename from .github/workflows/ci.yml rename to .github/workflows/ci.yml.disabled diff --git a/.github/workflows/sbom.yml b/.github/workflows/sbom.yml new file mode 100644 index 0000000000..1a6ed73615 --- /dev/null +++ b/.github/workflows/sbom.yml @@ -0,0 +1,40 @@ +name: SBOM & Vulnerability Scan + +on: + push: + branches: ["release/*"] + pull_request: + branches: ["release/*"] + workflow_dispatch: + +jobs: + sbom: + name: Generate SBOM and scan + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + + - name: Build image + run: | + docker build -t postgres:local -f 18/alpine3.23/Dockerfile 18/alpine3.23/ + + - name: Generate SBOM (Syft) + uses: anchore/sbom-action@v0 + with: + image: postgres:local + format: cyclonedx-json + output-file: sbom.cdx.json + + - name: Scan vulnerabilities (Grype) + uses: anchore/scan-action@v6 + with: + image: postgres:local + fail-build: false + output-format: table + + - name: Upload SBOM + uses: actions/upload-artifact@v4 + with: + name: sbom-postgres + path: sbom.cdx.json + retention-days: 90 diff --git a/.github/workflows/verify-templating.yml b/.github/workflows/verify-templating.yml.disabled similarity index 100% rename from .github/workflows/verify-templating.yml rename to .github/workflows/verify-templating.yml.disabled