fix: replace the vulnerable undici bundled with npm in the image

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Ruben Fiszel
2026-10-18 20:14:40 +02:00
co-authored by Claude Opus 5.5
parent b0c97b34ca
commit 4849f91b72
+15
View File
@@ -254,6 +254,21 @@ RUN curl -sL https://deb.nodesource.com/setup_24.x | bash -
RUN apt-get -y update && apt-get install -y --no-install-recommends curl procps nodejs awscli && apt-get clean \
&& rm -rf /var/lib/apt/lists/*
# The npm bundled with nodejs carries undici (via node-gyp) older than 6.29.1, which has
# CVE-2026-109383. Replaced in place until a bundled npm ships a fixed one; a bundled undici
# at or past this version, or on a later major, is left alone.
ARG NPM_UNDICI_VERSION=6.29.1
RUN dir=/usr/lib/node_modules/npm/node_modules/undici; \
if [ -f "$dir/package.json" ]; then \
current="$(node -p "require('$dir/package.json').version")"; \
if [ "${current%%.*}" = "${NPM_UNDICI_VERSION%%.*}" ] && [ "$(printf '%s\n' "$current" "$NPM_UNDICI_VERSION" | sort -V | head -n1)" != "$NPM_UNDICI_VERSION" ]; then \
cd /tmp && npm pack "undici@$NPM_UNDICI_VERSION" \
&& rm -rf "$dir" && mkdir "$dir" \
&& tar -xzf "undici-$NPM_UNDICI_VERSION.tgz" -C "$dir" --strip-components=1 \
&& rm "undici-$NPM_UNDICI_VERSION.tgz" && rm -rf /root/.npm; \
fi; \
fi
# go build is slower the first time it is ran, so we prewarm it in the build
# This mirrors Windmill's Go wrapper structure: main.go imports inner package, uses encoding/json, os, fmt
RUN export GOCACHE=/tmp/build_cache/go && \