Re:Show HN: Easy-to-configure Web Server in Go
by oakaz on Saturday July 27, 2013 @03:16PM
(#6114052)
just implemented -secure option for this purpose; https://github.com/azer/boxcars/blob/master/secure.go
usage example; http://github.com/azer/boxcars#security
thanks for the helpful comment!
Re:Show HN: Easy-to-configure Web Server in Go
by sarnowski on Saturday July 27, 2013 @05:16PM
(#6114465)
Please see my comment to your parent. Additional hint: you should also care about dropping/controlling your user's groups, see https://github.com/sarnowski/mitigation/blob/master/mitigati...
Re:Show HN: Easy-to-configure Web Server in Go
by oakaz on Saturday July 27, 2013 @06:30PM
(#6114736)
yeah I saw it, thanks so much. I like this kind of single-purpose small libraries. The only thing is, I hesitate to depend on other people's repositories since they may get moved or change the API.
Re:Show HN: Easy-to-configure Web Server in Go
by sarnowski on Saturday July 27, 2013 @05:06PM
(#6114431)
WARNING: I implemented a tiny library for that in go a while ago. Go under Linux is not safe! Linux is not posix compliant and only sets the IDs for the current thread. Go almost always spawned more threads before initializing your code which are then still owned by root and are in the threadpool for your goroutines:
https://github.com/sarnowski/mitigation/blob/master/mitigati...
Comments mentions safe OS and golang bugticket.
Re:Show HN: Easy-to-configure Web Server in Go
by laumars on Saturday July 27, 2013 @11:48PM
(#6115508)
I'm guessing it might depend on the point in your Go code whrn you setuid as the tests that I did on my own project, setuid changed the user id as expacted then the processes were spawned.
However you have given me reason to test my own code again and more thoroughly :-)
Re:Show HN: Easy-to-configure Web Server in Go
by 1331 on Saturday July 27, 2013 @09:08AM
(#6112744)
A program run as a non-privileged user can access privileged ports using authbind:
Re:Show HN: Easy-to-configure Web Server in Go
by laumars on Saturday July 27, 2013 @09:18AM
(#6112770)
Indeed, but it would make more sense (in my opinion) to have the web server natively 'de-elevate' it's permissions than to expect the sysadmin to be competent enough to set up authbind manually. Particularly when setuid/setgid is so easy in Go and that every other webserver out there natively drops down to a designated webuser after the daemons been launched and ports binded.
Seems to be GNU/Linux only.
Re:Show HN: Easy-to-configure Web Server in Go
by coolsunglasses on Sunday July 28, 2013 @02:09AM
(#6115795)
Come in, the water's warm.
Re:Show HN: Easy-to-configure Web Server in Go
by peterbotond on Saturday July 27, 2013 @11:17AM
(#6113173)
authbind seems to defeat the purpose of privileged and non-privileged users to bind.
Re:Show HN: Easy-to-configure Web Server in Go
by tptacek on Saturday July 27, 2013 @01:19PM
(#6113630)
There's really not much of a purpose to that anymore, anyways. It was a bigger deal when servers were multi-user and when services were diverse.
Re:Show HN: Easy-to-configure Web Server in Go
by chrissnell on Saturday July 27, 2013 @10:34PM
(#6115363)
It's easy enough to run this as a non-root user and use your local software firewall port to forward port 80 inbound to whatever high port this server is listening on.
Re:Show HN: Easy-to-configure Web Server in Go
by laumars on Saturday July 27, 2013 @11:50PM
(#6115514)
Indeed, but that doesn't change the fact that it makes more sense having that functionality in the web server itself given its a standard and expected function in all web servers.
Re:Show HN: Easy-to-configure Web Server in Go
by oakaz on Saturday July 27, 2013 @09:19AM
(#6112774)
thanks! would you mind sending a pull request to https://github.com/azer/boxcars/blob/master/boxcars/boxcars.... ?
Re:Show HN: Easy-to-configure Web Server in Go
by laumars on Saturday July 27, 2013 @09:46AM
(#6112851)
I'm not on Github, sorry. But that code should be pretty easy to port to your app :)
Re:Show HN: Easy-to-configure Web Server in Go
by ghotli on Saturday July 27, 2013 @01:57PM
(#6113760)
Just curious why you aren't on github. Surely there's a reason worth sharing?
Re:Show HN: Easy-to-configure Web Server in Go
by laumars on Saturday July 27, 2013 @03:34PM
(#6114103)
I tend not to sign up to many cloud based solutions as I prefer to host my own solutions (partly out of paranoia and partly because I have the server capacity to run my own solutions so it seems to make sense to use my servers where I can).
With github, it's very rare when I have anything worth contributing to other peoples gits so I've never really missed it. But I'm sure I'll end up on there at some point in the future.
In the case of the former, that's a huge step backwards in terms of security.
In the case of the latter, that would mean you'd need another reverse proxy hooked up - which would negate the need for this web server to begin with.
This can easily be fixed within Go though:
You can also add chroot to your code if you want to be ultra paranoid: This will need to be done before you change your user ID (as you need root permissions to chroot) and you may need to compile the Go without CGO because some of the standard Go libraries will have SO dependencies (I found this to be the case with domain name lookups).(the above code is adapted from my own Go web framework that I'm in the processes of building)