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

listen doesnt work on LAN #3498

Closed
6 of 10 tasks
unphased opened this issue Nov 3, 2023 · 7 comments
Closed
6 of 10 tasks

listen doesnt work on LAN #3498

unphased opened this issue Nov 3, 2023 · 7 comments
Assignees
Labels

Comments

@unphased
Copy link

unphased commented Nov 3, 2023

  • I have read through the manual page (man fzf)
  • I have the latest version of fzf
  • I have searched through the existing issues

Info

  • OS
    • Linux
    • Mac OS X
    • Windows
    • Etc.
  • Shell
    • bash
    • zsh
    • fish

Problem / Steps to reproduce

I find that I can access fzf --listen server just fine with curl but only on localhost.

I have a use case where I want to do some semi automated file searching, so i use a preview hook to curl a change-query command. Well I often want the backend fzf doing the file list matching to be on a remote host.

I see much discussion around security for --listen which seems reasonable but I think from what I saw in the code, this binds to localhost right now.

I reckon the security is good enough that we can allow network hosts to connect. Maybe we can enforce the use of an auth token to do this?

@junegunn
Copy link
Owner

junegunn commented Nov 4, 2023

Maybe we can enforce the use of an auth token to do this?

Yes, we really should, if we're going to allow external connections. It's so easy to mess up your system through this: execute:rm -rf /

  1. Change --listen to take the listen address, not just the port. e.g. 0.0.0.0:0
  2. If the address specified is not localhost (or 127.0.0.1), check if FZF_API_KEY is set to a non-empty value.

@junegunn junegunn self-assigned this Nov 4, 2023
@unphased
Copy link
Author

unphased commented Nov 4, 2023

I'd also be cool with putting execute and such commands locked behind further security gates, like a somewhat long launch flag name. Thanks!!

@junegunn
Copy link
Owner

junegunn commented Nov 5, 2023

Yeah, I also thought about that. We probably have two options:

  • Add --listen-safe that doesn't allow process execution
  • Add --listen-unsafe which allows remote process execution. Disallow remote (non-localhost) process execution in ordinary --listen

@unphased
Copy link
Author

Thanks! I had to get a newer version of go than apt provides, built fzf, and --listen does require 0.0.0.0:<port> instead of just port to allow binding outside localhost, and it works!

@unphased
Copy link
Author

One thing I'd like to note is when setting queries to large values and then setting to a smaller value, the horizontal scroll in the search bar isn't reset so it looks a bit wonky. Not a big problem but it made me think there was a huge bug for a few minutes last week.

@junegunn
Copy link
Owner

You'll see the same result when you hold down the backspace key and erase the query. It can be less confusing because you see the whole process.

I thought curl -d 'change-query(short)+beginning-of-line+end-of-line would reset the scroll offset, but it turns out it doesn't because fzf updates the offset only after the whole series of actions are performed. FWIW, you can first empty the query and set it to a new value in a separate call, but it's far from ideal.

curl localhost:6266 -d'change-query:'
curl localhost:6266 -d'change-query:foo'

@junegunn
Copy link
Owner

84bb350 is a simple patch that makes the `beginning of line+end of line' trick work as expected. (Ideally, we should be able to handle any action that moves the cursor to the left.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants