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

Support port forwarding for privileged ports (1-1023) #45

Closed
AkihiroSuda opened this issue Jun 11, 2021 · 6 comments · Fixed by #283
Closed

Support port forwarding for privileged ports (1-1023) #45

AkihiroSuda opened this issue Jun 11, 2021 · 6 comments · Fixed by #283
Labels
enhancement New feature or request priority/high
Milestone

Comments

@AkihiroSuda
Copy link
Member

https://twitter.com/_AkihiroSuda_/status/1403403845842075648

I'm planning to support privileged ports using authbind (https://github.com/Castaglia/MacOSX-authbind) if it works.

@AkihiroSuda
Copy link
Member Author

AkihiroSuda commented Jun 11, 2021

Another way is to replace ssh -L with a home-made port forwarder, and set SETUID bit on its binary.
(We could just set SETUID on ssh binary, but perhaps it may cause some unexpected side effect)

Most parts of the port forwarder could be executed without the SETUID bit. It will receive sockfd from a SETUID helper via SCM_RIGHTS cmsg.
https://github.com/apple/darwin-xnu/blob/xnu-7195.101.1/tests/fd_send.c

@AkihiroSuda AkihiroSuda added enhancement New feature or request help wanted Extra attention is needed labels Jun 11, 2021
@AkihiroSuda
Copy link
Member Author

Or maybe we don't need any SETUID stuff. Just bind 0.0.0.0:80, and reject connections from non-loopback addresses.

@AkihiroSuda AkihiroSuda removed the help wanted Extra attention is needed label Jun 23, 2021
@jandubois
Copy link
Member

reject connections from non-loopback addresses

Maybe make the rejection configurable? I think it can be useful to expose an app running in lima to the local network, so you can test it e.g. as a service from another machine.

@AkihiroSuda
Copy link
Member Author

Yes, we will eventually need config file and (REST?) API to control flexible forwarding

@markomitranic
Copy link

Until
this gets done, I hope this old little snippet helps someone :)

alias port80="sudo ifconfig lo0 127.0.0.1 alias
echo \"rdr pass on lo0 inet proto tcp from any to 127.0.0.1 port 80 -> 127.0.0.1 port 8080\" | sudo pfctl -ef -"

To revert the mappings back to their original state, just empty the file.

sudo pfctl -f /etc/pf.conf

Same for 443

@AkihiroSuda
Copy link
Member Author

PR: #283

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request priority/high
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants