Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Plaintext passwords / PIN exposed via rofi cache history file #25

Open
trinitronx opened this issue Jul 1, 2024 · 10 comments
Open

Plaintext passwords / PIN exposed via rofi cache history file #25

trinitronx opened this issue Jul 1, 2024 · 10 comments
Assignees

Comments

@trinitronx
Copy link

In testing this rofi plugin, I noticed that whatever is entered into the "secure" password entry in rofi gets directly written to disk in plaintext.

This appears due to rofi's default behavior to write textbox input history to: $XDG_CACHE_HOME/rofi-entry-history.txt (default: ~/.cache/rofi-entry-history.txt).

This may be possible to avoid by using -cache-dir /dev/null, but it's unclear how to tell the wrapper script /usr/bin/pinentry-rofi to pass this when it runs rofi.

@haennes
Copy link

haennes commented Jul 1, 2024

Just stumbled upon this issue.
Seems like there is a -disable-history option as well which does nothing on my setup (nixos 24.11)
passing cache dir /dev/null to rofi also failes with: Failed to create cache directory: Not a directory
Seemslike the only solution is to point it to a temp directory which gets deleted instantly. (Don´t know about the security implication of that though)

EDIT: maybe having a symlink or hardlink from $tmpdir/rofi-entry-history.txt to /dev/null could do the trick. Will try out tomorrow.

EDIT: It works

QUICK FIX: let ~/.cache/rofi-entry-history.txt be a symlink to /dev/null

@plattfot plattfot self-assigned this Jul 2, 2024
@plattfot
Copy link
Owner

plattfot commented Jul 2, 2024

Hi,

Yeah that is not great.

If I understand rofi correctly it should not write any entry to disk when using the option -password (as seen here in the rofi source code: view.c#L1005). Which is what I'm using when popping up rofi to prompt for passwords/PIN.

I don't see any trace of $XDG_CACHE_HOME/rofi-entry-history.txt on my machines. So it is working fine on my end.

The question is then, why does it write entries to disk for you two? I might have one suspicion on what it might be. But I need more information to be able to reproduce this. Would anyone of you mind answering the following questions?

What version of rofi?

What version of guile?

What version of gnupg? Or are you using something else?

Is the password/PIN visible when typing it in?

Thanks

@haennes
Copy link

haennes commented Jul 2, 2024

Hi,

Yeah that is not great.

If I understand rofi correctly it should not write any entry to disk when using the option -password (as seen here in the rofi source code: view.c#L1005). Which is what I'm using when popping up rofi to prompt for passwords/PIN.

I don't see any trace of $XDG_CACHE_HOME/rofi-entry-history.txt on my machines. So it is working fine on my end.

What version of rofi?

1.7.5

What version of guile?

3.0.9

What version of gnupg? Or are you using something else?

according to gpg --version:

gpg (GnuPG) 2.4.5
libgcrypt 1.10.3
Copyright (C) 2024 g10 Code GmbH

Is the password/PIN visible when typing it in?

No

OS: NixOS
package branch: unstable

@plattfot
Copy link
Owner

plattfot commented Jul 2, 2024

What version of rofi?

1.7.5

Could it be that you are using the next branch?

I did some more code spelunking and the rofi entry cache history was added after the 1.7.5 release. Which also explains why I'm not seeing it on my side, as Guix is using the 1.7.5 release.

I can reproduce the behavior by using rofi from this commit.
My steps are as follows:

Build it from source:

$ guix shell --pure -D rofi meson ninja pkg-config gcc-toolchain -- meson setup build
$ guix shell --pure -D rofi meson ninja pkg-config gcc-toolchain -- meson compile -C build

Then I ran:

./build/rofi -dmenu

Typed in foo when prompted

Then I ran:

./build/rofi -dmenu -password

Typed in bar

And the resulting history file is:

$ cat $XDG_CACHE_HOME/rofi-entry-history.txt
foo
bar

I would expect it to just capture foo and not bar. As the latter is using the -password option (same that is used in pinentry-rofi when prompting for passwords/PIN). Which I assume the commit message means when it says "disable when dmenu password is set".

Running the same with rofi-1.7.5 does not produce any output on disk.

Please report this issue to the rofi maintainers given that this looks to be a bug in rofi and not pinentry-rofi.

@haennes
Copy link

haennes commented Jul 3, 2024

could you provide me with a/the commit of the upstream it still works on? i cant figure out where i have to look

@plattfot
Copy link
Owner

plattfot commented Jul 3, 2024

I'm using the 1.7.5 tag: https://github.com/davatorium/rofi/tree/1.7.5
That one is the latest release, which is ~2 years ago. Not sure why there hasn't been any new official release since then.

@haennes
Copy link

haennes commented Jul 5, 2024

opened an upstream issue. Is confirmed by the developer. davatorium/rofi#1995

I think this should be left open until it is patched in upstream and on a realease. Such that people will find it

@plattfot
Copy link
Owner

plattfot commented Jul 5, 2024

Sounds good. I'll leave this open until this is patched upstream.

@trinitronx
Copy link
Author

trinitronx commented Jul 8, 2024

Could it be that you are using the next branch?

Yes, in effect I'm using the Wayland forked version of rofi that was based on the next branch of the original repo, davatorium/rofi.

This is the lbonn/rofi fork that supports Wayland natively, and it's installed by default in Manjaro Sway, as manjaro-sway/rofi-wayland version 1.7.5-2.

@plattfot
Copy link
Owner

plattfot commented Jul 8, 2024

Yes, in effect I'm using the Wayland forked version of rofi that was based on the next branch of the original repo, davatorium/rofi.

This is the lbonn/rofi fork that supports Wayland natively

Ok, it seems that they track the upstream rofi repository. Once the fix lands in davatorium/rofi then lbonn/rofi should eventually get it.

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

No branches or pull requests

3 participants