Bug 19048

Summary: localhost can be accessed via the network
Product: Base System Reporter: sec
Component: kernAssignee: freebsd-bugs (Nobody) <bugs>
Status: Closed FIXED    
Severity: Affects Only Me    
Priority: Normal    
Version: 3.4-STABLE   
Hardware: Any   
OS: Any   

Description sec 2000-06-06 01:40:01 UTC
I'm not sure wether this is a real bug. This is more of a question if this
should be changed.

You can access listening demons bound to localhost from another machine
on the same ip subnet. Some people do not expect this. :)

Fix: 

filter 127/8 somewhere in the kernel?

if this is not deemed right, you can of course use ipfilter / ipfw to block
these packets.
How-To-Repeat: 
I'm on my host 'yoda'

| yoda:~#telnet 127.0.0.1
| Trying 127.0.0.1...
| Connected to localhost.
| Escape character is '^]'.
| 
| FreeBSD/i386 (yoda) (ttypa)
| 
| login:
| telnet> q
| Connection closed.

I modify the routes a bit...

| yoda:~#route delete -host 127.0.0.1
| delete host 127.0.0.1

| yoda:~#route add -host 127.0.0.1 -gateway kenobi
| add host 127.0.0.1

Now localhost is somewhere else :)

| yoda:~#telnet 127.0.0.1
| Trying 127.0.0.1...
| Connected to localhost.
| Escape character is '^]'.
| 
| FreeBSD/i386 (kenobi) (ttype)
| 
| login:
| telnet> q
| Connection closed.

I even tried it with program listening only on localhost:8888 on kenobi

| yoda:~#telnet 127.0.0.1 8888
| Trying 127.0.0.1...
| Connected to localhost.
| Escape character is '^]'.
| Hallo, hier ist kenobi-localhost
| Connection closed by foreign host.

Of course this usually doesn't matter because if you have bad guys on your
ethernet, you usually have worse problems already :)

But quite some people expect programs listening on localhost to be only
accessible from localhost.
Comment 1 Will Andrews 2000-06-06 02:32:47 UTC
On Tue, Jun 06, 2000 at 02:35:42AM +0200, Stefan `Sec` Zehl wrote:
> filter 127/8 somewhere in the kernel?
> 
> if this is not deemed right, you can of course use ipfilter / ipfw to block
> these packets.

It's default in rc.firewall:

00200      0         0 deny ip from any to 127.0.0.0/8

-- 
Will Andrews <andrews@technologist.com>
GCS/E/S @d- s+:+>+:- a--->+++ C++ UB++++ P+ L- E--- W+++ !N !o ?K w---
?O M+ V-- PS+ PE++ Y+ PGP+>+++ t++ 5 X++ R+ tv+ b++>++++ DI+++ D+ 
G++>+++ e->++++ h! r-->+++ y?
Comment 2 ru freebsd_committer freebsd_triage 2000-06-06 08:06:37 UTC
State Changed
From-To: open->closed

Default ipfw(8) configuration blocks this.