reddit / emacs

Emacs as a login manager

declantsien · 2022-10-19 09:21
Hey, I put together a Emacs dynamic module for [greetd-ipc](https://crates.io/crates/greetd_ipc). With this we can use Emacs as a greeter for greetd. Here is the repo [https://git.sr.ht/\~declantsien/egreet](https://git.sr.ht/~declantsien/egreet) and a demo [https://i.imgur.com/m3ppyg8.mp4](https://i.imgur.com/m3ppyg8.mp4) The rust code are mainly borrowed from [agreety](https://git.sr.ht/~kennylevinsen/greetd/tree/master/item/agreety/src/main.rs). And I am using the [Emacs Module in Rust](https://crates.io/crates/emacs) crate here. For those who are not familar with greetd. [greetd](https://git.sr.ht/~kennylevinsen/greetd) is a minimal, agnostic and flexible [login manager](https://wiki.archlinux.org/title/Login_manager) daemon.
donio · 2022-10-19 17:00
I might be misunderstanding what this does but wouldn't it be a problem if the user is able to take control of the Emacs session before authentication is complete?
my_bad_name · 2022-10-19 18:09
they were so concentrating on if they *could* do it that they forgot to think if they*should*. But really: a technically very interesting hack!
gerenski9 · 2022-10-19 18:24
The real question is, can you use Emacs both as a login manager through your module, and EXWM at the same time?
Pay08 · 2022-10-19 19:20
It'd seems so, if the video is anything to go by.
mickeyp · 2022-10-19 19:45
Love it. Let's change it to `M-x doctor`. You can only log in successfully if you succeed in getting the last word against the good doctor.
declantsien · 2022-10-19 23:51
Yeah, users can take control of the Emacs session using C-g. And try logging later again with `(egreet-login)`. But Greetd greeters(Emacs in this case) is run with a Linux account called `greeter`, not the accounts associated with your data. Is this supposed to be a problem?
declantsien · 2022-10-19 23:52
Emacs from login manager is killed after a successful authorization, and EXWM is started afterwards. So I don't see a problem here.
donio · 2022-10-20 02:35
Well, it's an arbitrary code execution vulnerability. An attacker with access to the console could use it as a jumping point to exploit other vulnerabilities to gain access to other accounts. Or steal your password by running a modified `egreet-login` function in this hijacked Emacs login session that snoops your password before sending it to `greetd`. Or just have direct access to sensitive files that are not protected by file-system permissions.
declantsien · 2022-10-20 07:09
Thanks for pointing out these potential security issues. * An attacker with access to the console could use it as a jumping point to exploit other vulnerabilities to gain access to other accounts. * Or just have direct access to sensitive files that are not protected by file-system permissions. I guess these two apply to any device if an attacker gets his hands on it. By using a live USB sticker? Macbook also has a terminal in recovery mode. ​ * Or steal your password by running a modified egreet-login function in this hijacked Emacs login session that snoops your password before sending it to greetd. Code like this seems able to hijack `C-g`, and block minibuffer (defun egreet-login (&optional user) (unwind-protect (let ((result (egreet-login1 (or user (read-from-minibuffer "User: "))))) (if result (progn (message "Logined") (sit-for 1) (kill-emacs)) (progn (message "Login incorrect") (sit-for 1)))) (egreet-login))) (egreet-login)
yo_99 · 2022-10-22 12:33
Long live Emacs/Linux