[bug]: AppImage launch fork-bombs on Linux
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
- Install the
emdash-x86_64.AppImagerelease on a Linux box whose login shell is zsh and whose.zshrcsources mise / starship / oh-my-zsh (in my case: CachyOS / Arch). - Launch the AppImage.
- 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:44spawns$SHELL -ilc '<probe>'withenv: { ...process.env, ... }.APPIMAGE,APPDIR,ARGV0,OWD,/tmp/.mount_*entries inPATH/LD_LIBRARY_PATH/XDG_DATA_DIRS, and AppImage-rootedPYTHONHOME/PYTHONPATHall pass through unchanged. - Expected: the probe should strip AppImage packaging vars before handing the env to the child shell, the same way
ptyManager.ts:1418andappIpc.tsalready do viabuildExternalToolEnv()fromchildProcessEnv.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.
from arne:
closing this for now