-
Notifications
You must be signed in to change notification settings - Fork 17
Fixed vulnerability #349
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Fixed vulnerability #349
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,5 @@ | ||
| # Stage 1: Builder stage | ||
| FROM node:18.19.0 AS builder | ||
| FROM node:18 AS builder | ||
|
|
||
| WORKDIR /app | ||
|
|
||
|
|
@@ -19,16 +19,42 @@ RUN yarn global add patch-package | |
| RUN yarn build | ||
|
|
||
| # Stage 2: Production stage | ||
| FROM node:18.19.0-slim | ||
| FROM node:18-slim | ||
|
|
||
| WORKDIR /app | ||
|
|
||
| # Apply OS-level security patches and patch npm-bundled vulnerable packages | ||
| RUN apt-get update && apt-get upgrade -y && rm -rf /var/lib/apt/lists/* && \ | ||
| cd /tmp && npm install tar@7.5.11 cross-spawn@7.0.6 glob@10.5.0 minimatch@9.0.7 2>/dev/null && \ | ||
| NPM_MODS=/usr/local/lib/node_modules/npm/node_modules && \ | ||
| rm -rf "$NPM_MODS/tar" "$NPM_MODS/cross-spawn" "$NPM_MODS/glob" "$NPM_MODS/minimatch" && \ | ||
| cp -r node_modules/tar $NPM_MODS/ && \ | ||
| cp -r node_modules/cross-spawn $NPM_MODS/ && \ | ||
| cp -r node_modules/glob $NPM_MODS/ && \ | ||
| cp -r node_modules/minimatch $NPM_MODS/ && \ | ||
|
Comment on lines
+31
to
+34
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Replace the package directories instead of merging into them. These 🔧 Proposed fix cd /tmp && npm install tar@7.5.11 cross-spawn@7.0.6 glob@10.5.0 minimatch@9.0.7 2>/dev/null && \
NPM_MODS=/usr/local/lib/node_modules/npm/node_modules && \
+ rm -rf "$NPM_MODS/tar" "$NPM_MODS/cross-spawn" "$NPM_MODS/glob" "$NPM_MODS/minimatch" && \
cp -r node_modules/tar $NPM_MODS/ && \
cp -r node_modules/cross-spawn $NPM_MODS/ && \
cp -r node_modules/glob $NPM_MODS/ && \
cp -r node_modules/minimatch $NPM_MODS/ && \
...
- cp -r node_modules/glob /app/node_modules/@tsoa/cli/node_modules/ && \
+ rm -rf /app/node_modules/@tsoa/cli/node_modules/glob && \
+ cp -r node_modules/glob /app/node_modules/@tsoa/cli/node_modules/ && \Also applies to: 49-50 🤖 Prompt for AI Agents |
||
| rm -rf /tmp/node_modules /tmp/package*.json | ||
|
|
||
| # Copy built files and node_modules from the builder stage | ||
| COPY --from=builder /app/build ./build | ||
| COPY --from=builder /app/bin ./bin | ||
| COPY --from=builder /app/package.json ./ | ||
| COPY --from=builder /app/node_modules ./node_modules | ||
| COPY --from=builder /app/patches ./patches | ||
|
|
||
| # Remove build-time-only packages that contain vulnerabilities and aren't needed at runtime: | ||
| # - ngrok: devDependency with vulnerable Go binary | ||
| # - tar: only used by node-pre-gyp during native module installation (already done at build time) | ||
| # Patch glob inside @tsoa/cli to fix CVE-2025-64756 | ||
| RUN rm -rf /app/node_modules/ngrok \ | ||
| /app/node_modules/tar && \ | ||
| cd /tmp && npm install glob@10.5.0 2>/dev/null && \ | ||
| rm -rf /app/node_modules/@tsoa/cli/node_modules/glob && \ | ||
| cp -r node_modules/glob /app/node_modules/@tsoa/cli/node_modules/ && \ | ||
| rm -rf /tmp/node_modules /tmp/package*.json && \ | ||
| chown -R node:node /app | ||
|
Comment on lines
+44
to
+54
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This still leaves the rest of the dev toolchain in the production image. Because Line 40 copies the full builder 🤖 Prompt for AI Agents |
||
|
|
||
| # Run as non-root user for security | ||
| USER node | ||
|
|
||
| # Set entry point | ||
| ENTRYPOINT ["node", "./bin/afj-rest.js", "start"] | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
❓ Verification inconclusive
Node.js 18 end of life EOL date 2025
Node.js 18 reached end-of-life (EOL) on April 30, 2025. It no longer receives updates or security patches from the official Node.js project. As of March 24, 2026, it is past EOL. Commercial extended support is available through partners like HeroDevs (Never-Ending Support) for security patches.
Citations:
Node.js LTS versions supported March 2026
As of March 24, 2026, the Node.js LTS versions that are supported (Active LTS or Maintenance LTS) are v24 (Active LTS, codename Krypton), v22 (Maintenance LTS, codename Jod), and v20 (Maintenance LTS, codename Iron). These are receiving security updates, as confirmed by the March 24, 2026 security releases announcement covering 24.x, 22.x, and 20.x. v25 is Current (not yet LTS), and older even versions like v18 are End-of-Life.
Citations:
Move off Node 18; it reached EOL on April 30, 2025.
Node's release schedule shows that
v18reached end-of-life on April 30, 2025, and no longer receives security updates. For a vulnerability-remediation PR, using an EOL runtime leaves the application outside upstream patch support. Move this image to a currently supported LTS release: v24 (Active LTS), v22 (Maintenance LTS), or v20 (Maintenance LTS). (nodejs.org)Also applies to: 22-22
🤖 Prompt for AI Agents