-
Notifications
You must be signed in to change notification settings - Fork 154
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
Implicit copy to system clipboard doesn't obey law of least surprise and poses potential security hazard #759
Comments
Yes isolating the system clipboard to deliberate operations seems to be the only reasonable thing to do here. Regarding nushell/nushell#11907 currently the feature is not deliberately enabled? |
The feature is enabled in nushell by default with the |
Ah I was just checking on the reedline imports directly. There could be a debate on the nushell side if we should even include system clipboard access among the default features thanks to the patchy support accross the platforms. For the basic operations it is not necessary |
Thanks for the issue @Tastaturtaste. I'm excited to see what you come up with. I don't know the answer to your questions, sorry. |
Is the support really that patchy? As far as I know, there are mainly problems when running on linux without an x11 server. I would guess this is a pretty rare thing to run into, outside of pure server instances. But I am also not that knowledgable outside of windows. |
I think this is potentially pretty distribution dependent how everything is set up. Some distros still ship with a traditional X11 others migrated to Wayland more extensively (where I am no expert on the support for clipboards). nushell/nushell#11907 (comment) indicates that whatever support we get from the But that is a separate discussion for Nushell from how we should go about on the reedline side. I would say the suggestion in #380
was shortsighted and should be replaced by explicit ops as you suggested. (limiting this to the selection for cutting would be a compromise to keep the number of commands in check) We can probably discard the |
My suggestion would be to only provide access to the OS clipboard with three commands, Another possibility would be to parameterize those commands over the clipboard where both clipboard choices possibly make sense. That would also keep the number of commands in check.
I take it that this means the answer to
is No? |
Mhh when we implement visual mode for the vi-emulation we will probably want to be able to express those selection ops for the local cut buffer as well but that is Zukunftsmusik. I would be fine with first making the ones you mentioned system only. I think we should not make runtime behavior dependent on the feature flag anymore. This could be reasonably be made at runtime, and the feature flag should just control what is available. |
@Tastaturtaste I also agree with your suggestion #759 (comment) and the point @sholderbach is making about feature flags. |
I just made a PR to fix this. I implemented the three commands |
Certain operations, such as
alt + d
, cut content and put the content in the cut buffer. With thesystem_clipboard
feature enabled, the cut buffer is replaced by the system clipboard. This can lead to surprising behaviour changes for the user and pose a security hazard in case a user cuts sensitive information into the system clipboard without knowing about it.For more context see nushell/nushell#11907.
Steps to reproduce
CutWordRight
Possible Solution
I am currently looking into this and think it would be best if reedline always has a local clipboard (which it calls the cut buffer) and additionally with the
system_clipboard
feature enabled a system clipboard. Most commands would always use the local clipboard, only some explicitly named commands interact with the system clipboard. I would also like to avoid changing which clipboard gets used by a command depending on the feature flag used to compile. Commands should either use the cut buffer, which is always available, or the system clipboard.Commands that copy to the system clipboard would be
CopySelection
(default Ctrl+Shift+C) andCutSelection
(default Ctrl+Shift+X). If permitted with regard to backward compatibility of reedline, I would also like to rename them toCopySelectionToSystem
andCutSelectionToSystem
to be more explicit about what they do. Changing the way the clipboard works is a semantic breaking change either way.In addition to
PasteCutBufferBefore
(default Ctrl+Shift+V and emacs Ctrl+Y), I would introduce a new CommandPasteSystemClipboard
, which does whatPasteCutBufferBefore
currently does with the system clipboard enabled. I would then changePasteCutBufferBefore
to always paste from the local clipboard, matching its name. The default key binding forCtrl+Shift+V
would then be changed to invoke the newPasteSystemClipboard
.Open Questions
EditCommand
enum variants concerning thesystem_clipboard
feature (CutSelectionToSystem
, ...) be conditionally included only? This would statically ensure that those commands can only come in when there is actually a system clipboard available. In this case, the enum should also be markednon_exhaustiv
, otherwise this would break exhaustive matches for crates when somewhere in their dependency graph thesystem_clipboard
feature gets newly enabled in the future.The text was updated successfully, but these errors were encountered: