Skip to content

fix: CVE-2024-38821 - #41221

Merged
subrata71 merged 1 commit into
releasefrom
fix/CVE-2024-38821
Sep 15, 2025
Merged

fix: CVE-2024-38821#41221
subrata71 merged 1 commit into
releasefrom
fix/CVE-2024-38821

Conversation

@subrata71

@subrata71 subrata71 commented Sep 12, 2025

Copy link
Copy Markdown
Collaborator

Description

Before:
The appsmith-ce release image contains CVE-2024-38821 critical vulnerability.
Screenshot 2025-09-12 at 1 41 00 PM

cves_report_ce.json

After:
The current DP image doesn't contain CVE-2024-38821 after removing pg build from server.

Screenshot 2025-09-12 at 1 40 36 PM

cves_41221.txt

Fixes CVE-2024-38821

Automation

/ok-to-test tags="@tag.Sanity"

🔍 Cypress test results

Tip

🟢 🟢 🟢 All cypress tests have passed! 🎉 🎉 🎉
Workflow run: https://github.com/appsmithorg/appsmith/actions/runs/17725447283
Commit: 959d97e
Cypress dashboard.
Tags: @tag.Sanity
Spec:


Mon, 15 Sep 2025 08:39:53 UTC

Communication

Should the DevRel and Marketing teams inform users about this change?

  • Yes
  • No

Summary by CodeRabbit

  • Chores
    • Removed PostgreSQL support from build artifacts; only the MongoDB edition is produced going forward.
    • Updated Docker validation to require only the MongoDB server jar; error message reflects this change.
    • Simplified artifact preparation by removing PostgreSQL image extraction and related steps.
    • Maintains existing exit-on-failure behavior; successful MongoDB paths are unchanged.
    • No changes to runtime behavior for MongoDB users.

@coderabbitai

coderabbitai Bot commented Sep 12, 2025

Copy link
Copy Markdown
Contributor

Walkthrough

The Dockerfile now validates only the presence of server/mongo/server.jar and updates the associated error message. The prepare_server_artifacts.sh script removes PostgreSQL artifact retrieval and related steps, retaining only MongoDB artifact preparation with updated messages and comments. No other build logic or error handling changed.

Changes

Cohort / File(s) Summary
Docker build validation
Dockerfile
Changed file existence check from requiring both MongoDB and PostgreSQL server jars to only MongoDB’s jar; updated error message accordingly. Exit behavior unchanged.
Artifact preparation script
scripts/prepare_server_artifacts.sh
Removed all PostgreSQL artifact extraction and Docker-based retrieval steps; preserved MongoDB artifact build/copy/rename flow; added comments/echoes noting PG removal and CVE reference; simplified control flow to only produce MongoDB artifacts.

Sequence Diagram(s)

sequenceDiagram
  autonumber
  participant Dev as Developer
  participant Script as prepare_server_artifacts.sh
  participant FS as Filesystem
  participant Docker as Docker build

  Note over Script: Simplified to MongoDB-only artifacts
  Dev->>Script: Run artifact preparation
  Script->>FS: Copy app/server/dist -> target/mongo
  Script->>FS: Rename server-*.jar -> server.jar
  Note over Script,FS: No PostgreSQL artifact steps

  Dev->>Docker: Build image
  Docker->>FS: Check server/mongo/server.jar exists
  alt Mongo jar present
    Docker-->Dev: Proceed with build
  else Missing Mongo jar
    Docker-->Dev: Fail with error (exit 1)
  end
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Poem

One jar to check, one path to go,
The Mongo road is all we know.
Postgres packed its bags, withdrew—
Scripts slim down, the build flows through.
Fewer steps, a cleaner art,
Green lights blink: ship the part.

Tip

👮 Agentic pre-merge checks are now available in preview!

Pro plan users can now enable pre-merge checks in their settings to enforce checklists before merging PRs.

  • Built-in checks – Quickly apply ready-made checks to enforce title conventions, require pull request descriptions that follow templates, validate linked issues for compliance, and more.
  • Custom agentic checks – Define your own rules using CodeRabbit’s advanced agentic capabilities to enforce organization-specific policies and workflows. For example, you can instruct CodeRabbit’s agent to verify that API documentation is updated whenever API schema files are modified in a PR. Note: Upto 5 custom checks are currently allowed during the preview period. Pricing for this feature will be announced in a few weeks.

Please see the documentation for more information.

Example:

reviews:
  pre_merge_checks:
    custom_checks:
      - name: "Undocumented Breaking Changes"
        mode: "warning"
        instructions: |
          Pass/fail criteria: All breaking changes to public APIs, CLI flags, environment variables, configuration keys, database schemas, or HTTP/GraphQL endpoints must be documented in the "Breaking Change" section of the PR description and in CHANGELOG.md. Exclude purely internal or private changes (e.g., code not exported from package entry points or explicitly marked as internal).

Please share your feedback with us on this Discord post.

✨ Finishing touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fix/CVE-2024-38821

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.

Pre-merge checks

✅ Passed checks (3 passed)
Check name Status Explanation
Title Check ✅ Passed The title "fix: CVE-2024-38821" is short, single-line, and explicitly names the vulnerability the PR targets; it aligns with the PR objective to address CVE-2024-38821 and the changes summarized (removal of PostgreSQL artifact steps and tightening the Dockerfile to require only the Mongo server.jar). This makes the title relevant and appropriately focused for a security fix. For historical clarity you may optionally append a short scope (e.g., "remove PG artifacts") but that is not required.
Docstring Coverage ✅ Passed No functions found in the changes. Docstring coverage check skipped.
Description Check ✅ Passed The PR description provides a clear Before/After explanation, screenshots, automation tag, Cypress test results, and a populated Communication section, so most required template sections are present and the intent (fixing CVE-2024-38821) is well explained. The one notable omission is the repository-required explicit issue reference format — the description says "Fixes CVE-2024-38821" but does not use "Fixes #" or a direct issue URL, and it lacks an explicit short TL;DR and a listed dependencies section. Overall the description is mostly complete and actionable.

@github-actions github-actions Bot added the Bug Something isn't working label Sep 12, 2025
@subrata71

Copy link
Copy Markdown
Collaborator Author

/build-deploy-preview

@github-actions

Copy link
Copy Markdown

Deploying Your Preview: https://github.com/appsmithorg/appsmith/actions/runs/17665653070.
Workflow: On demand build Docker image and deploy preview.
skip-tests: . env: .
PR: 41221.
recreate: .

@subrata71 subrata71 self-assigned this Sep 12, 2025

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🧹 Nitpick comments (3)
Dockerfile (1)

28-31: Use absolute path for artifact check (avoid WORKDIR assumptions).

The prepare script writes to /opt/appsmith/server/mongo/server.jar. Checking server/mongo/server.jar assumes WORKDIR=/opt/appsmith; make the path explicit to prevent false negatives.

Apply:

-  if ! [ -f server/mongo/server.jar ]; then
-    echo "Missing MongoDB server.jar file. Are you using the build script?" >&2
+  if ! [ -f /opt/appsmith/server/mongo/server.jar ]; then
+    echo "Missing /opt/appsmith/server/mongo/server.jar. Did you run scripts/prepare_server_artifacts.sh?" >&2
     exit 1
   fi

If you prefer relative paths, please confirm the base image sets WORKDIR /opt/appsmith.

scripts/prepare_server_artifacts.sh (2)

12-12: Minor: keep logs ASCII-only for CI portability.

Emojis can render poorly in some terminals/CI. Optional tweak below.


24-26: Optional: replace emojis with plain tags for consistent logs.

-echo "✅ MongoDB artifacts prepared successfully"
-echo "🗑️ PostgreSQL artifacts skipped (CVE-2024-38821 eliminated)"
-echo "📁 Only MongoDB artifacts: $target/mongo/"
+echo "[ok] MongoDB artifacts prepared successfully"
+echo "[info] PostgreSQL artifacts skipped (CVE-2024-38821 eliminated)"
+echo "[path] Only MongoDB artifacts: $target/mongo/"
📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between e1cb5d9 and 959d97e.

📒 Files selected for processing (2)
  • Dockerfile (1 hunks)
  • scripts/prepare_server_artifacts.sh (1 hunks)

Comment on lines +18 to 21
# Build MongoDB server artifacts
cp -r "app/server/dist" "$target/mongo"
mv "$target/mongo"/server-*.jar "$target/mongo/server.jar"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Guard against 0 or >1 server-*.jar matches.

mv "$target/mongo"/server-*.jar ... is brittle if the glob matches none or multiple files.

Apply:

 cp -r "app/server/dist" "$target/mongo"
