Skip to content

Fixed vulnerability#349

Open
DeepDN wants to merge 2 commits intocredebl:mainfrom
DeepDN:fix/docker_vulnerability
Open

Fixed vulnerability#349
DeepDN wants to merge 2 commits intocredebl:mainfrom
DeepDN:fix/docker_vulnerability

Conversation

@DeepDN
Copy link
Copy Markdown

@DeepDN DeepDN commented Mar 24, 2026

What was fixed:

  • Base image :- Upgraded node:18.19.0 → node:18 (Debian 12.13, Node 18.20.8),
  • OS packages :- apt-get upgrade patches all available Debian CVEs,
  • npm bundled (tar, cross-spawn, glob, minimatch) :- Patched inside /usr/local/lib/node_modules/npm/node_modules/,
  • axios :- Upgraded 1.9.0 → 1.13.6 in package.json,
  • form-data, jws, flatted, validator, minimatch, undici, tar:- Forced via yarn resolutions,
  • glob@10.4.5 in @tsoa/cli :- Patched in-place in Dockerfile,
  • ngrok binary :- Removed from production image (devDependency with vulnerable Go binary),
  • tar@6.2.1 in app/node_modules :- Removed (only used by node-pre-gyp at install time, not runtime),
  • File permissions :- chown -R node:node /app + USER node for non-root execution

Remaining (no fix available upstream):

  • zlib1g CRITICAL (CVE-2023-45853) — Debian hasn't released a patch
  • libc6/libc-bin HIGH (CVE-2026-0861) — status affected, no fixed version yet"

Summary by CodeRabbit

Release Notes

  • Bug Fixes

    • Patched multiple dependency vulnerabilities to enhance application security
    • Improved container security by enforcing non-root user execution
  • Chores

    • Updated and pinned transitive dependencies for more stable and secure builds

…8.20.8),

- OS packages :- apt-get upgrade patches all available Debian CVEs,
- npm bundled (tar, cross-spawn, glob, minimatch) :- Patched inside /usr/local/lib/node_modules/npm/node_modules/,
- axios :- Upgraded 1.9.0 → 1.13.6 in package.json,
- form-data, jws, flatted, validator, minimatch, undici, tar:- Forced via yarn resolutions,
- glob@10.4.5 in @tsoa/cli :- Patched in-place in Dockerfile,
- ngrok binary :- Removed from production image (devDependency with vulnerable Go binary),
- tar@6.2.1 in app/node_modules :- Removed (only used by node-pre-gyp at install time, not runtime),
- File permissions :- chown -R node:node /app + USER node for non-root execution

Remaining (no fix available upstream):
- zlib1g CRITICAL (CVE-2023-45853) — Debian hasn't released a patch
- libc6/libc-bin HIGH (CVE-2026-0861) — status affected, no fixed version yet

Signed-off-by: DeepDN <nemadedeepak1111@gmail.com>
@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Mar 24, 2026

📝 Walkthrough

Walkthrough

The Dockerfile now uses flexible Node base images with OS-level security updates and manual npm package patching to remediate vulnerabilities. The package.json concurrently bumps axios and expands resolutions to enforce specific versions of transitive dependencies for consistency.

Changes

Cohort / File(s) Summary
Docker Build Configuration
Dockerfile
Updated to use generic Node 18 images, added OS-level patching (apt-get update && apt-get upgrade), manually installed and patched npm packages (tar, cross-spawn, glob, minimatch) for vulnerability remediation, removed incompatible runtime packages (ngrok, tar), and switched to non-root node user.
Dependency Management
package.json
Bumped axios from ^1.9.0 to ^1.13.6 and expanded resolutions block to pin transitive dependencies (axios, flatted, form-data, jws, minimatch, tar, undici, validator) for consistency and security.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

