Skip to content

installer: Feed LUKS passphrase to cryptsetup on stdin#185

Open
ggiesen wants to merge 1 commit into
linuxmint:masterfrom
ggiesen:fix-luks-passphrase-process-table
Open

installer: Feed LUKS passphrase to cryptsetup on stdin#185
ggiesen wants to merge 1 commit into
linuxmint:masterfrom
ggiesen:fix-luks-passphrase-process-table

Conversation

@ggiesen

@ggiesen ggiesen commented Jun 24, 2026

Copy link
Copy Markdown

During an encrypted install create_partitions() ran os.system("echo -n <pass> | cryptsetup luksFormat/luksOpen ..."). os.system runs /bin/sh -c "<string>", so the passphrase sat in the shell's argv and was readable from the process table (ps) by any local user during the encrypt window.

Fix: pass the passphrase to cryptsetup on stdin via --key-file -, using subprocess.run(..., input=passphrase.encode("utf-8")), so it is never a command argument. luksFormat and luksOpen change identically, so the derived key is unchanged (same bytes, no trailing newline, read until EOF as with the old echo -n). The now-unused shlex import is dropped; the change is confined to the existing if self.setup.luks: block.

Testing (LMDE 7, QEMU/KVM): instrumented ps across luksFormat/luksOpen during an encrypted install. The old echo | cryptsetup form shows the passphrase in the process table; the stdin form does not (11k+ samples). The install completes and the volume unlocks with the chosen passphrase.

Split out of #180 so it can land independently.

Fixes #182

create_partitions() built 'echo -n <pass> | cryptsetup ...' and ran it
through os.system(), i.e. sh -c 'echo -n <pass> | cryptsetup ...'. The
passphrase was the shlex-quoted argument of that shell, so it was
briefly visible in the process table to any local user running ps
during an encrypted install.

cryptsetup reads the key from stdin with --key-file -; pass it there
via subprocess.run(input=). The passphrase is now never a command
argument: not in ps, not in any log.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Encryption passphrase briefly visible in the process table during automated encrypted install

1 participant