-mv "$target/mongo"/server-*.jar "$target/mongo/server.jar"
+shopt -s nullglob
+jars=( "$target/mongo"/server-*.jar )
+if (( ${#jars[@]} == 1 )); then
+  mv "${jars[0]}" "$target/mongo/server.jar"
+else
+  echo "Expected exactly one server-*.jar in $target/mongo, found ${#jars[@]}: ${jars[*]}" >&2
+  exit 1
+fi
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
# Build MongoDB server artifacts
cp -r "app/server/dist" "$target/mongo"
mv "$target/mongo"/server-*.jar "$target/mongo/server.jar"
# Build MongoDB server artifacts
cp -r "app/server/dist" "$target/mongo"
shopt -s nullglob
jars=( "$target/mongo"/server-*.jar )
if (( ${#jars[@]} == 1 )); then
mv "${jars[0]}" "$target/mongo/server.jar"
else
echo "Expected exactly one server-*.jar in $target/mongo, found ${#jars[@]}: ${jars[*]}" >&2
exit 1
fi
🤖 Prompt for AI Agents
In scripts/prepare_server_artifacts.sh around lines 18–21, the mv using the glob
"server-*.jar" can fail or pick the wrong file when the glob expands to zero or
multiple matches; change the logic to enable safe globbing (e.g. set nullglob),
collect matches into an array, verify the array length is exactly 1 and exit
with a clear error if it is 0 or >1, then mv that single element to
"$target/mongo/server.jar". Ensure the script uses an explicit check and error
message instead of relying on mv's behavior.

Comment on lines +22 to +26
# PostgreSQL support has been removed - no more vulnerable artifacts
# This eliminates CVE-2024-38821 from the Docker image
echo "✅ MongoDB artifacts prepared successfully"
echo "🗑️ PostgreSQL artifacts skipped (CVE-2024-38821 eliminated)"
echo "📁 Only MongoDB artifacts: $target/mongo/"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

💡 Verification agent

🧩 Analysis chain

Good call removing PG artifacts for CVE mitigation; verify no lingering PG references.

Looks aligned with the Dockerfile change. Let’s ensure no PG paths/tags remain elsewhere.


🏁 Script executed:

#!/bin/bash
set -euo pipefail
# Find lingering references to PG artifacts/tags/paths
rg -nC2 -g '!**/node_modules/**' -P '(?i)\b(server/pg|pg/server\.jar|PG_TAG|postgresql)\b'

Length of output: 148


🏁 Script executed:

#!/bin/bash
set -euo pipefail
echo "Searching repo for PostgreSQL references..."
# Search broadly (include ignored/hidden files) for common postgres/postgresql references and known artifact names.
rg -nC2 --hidden --no-ignore -i -e "postgres" -e "postgresql" -e "PG_TAG" -e "server/pg" -e "pg/server\.jar" -e "FROM postgres" -e "postgres:" || true

Length of output: 263951


Action required — Postgres artifacts remain; CVE mitigation incomplete

prepare_server_artifacts.sh removal is fine, but the image and startup still reference/install Postgres — the vulnerable artifacts will remain unless these are removed or disabled.

  • Key locations to fix:
    • deploy/docker/base.dockerfile (installs postgresql-14; PATH /usr/lib/postgresql/14/bin)
    • deploy/docker/fs/opt/appsmith/{run-postgres.sh, pg-upgrade.sh, pg-utils.sh, entrypoint.sh — init_postgres/safe_init_postgres/create_appsmith_pg_db, supervisord/postgres.conf, postgres/appsmith_hba.conf}
    • deploy/docker/fs/opt/appsmith/templates/docker.env.sh (APPSMITH_POSTGRES_DB_URL)
    • deploy/helm/* (values.yaml, templates/deployment.yaml, templates/configMap.yaml — postgresql.enabled / init container)
    • deploy/docker/tests/* (test-pg-utils.sh, pg-test-utils.sh, pg-upgrade tests)
    • scripts/trivy_vulnerabilities_data.sh (psql usage)

Action: remove Postgres package/install and embedded startup files from the Docker image (or fully disable embedded Postgres and ensure no postgres packages are installed), then re-run vulnerability scan and grep to confirm no remaining runtime artifacts.

🤖 Prompt for AI Agents
In scripts/prepare_server_artifacts.sh around lines 22 to 26, the comment claims
PostgreSQL artifacts were skipped but the repository still installs and
references Postgres in multiple places; remove or disable those runtime
artifacts to fully mitigate CVE-2024-38821. Remove postgresql-14 installation
and any PATH additions from deploy/docker/base.dockerfile; delete or disable
run-postgres.sh, pg-upgrade.sh, pg-utils.sh, entrypoint
init_postgres/safe_init_postgres/create_appsmith_pg_db logic,
supervisord/postgres.conf and postgres/appsmith_hba.conf under
deploy/docker/fs/opt/appsmith (or ensure they are not copied into image); remove
APPSMITH_POSTGRES_DB_URL and related templates from
deploy/docker/fs/opt/appsmith/templates/docker.env.sh; update deploy/helm values
and templates to turn off postgresql.enabled and remove init
containers/configMap entries that provision Postgres; update or remove docker
tests that exercise pg utilities under deploy/docker/tests and any scripts using
psql (e.g., scripts/trivy_vulnerabilities_data.sh); after changes rebuild the
image and re-run vulnerability scan and a repo-wide grep for "postgres", "psql",
"postgresql-14" and related init scripts to confirm no Postgres binaries,
configs, or startup hooks remain in the final image.

@github-actions

Copy link
Copy Markdown

Deploy-Preview-URL: https://ce-41221.dp.appsmith.com

@subrata71

Copy link
Copy Markdown
Collaborator Author

/build-deploy-preview skip-tests=false

@github-actions

Copy link
Copy Markdown

Deploying Your Preview: https://github.com/appsmithorg/appsmith/actions/runs/17666291386.
Workflow: On demand build Docker image and deploy preview.
skip-tests: false.
env: ``.
PR: 41221.
recreate: .

@github-actions

Copy link
Copy Markdown

Deploy-Preview-URL: https://ce-41221.dp.appsmith.com

@subrata71
subrata71 requested review from pratapaprasanna and removed request for nidhi-nair September 12, 2025 07:26
@subrata71 subrata71 added the ok-to-test Required label for CI label Sep 15, 2025
@subrata71
subrata71 merged commit 20da6c6 into release Sep 15, 2025
81 of 83 checks passed
@subrata71
subrata71 deleted the fix/CVE-2024-38821 branch September 15, 2025 11:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Bug Something isn't working ok-to-test Required label for CI

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants