emdash icon indicating copy to clipboard operation
emdash copied to clipboard

[bug]: AppImage launch fork-bombs on Linux

Open raulpineda opened this issue 7 months ago • 1 comments

Bug Description

On Linux AppImage installs, Emdash's startup shell-env probe at src/main/utils/shellEnv.ts:44 hands process.env wholesale to a $SHELL -ilc subshell. An AppImage sets APPIMAGE, APPDIR, and injects /tmp/.mount_* entries into PATH / LD_LIBRARY_PATH / XDG_DATA_DIRS, all of which leak into the probed login shell. If the user's .zshrc / .bash_profile exec's any binary by name through PATH — starship's language version modules, mise's activation hook, oh-my-zsh completion plugins all do some flavor of this — that exec can resolve back into the AppImage mount, boot a second Emdash main process, which runs the same probe, which spawns another shell. Fork bomb, OOM.

src/main/utils/childProcessEnv.ts already exports buildExternalToolEnv() for exactly this purpose and is wired into src/main/services/ptyManager.ts and src/main/ipc/appIpc.ts. shellEnv.ts is the remaining call site where process.env is still passed wholesale into a child shell.

Steps to Reproduce

  1. Install the emdash-x86_64.AppImage release on a Linux box whose login shell is zsh and whose .zshrc sources mise / starship / oh-my-zsh (in my case: CachyOS / Arch).
  2. Launch the AppImage.
  3. Observe a runaway recursive process tree that OOM-kills the machine if left unchecked.

Current workaround on my box is a top-of-.zshrc guard:

if [[ -n "$APPIMAGE" && "$APPIMAGE" == *emdash* ]]; then
  return 0 2>/dev/null || exit 0
fi

With that guard: Emdash launches normally. Without it: fork bomb.

Actual vs Expected Behavior

  • Actual: shellEnv.ts:44 spawns $SHELL -ilc '<probe>' with env: { ...process.env, ... }. APPIMAGE, APPDIR, ARGV0, OWD, /tmp/.mount_* entries in PATH / LD_LIBRARY_PATH / XDG_DATA_DIRS, and AppImage-rooted PYTHONHOME / PYTHONPATH all pass through unchanged.
  • Expected: the probe should strip AppImage packaging vars before handing the env to the child shell, the same way ptyManager.ts:1418 and appIpc.ts already do via buildExternalToolEnv() from childProcessEnv.ts.

emdash Version

v0.4.45

Operating System

CachyOS (Linux 6.19.11-1-cachyos x86_64), zsh login shell

Additional Context

I have a standalone reproducer that demonstrates the mechanism in ~20 lines of .zshrc + a depth-counted wrapper under systemd-run --user --scope sandbox (no mise/starship/oh-my-zsh required, no actual AppImage download, fully safe to run). On my box the depth counter catches 4 levels of recursion in under 100 ms. Happy to share if helpful.

raulpineda avatar Apr 06 '26 19:04 raulpineda

from arne:

closing this for now

linear[bot] avatar May 01 '26 10:05 linear[bot]