🐰 A rabbit's tale of patches and care,
Fixing vulnerabilities with flair,
Docker builds stronger, packages align,
Security updates in line after line,
One hop closer to code so divine! 🛡️

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'Fixed vulnerability' directly and accurately summarizes the primary objective of the changeset—addressing multiple security vulnerabilities through dependency upgrades and Docker image hardening.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 3

🧹 Nitpick comments (1)
package.json (1)

69-69: Scope the new resolutions to the affected parents.

The direct axios bump is fine, but these unscoped overrides also force newer majors for packages like tar, minimatch, and undici across the whole install. Yarn Classic supports selective nested selectors in resolutions and warns when an override is incompatible with the original request, so it is safer to target the vulnerable parent paths instead of overriding the entire tree. (classic.yarnpkg.com)

Also applies to: 117-127

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@package.json` at line 69, The package.json currently pins dependencies
globally via top-level "resolutions" which forces newer majors (e.g., tar,
minimatch, undici) across the entire tree; narrow those overrides to the
specific parent packages that depend on vulnerable versions instead of global
selectors. Update the "resolutions" entries to use selective nested selectors
that target the affected parents (for example the package names that require
tar/minimatch/undici) rather than wildcard or root-level overrides, and ensure
the direct "axios" bump stays as-is; apply the same selective-scoping approach
to the other entries mentioned (around the block corresponding to lines 117-127)
so only the vulnerable dependency chains are constrained.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@Dockerfile`:
- Around line 30-33: The Dockerfile currently uses recursive copy commands
(e.g., the 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/) which merge into existing target folders and can leave old
vulnerable files behind; change these steps to replace the target directories
atomically by removing the destination first (or moving the source into place)
before copying or by using a single mv or rm -rf $NPM_MODS/<package> && cp -r
node_modules/<package> $NPM_MODS/ pattern for each package (also apply the same
replacement behavior to the similar commands around lines noted 49-50) so the
destination contains only the new package contents.
- Around line 43-52: The Dockerfile currently copies the full builder
node_modules and only removes ngrok/tar, leaving all devDependencies in the
runtime image; change the final image to install only production packages (or
explicitly prune dev deps) instead of copying builder node_modules. Update the
Dockerfile to, in the final stage, either copy package.json/package-lock.json
and run npm ci --omit=dev (or npm prune --production) inside the runtime stage,
or use a multistage approach where builder installs dev deps and outputs built
artifacts while the final stage runs npm ci --omit=dev and then copies built
artifacts; ensure the existing chown -R node:node /app is preserved and remove
the ad-hoc cp/rm steps that try to patch `@tsoa/cli` after copying full
node_modules.
- Line 2: Base image uses Node 18 which reached EOL; update the Dockerfile base
image to a supported LTS. Edit the Dockerfile line "FROM node:18 AS builder"
(and any similar occurrences like "FROM node:22-22" if present) to a supported
LTS tag such as "node:24" (or "node:22" / "node:20" if you prefer maintenance
LTS), ensure any associated tooling or package-lock files remain compatible,
rebuild and run tests to confirm no runtime or dependency breakage, and update
any CI configs that reference the old image tag.

---

Nitpick comments:
In `@package.json`:
- Line 69: The package.json currently pins dependencies globally via top-level
"resolutions" which forces newer majors (e.g., tar, minimatch, undici) across
the entire tree; narrow those overrides to the specific parent packages that
depend on vulnerable versions instead of global selectors. Update the
"resolutions" entries to use selective nested selectors that target the affected
parents (for example the package names that require tar/minimatch/undici) rather
than wildcard or root-level overrides, and ensure the direct "axios" bump stays
as-is; apply the same selective-scoping approach to the other entries mentioned
(around the block corresponding to lines 117-127) so only the vulnerable
dependency chains are constrained.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: f7b22026-25aa-4b17-b05a-2405bc9e5a31

📥 Commits

Reviewing files that changed from the base of the PR and between 104f72a and 678e20b.

