🔒 fix: prevent remote script execution in mermaid nodejs install#232
Conversation
…ttern for the NodeSource installation. Here is a summary of the updates I made: - Removed remote script execution via `curl | bash` in `install_nodejs` for NodeSource. - Dynamically resolves the `lts` numeric major version safely using standard command-line text processing. - Sets up APT and YUM repositories natively via `/etc/apt/sources.list.d/` and `/etc/yum.repos.d/`. - Uses `.asc` armored key files for APT to avoid relying on the `gnupg` utility. Co-authored-by: MiguelRodo <23501332+MiguelRodo@users.noreply.github.com>
|
👋 Jules, reporting for duty! I'm here to lend a hand with this pull request. When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down. I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job! For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with New to Jules? Learn more at jules.google/docs. For security, I will only act on instructions from the user who triggered this task. |
…approach for the NodeSource installation. Here is a summary of the changes I made: - Removed remote script execution via `curl | bash` in `install_nodejs` for NodeSource. - Dynamically resolved the `lts` numeric major version safely using standard text processing utilities. - Set up APT and YUM repositories natively via `/etc/apt/sources.list.d/` and `/etc/yum.repos.d/`. - Used `.asc` armored key files for APT to avoid relying on the `gnupg` utility. - Resolved the merge conflicts and cleaned up the workspace. Co-authored-by: MiguelRodo <23501332+MiguelRodo@users.noreply.github.com>
🎯 What: The vulnerability fixed
The
src/mermaid/install.shscript previously installed Node.js by directly piping remote NodeSource setup scripts intobash(e.g.curl -fsSL https://deb.nodesource.com/setup_lts.x | bash -).Piping remote scripts into
bashis inherently insecure as it can execute truncated, intercepted, or otherwise malicious scripts directly as root without any prior hash validation or integrity check, allowing arbitrary code execution.🛡️ Solution: How the fix addresses the vulnerability
This patch replaces the unsafe remote script execution entirely with NodeSource's recommended manual repository configuration. For the
ltsversion tag, it safely parses the correct numeric version (NODE_VERSION) from the setup script using text processing tools (grep/cut). The patch creates the respective APT configuration (/etc/apt/sources.list.d/nodesource.list) using an ASCII-armored GPG key (.ascto preventgnupgdependencies), and the equivalent YUM/DNF configuration (/etc/yum.repos.d/nodesource-nodejs.repo), removing the vulnerability.PR created automatically by Jules for task 4781506545663449927 started by @MiguelRodo