Skip to content

Security: Replace curl-pipe-bash nodesource install with official Node.js Docker image #666

Description

@LucasMaupin

Summary

The frontend Dockerfile installs Node.js by piping a remote shell script directly into bash at image build time:

RUN curl -fsSL https://deb.nodesource.com/setup_22.x | bash -

This is a supply-chain attack vector: if the nodesource CDN is compromised, DNS is hijacked, or a TLS MITM is possible in the build environment, an attacker can execute arbitrary code as root inside the Docker build context and embed malicious binaries in the final image.

Affected File

Dockerfile (lines 8–10):

RUN apt-get update
RUN apt-get install -y curl
RUN curl -fsSL https://deb.nodesource.com/setup_22.x | bash -
RUN apt-get install -y nodejs

Recommended Fix

Use a multi-stage Dockerfile (tracked in #640): use an official node:22-alpine image as the build stage, then copy only the compiled static assets into the nginx runtime stage. This eliminates the need to install Node.js into the nginx image entirely.

# Stage 1: Build
FROM node:22-alpine AS builder
WORKDIR /app
COPY package.json package-lock.json ./
RUN npm ci
COPY . .
ARG VITE_BACKEND_URL
ENV VITE_BACKEND_URL=$VITE_BACKEND_URL
RUN npm run build

# Stage 2: Serve
FROM nginx:1.29.0-alpine
COPY --from=builder /app/dist /usr/share/nginx/html
COPY ./nginx/nginx.conf /etc/nginx/conf.d/default.conf
EXPOSE 8080

This approach:

References

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

    HighPriority: highsecuritySecurity vulnerability or hardening

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions