SYSTEM WARNING: 'file_get_contents(https://www.clearos.com/?rendertype=json&get=header): failed to open stream: Connection refused' in '/var/www/virtual/newwrapper/cf_topmenu.inc' line 5

ClearOS Bug Tracker


View Issue Details Jump to Notes ] Issue History ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0000715ClearOSapp-firewall - Firewallpublic2012-08-19 13:362015-05-25 15:02
Reportertracker 
Assigned Touser2 
PrioritynormalSeveritymajorReproducibilityalways
StatusclosedResolutionsuspended 
PlatformOSOS Version
Product Version 
Target VersionFixed in Version 
Summary0000715: ClearOS port forwarding creates security risk on internal LAN
DescriptionA ClearOS firewall "port forward" rule (not a "custom" rule, an external -> internal forward) basically translates into 3 types of iptables rules:

- A DNAT rule to map the external ip/port to the internal ip/port.
- Forwarding rules to get the packet forwarded to the internal interface.
- Spurious SNAT rules which have no effect on packets arriving on an external interface.

Unfortunately, these SNAT rules hide the source address of packets routed between internal interfaces. This can create a security risk, or other confusion if the device which is being forwarded to is accessed internally.
Steps To ReproduceNeed a gateway setup with >1 internal interface, lets say LAN and Hot LAN.
Also a device D on the Hot LAN that does http basic auth.
Also a couple of LAN clients L1 and L2.
Create a port forwarding rule from the external interface to the device D on the Hot LAN.
Connect to D from LAN client L1 (using D's internal address, not the external one), and authenticate.
Now connect to D from L2... no authentication required. Boo Hiss. D sees any access from the LAN as being from the address of the firewall itself.
Additional InformationHere's a worked example:

LAN eth0 10.51.8.1 / 24
Hot eth2 10.51.13.1 / 24
ext ip 1.2.3.4

Now create a port forwarding rule to a device on the hot LAN:

port 48101 -> 10.51.13.167:80

Here are the iptables rules created by ClearOS

$ sudo iptables -t nat -L -v
Chain PREROUTING (policy ACCEPT 5846K packets, 1786M bytes)
pkts bytes target prot opt in out source destination
0 0 DNAT tcp – any any anywhere 1.2.3.4 tcp dpt:48101 to:10.51.13.167:80

Chain POSTROUTING (policy ACCEPT 7292K packets, 448M bytes)
pkts bytes target prot opt in out source destination
0 0 SNAT tcp – any any 10.51.8.0/24 10.51.13.167 tcp dpt:http to:10.51.8.1
0 0 SNAT tcp – any any 10.51.13.0/24 10.51.13.167 tcp dpt:http to:10.51.13.1

$ sudo iptables -L -v
Chain FORWARD (policy DROP 18 packets, 1080 bytes)
pkts bytes target prot opt in out source destination
0 0 ACCEPT tcp – any eth0 anywhere 10.51.13.167 tcp dpt:http
0 0 ACCEPT tcp – any eth2 anywhere 10.51.13.167 tcp dpt:http

So, those SNAT rules do nothing useful as far as I can see. Certainly they never apply to packets arriving on the external interface. But they do hide the source address of any packet destined for 10.51.13.167 and routed from the LAN to the Hot LAN... to the device on the Hot LAN, any access from the LAN looks like it's coming frrom the firewall itself.

Looking at the code in firewall.lua, it's simple to fix, just delete the SNAT rule generation. The FORWARD rules could be cleaned up too, there's no need to generate one for each LAN interface, just create one rule for the destination ip/port without specifying interface.

Maybe this crept in because "forwarding rule" and "custom forwarding rule" got confused one fine day back in the Jurassic era?

Note that the spurious SNAT rules will have no effect at all if there's only one internal interface.
TagsNo tags attached.
Attached Files

- Relationships

-  Notes
(0001080)
user2
2013-11-01 10:19

The SNAT rules makes it possible for systems on the LAN/HotLAN to use the external IP. Without those rules L1 could not use the public IP to connect to D. That's painful if a user is hosting a web site www.example.com/1.2.3.4 on the HotLAN -- LAN users would not be able to access www.example.com without some DNS hacks.

- Issue History
Date Modified Username Field Change
2012-08-19 13:36 devferret New Issue
2012-08-20 02:46 user2 Status new => acknowledged
2013-11-01 10:19 user2 Note Added: 0001080
2013-11-01 10:19 user2 Status acknowledged => feedback
2015-05-25 15:02 user2 Reporter devferret => tracker
2015-05-25 15:02 user2 Status feedback => closed
2015-05-25 15:02 user2 Assigned To => user2
2015-05-25 15:02 user2 Resolution open => suspended

SYSTEM WARNING: 'file_get_contents(https://www.clearos.com/?rendertype=json&get=footer): failed to open stream: Connection refused' in '/var/www/virtual/newwrapper/cf_footer.inc' line 7