Skip to content

fix: harden the auto-update flow from relative paths and env var intercepts#9796

Merged
mmaietta merged 1 commit into
masterfrom
chore/linux-updater-pm-filters
May 30, 2026
Merged

fix: harden the auto-update flow from relative paths and env var intercepts#9796
mmaietta merged 1 commit into
masterfrom
chore/linux-updater-pm-filters

Conversation

@mmaietta

Copy link
Copy Markdown
Collaborator

Improves input validation, path handling robustness, and environment variable handling across the electron-updater auto-update flow. Changes span LinuxUpdater, BaseUpdater, AppUpdater, and AppImageUpdater.

Changes

packages/electron-updater/src/LinuxUpdater.ts

1. ELECTRON_BUILDER_LINUX_PACKAGE_MANAGER env var — stricter validation (detectPackageManager)

  • Added SAFE_PM_REGEX = /^[a-zA-Z0-9_-]+$/ — validates that the override value is a well-formed command name before use. Values that don't match log a warning and fall through to automatic detection.
  • Added hasCommand(pmOverride) check — verifies the specified binary is present on the system before using it. If not found, logs a warning and falls through to automatic detection.
  • Both checks are non-fatal: invalid or unavailable overrides degrade gracefully to the standard PM priority list rather than breaking the update flow.

2. Installer path handling (installerPath getter)

  • Extended the set of characters that are backslash-escaped for POSIX shell contexts: previously only \ and space were handled; now also covers `, $, !, ", ;, |, &, (, ), <, >.
  • Strips \n / \r characters from paths entirely.

3. App name handling in sudo dialog (runCommandWithSudoIfNeeded)

  • Strips shell-meaningful characters from this.app.name before embedding it in the sudo dialog comment string, ensuring the comment is well-formed regardless of what the app name contains.

packages/electron-updater/src/BaseUpdater.ts

4. PATH normalization in spawnSyncLog

  • Extracted sanitizeEnvPath(envPath: string): string — filters the inherited PATH to retain only absolute-path entries before passing it to spawnSync.
  • Added import * as path from "path" (previously absent).

packages/electron-updater/src/AppUpdater.ts

5. Consistent cache filename derivation (executeDownloadgetCacheUpdateFileName)

  • The fallback branch (used when the URL does not end with the expected file extension, e.g. /latest-style redirect URLs) now applies path.basename(...) to the URL string, matching the treatment already applied in the primary branch.

packages/electron-updater/src/AppImageUpdater.ts

6. APPIMAGE env var — path validation (doInstall)

  • Added path.isAbsolute and null-byte checks on process.env["APPIMAGE"] before use. Produces a clear ERR_UPDATER_OLD_FILE_NOT_FOUND error if the value is not a valid absolute path.

@changeset-bot

changeset-bot Bot commented May 30, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 304fcc5

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
electron-updater Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@mmaietta mmaietta force-pushed the chore/linux-updater-pm-filters branch from 236064e to 304fcc5 Compare May 30, 2026 21:06
@mmaietta mmaietta marked this pull request as ready for review May 30, 2026 21:07
@mmaietta mmaietta merged commit 2dc409f into master May 30, 2026
45 checks passed
@mmaietta mmaietta deleted the chore/linux-updater-pm-filters branch May 30, 2026 21:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant