News for hackers. Stuff that matters.
Re:How to steal a developer's local database by an_ko on Thursday September 01, 2016 @02:30PM (#12407717)
> Don't let your services listen on (AKA bind to) 0.0.0.0 or 127.0.0.1.

How do I do that? Iptables? (Sorry if this is a dumb question.)

Re:How to steal a developer's local database by andrewstuart2 on Thursday September 01, 2016 @02:38PM (#12407775)
It's part of configuring whatever services you're running (or an option in your tcp/ip library if you're programming your own), and will depend on the service. For memcached for example, you can change the listen address with `-l <addr>`. Usually you just have to find the configuration documentation and ctrl-f search for "address," "bind address," "listen address," "IP address," etc. Or scan the page for something networking related.

It's pretty much always a command line flag or config file parameter.

If you're running with docker, it's even more standard. When you expose a port, just use `-p 127.12.12.3:11211:11211` (with your chosen IP address, of course), and docker will set up the forwarding for you, only for that address.

Re:How to steal a developer's local database by d0mine on Thursday September 01, 2016 @03:54PM (#12408342)
To choose an ip address from 127.0.0.0/8 subnet randomly in Python 3:

  >>> import ipaddress
  >>> import random
  >>> ipaddress.IPv4Address('127.0.0.1') + random.randrange(2**24 - 2)
  IPv4Address('127.23.181.175')
Re:How to steal a developer's local database by wcarron27 on Wednesday September 14, 2016 @02:55PM (#12500133)
Hey, I know I'm a bit late to the party. But I'm looking to protect my company's redis instance from these attacks and your approach looks very promising. Things is, I don't know what to do now that I've written a similar script. Where should I use this code? In the redis.conf file?

Bear in mind, I'm a front end developer, so this is absolutely not my forte. Thanks for the help.

Re:How to steal a developer's local database by _RPM on Thursday September 01, 2016 @05:30PM (#12409053)
Nice use of __add__ operator over loading here
Re:How to steal a developer's local database by fizzbatter on Thursday September 01, 2016 @05:05PM (#12408872)
I really appreciate this code example. I've been using 127.0.0.1 for all my local dev stuff, relying on ports. This is pretty awesome!
Re:How to steal a developer's local database by JonnieCache on Thursday September 01, 2016 @02:57PM (#12407935)
Is there a way to make root a requirement for binding to 0.0.0.0 though?
Re:How to steal a developer's local database by TimPrice on Thursday September 01, 2016 @03:56PM (#12408358)
Selinux (semanage port) and iptables (SECMARK?) might help you there.
Re:How to steal a developer's local database by thewhitetulip on Thursday September 01, 2016 @02:36PM (#12407765)
no, it depends which language you use, but each allows you to 'listen' on an ip address and a port.

The point is that the most commonly used IP is 127.0.0.1 but we can as well use 127.120.99.12 because the entire subnet is the loopback address.

https://github.com/thewhitetulip/web-dev-golang-anti-textboo... For an example in Go.

Re:How to steal a developer's local database by baby on Thursday September 01, 2016 @02:35PM (#12407748)
he means make them listen for 3.3.99.8 for example
Re:How to steal a developer's local database by thewhitetulip on Thursday September 01, 2016 @02:37PM (#12407772)
3.0.0.0/8 isn't loopback. Or did I miss something?

I thought he said use 127.3.99.7 or something of that sort to avoid using the default localhost

Re:How to steal a developer's local database by andrewstuart2 on Thursday September 01, 2016 @02:43PM (#12407817)
Right, and furthermore an address in 3.0.0.0/8 isn't likely to be added on any of your interfaces, so attempting to bind/listen on that will just fail. Even if you add it yourself, there's a tiny chance you might start redirecting some traffic you care about (say, facebook) to a local interface where facebook services are definitely not running. :-P

Fortunately, the whole 127.0.0.0/8 block is automatically added to the loopback interface (edit: on Linux at least), so you can bind away to your heart's content.

Re:How to steal a developer's local database by thewhitetulip on Friday September 02, 2016 @02:15AM (#12411205)
then how can you run the webapp if you aren't binding it to localhost?

How will your PC know how to resolve 3.0.0.0/8?