Tudmotu / gnome-shell-extension-clipboard-indicator

The most popular clipboard manager for GNOME, with over 1M downloads
https://extensions.gnome.org/extension/779/clipboard-indicator/
MIT License
818 stars 166 forks source link

Doesn't work due to clipboard entry parsing #447

Closed sidt4 closed 2 months ago

sidt4 commented 3 months ago

Appears the extension is trying to do something with the clipboard entry. I moved dir /usr/share/devhelp/books/ and created a empty file /usr/share/devhelp/books, the extension loaded fine.

After clearing all clipboard entries, it loaded fine and all was ok.

I think clipboard clearing should work irrespective of other features.

journalctl log:

Mar 30 18:12:30 linux gnome-shell[24359]: JS ERROR: Gio.IOErrorEnum: Error opening file /usr/share/devhelp/books: Is a directory
                                          fromJSON/bytes</<@file:///home/sid/.local/share/gnome-shell/extensions/clipboard-indicator@tudmotu.com/registry.js:232:47
                                          @resource:///org/gnome/shell/ui/init.js:21:20
Tudmotu commented 3 months ago

Not sure why would the extension try to open a random file? Did you edit the registry.txt file?

sidt4 commented 3 months ago

Did you edit the registry.txt file?

Don't know what that is.

Extension wasn't working as expected (refer https://github.com/Tudmotu/gnome-shell-extension-clipboard-indicator/issues/439#issuecomment-2028359573) for more than a week. I thought it was due to recent GNOME Shell 46 upgrade stuff. As the issue wasn't going away, I decided to look into journalctl logs to fix the issue, as I wanted to get the extension working.

Tudmotu commented 3 months ago

Hmm interesting. If that every happens to you again, I would appreciate if you could make a copy of ~/.cache/clipboard-indicator@tudmotu.com/registry.txt and send it to me privately (remember to remove any sensitive information from it before sending it to me).

Do I understand correctly that the extension is currently working for you?

Edu4rdSHL commented 3 months ago

I'm having the same issue, every time I copy a system's directory path, the app tries to open it for some reason, and fails with the message stated in the issue. The fix, is to mv the path so that it doesn't exist anymore and re-enable the extension, then delete the entry containing the path and move the path back again in the file system.

I can reproduce it at any time I want, so let me post the registry.txt file.

$ cat ~/.cache/clipboard-indicator@tudmotu.com/registry.txt
[{"favorite":false,"mimetype":"UTF8_STRING","contents":"/home/edu4rdshl/.local/share/applications"},{"favorite":false,"mimetype":"text/plain;charset=utf-8","contents":".local/share/applications/"},{"favorite":false,"mimetype":"text/plain;charset=utf-8","contents":"/var/lib/pacman/local"}]

After checking, the issue is when the mimetype is set to UTF8_STRING, I can reproduce it for each line if I change the mimetype to that one. And, changing it to text/plain;charset=utf-8 makes the issue disappear.

Tudmotu commented 3 months ago

Thanks! This sounds like a bug. Will try to reproduce.

Tudmotu commented 3 months ago

@Edu4rdSHL from what app are you copying the path?

Edu4rdSHL commented 3 months ago

@Tudmotu from Gnome Terminal.

Edu4rdSHL commented 3 months ago

Out of curiosity, why is even the app trying to execute something? That looks terrible to me. So, if I copy rm -rf $HOME and it gets set to UTF8_STRING, it will possibly run that?

Edit: I confirm this behavior. We have a RCE vulnerability right here. I will open a new issue to track it.

Tudmotu commented 2 months ago

@Edu4rdSHL I honestly have no idea. I don't understand how that could happen.

sidt4 commented 2 months ago

Ran into this issue again.

Steps to reproduce:

  1. Clear all entries
  2. Copy /tmp/ to clipboard.
  3. Disable and enable extension
  4. Below error should happen.
Apr 07 18:11:29 linux gnome-shell[140892]: JS ERROR: Gio.IOErrorEnum: Error opening file /tmp: Is a directory
                                           fromJSON/bytes</<@file:///home/sid/.local/share/gnome-shell/extensions/clipboard-indicator@tudmotu.com/registry.js:232:47
                                           @resource:///org/gnome/shell/ui/init.js:21:20