⛔ Files ignored due to path filters (1)
  • yarn.lock is excluded by !**/yarn.lock, !**/*.lock
📒 Files selected for processing (2)
  • Dockerfile
  • package.json

@@ -1,5 +1,5 @@
# Stage 1: Builder stage
FROM node:18.19.0 AS builder
FROM node:18 AS builder
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

❓ 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 v18 reached 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
Verify each finding against the current code and only fix it if needed.

In `@Dockerfile` at line 2, Base image uses Node 18 which reached EOL; update the
Dockerfile base image to a supported LTS. Edit the Dockerfile line "FROM node:18
AS builder" (and any similar occurrences like "FROM node:22-22" if present) to a
supported LTS tag such as "node:24" (or "node:22" / "node:20" if you prefer
maintenance LTS), ensure any associated tooling or package-lock files remain
compatible, rebuild and run tests to confirm no runtime or dependency breakage,
and update any CI configs that reference the old image tag.

Comment on lines +30 to +33
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/ && \
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

Replace the package directories instead of merging into them.

These cp -r calls merge into the existing package folders rather than replacing them. Files that existed only in the vulnerable version can be left behind, so the result may still be a mixed tree instead of a clean patch.

🔧 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
Verify each finding against the current code and only fix it if needed.

In `@Dockerfile` around lines 30 - 33, The Dockerfile currently uses recursive
copy commands (e.g., the 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/) which merge into existing target folders and
can leave old vulnerable files behind; change these steps to replace the target
directories atomically by removing the destination first (or moving the source
into place) before copying or by using a single mv or rm -rf $NPM_MODS/<package>
&& cp -r node_modules/<package> $NPM_MODS/ pattern for each package (also apply
the same replacement behavior to the similar commands around lines noted 49-50)
so the destination contains only the new package contents.

Comment on lines +43 to +52
# 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 && \
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
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

This still leaves the rest of the dev toolchain in the production image.

Because Line 40 copies the full builder node_modules, pruning only ngrok and tar still leaves the rest of devDependencies in the runtime image. That keeps unnecessary packages—and their scan surface—inside production. Prefer a clean production-only install or an explicit prune step after the copy.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@Dockerfile` around lines 43 - 52, The Dockerfile currently copies the full
builder node_modules and only removes ngrok/tar, leaving all devDependencies in
the runtime image; change the final image to install only production packages
(or explicitly prune dev deps) instead of copying builder node_modules. Update
the Dockerfile to, in the final stage, either copy
package.json/package-lock.json and run npm ci --omit=dev (or npm prune
--production) inside the runtime stage, or use a multistage approach where
builder installs dev deps and outputs built artifacts while the final stage runs
npm ci --omit=dev and then copies built artifacts; ensure the existing chown -R
node:node /app is preserved and remove the ad-hoc cp/rm steps that try to patch
`@tsoa/cli` after copying full node_modules.

…8.20.8),

- OS packages :- apt-get upgrade patches all available Debian CVEs,
- npm bundled (tar, cross-spawn, glob, minimatch) :- Patched inside /usr/local/lib/node_modules/npm/node_modules/,
- axios :- Upgraded 1.9.0 → 1.13.6 in package.json,
- form-data, jws, flatted, validator, minimatch, undici, tar:- Forced via yarn resolutions,
- glob@10.4.5 in @tsoa/cli :- Patched in-place in Dockerfile,
- ngrok binary :- Removed from production image (devDependency with vulnerable Go binary),
- tar@6.2.1 in app/node_modules :- Removed (only used by node-pre-gyp at install time, not runtime),
- File permissions :- chown -R node:node /app + USER node for non-root execution

Remaining (no fix available upstream):
- zlib1g CRITICAL (CVE-2023-45853) — Debian hasn't released a patch
- libc6/libc-bin HIGH (CVE-2026-0861) — status affected, no fixed version yet

Signed-off-by: DeepDN <nemadedeepak1111@gmail.com>
@sonarqubecloud
Copy link
Copy Markdown

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant