diff --git a/etc/inc/auth.inc b/etc/inc/auth.inc index 0af0594452..d0b261a430 100644 --- a/etc/inc/auth.inc +++ b/etc/inc/auth.inc @@ -49,6 +49,57 @@ require_once("config.gui.inc"); +/* If this function doesn't exist, we're being called from Captive Portal or + another internal subsystem which does not include authgui.inc */ +if (function_exists("display_error_form") && !isset($config['system']['webgui']['nodnsrebindcheck'])) { + /* DNS ReBinding attack prevention. http://redmine.pfsense.org/issues/708 */ + $found_host = false; + if(strstr($_SERVER['HTTP_HOST'], ":")) { + $http_host_port = explode(":", $_SERVER['HTTP_HOST']); + $http_host = $http_host_port[0]; + } else { + $http_host = $_SERVER['HTTP_HOST']; + } + if(($http_host == "localhost" or $_SERVER['SERVER_ADDR'] == "localhost") or + ($http_host == "127.0.0.1" or $_SERVER['SERVER_ADDR'] == "127.0.0.1")) + $found_host = true; + if($config['dyndnses']['dyndns']) + foreach($config['dyndnses']['dyndns'] as $dyndns) + if($dyndns['host'] == $http_host or $dyndns['host'] == $_SERVER['SERVER_ADDR']) + $found_host = true; + + if(!empty($config['system']['webgui']['althostnames'])) { + $althosts = explode(" ", $config['system']['webgui']['althostnames']); + foreach ($althosts as $ah) + if($ah == $http_host or $ah == $_SERVER['SERVER_ADDR']) + $found_host = true; + } + + if($http_host == $config['system']['hostname'] . "." . $config['system']['domain'] or + $http_host == $_SERVER['SERVER_ADDR'] or + $http_host == $config['system']['hostname']) + $found_host = true; + + /* Check against locally configured IP addresses, which will catch when someone + port forwards WebGUI access from WAN to an internal IP on the router. */ + if ($found_host == false) { + global $FilterIflist; + if (empty($FilterIflist)) { + require_once('filter.inc'); + require_once('shaper.inc'); + filter_generate_optcfg_array(); + } + foreach ($FilterIflist as $iflist) + if($iflist['ip'] == $http_host) + $found_host = true; + } + + if($found_host == false) { + display_error_form("501", "Potential DNS Rebind attack detected, see http://en.wikipedia.org/wiki/DNS_rebinding"); + exit; + } +} + $groupindex = index_groups(); $userindex = index_users(); @@ -278,7 +329,7 @@ function local_user_set(& $user) { /* determine add or mod */ if (!strncmp($pwread, "pw:", 3)) { - $user_op = "useradd -m -k /usr/share/skel -o"; + $user_op = "useradd -m -k /etc/skel -o"; } else { $user_op = "usermod"; } @@ -1181,4 +1232,4 @@ function session_auth() { return true; } -?> +?> \ No newline at end of file diff --git a/etc/inc/filter.inc b/etc/inc/filter.inc index fe7c047905..adcb8d5fce 100644 --- a/etc/inc/filter.inc +++ b/etc/inc/filter.inc @@ -1085,7 +1085,8 @@ function filter_nat_rules_generate() { if($natif) { /* If reflection is enabled, turn on extra redirections * for this rule by adding other interfaces to binat rule. */ - if(isset($config['system']['enablebinatreflection'])) { + if((isset($config['system']['enablebinatreflection']) || $natent['natreflection'] == "enable") + && $natent['natreflection'] != "disable") { $nat_if_list = filter_get_reflection_interfaces($natif); } else { $nat_if_list = array(); @@ -1281,10 +1282,8 @@ function filter_nat_rules_generate() { fwrite($inetd_fd, "tftp-proxy\tdgram\tudp\twait\t\troot\t/usr/libexec/tftp-proxy\ttftp-proxy -v\n"); if(isset($config['nat']['rule'])) { - if(!isset($config['system']['disablenatreflection'])) { - /* start redirects on port 19000 of localhost */ - $starting_localhost_port = 19000; - } + /* start reflection redirects on port 19000 of localhost */ + $starting_localhost_port = 19000; $natrules .= "# NAT Inbound Redirects\n"; foreach ($config['nat']['rule'] as $rule) { update_filter_reload_status("Creating NAT rule {$rule['descr']}"); @@ -1360,7 +1359,8 @@ function filter_nat_rules_generate() { } else $nordr = ""; - if(!isset($config['system']['disablenatreflection'])) { + if((!isset($config['system']['disablenatreflection']) || $rule['natreflection'] == "enable") + && $rule['natreflection'] != "disable") { $nat_if_list = filter_get_reflection_interfaces($natif); } else { $nat_if_list = array(); @@ -2126,13 +2126,18 @@ EOD; } } - $ipfrules .= "# NAT Reflection rules\n"; - if(isset($config['nat']['rule']) && - (!isset($config['system']['disablenatreflection']))) { - $ipfrules .= << "") + if(is_ipaddr($_POST["address{$x}"]) && $_POST["address_subnet{$x}"] <> "") $tmpaddress .= "/" . $_POST["address_subnet{$x}"]; $address[] = $tmpaddress; } diff --git a/usr/local/www/firewall_nat_1to1_edit.php b/usr/local/www/firewall_nat_1to1_edit.php index d7ed094d4a..4966e141e2 100755 --- a/usr/local/www/firewall_nat_1to1_edit.php +++ b/usr/local/www/firewall_nat_1to1_edit.php @@ -77,6 +77,7 @@ if (isset($id) && $a_1to1[$id]) { else $pconfig['subnet'] = $a_1to1[$id]['subnet']; $pconfig['descr'] = $a_1to1[$id]['descr']; + $pconfig['natreflection'] = $a_1to1[$id]['natreflection']; } else { $pconfig['subnet'] = 32; $pconfig['interface'] = "wan"; @@ -123,6 +124,11 @@ if ($_POST) { $natent['descr'] = $_POST['descr']; $natent['interface'] = $_POST['interface']; + if ($_POST['natreflection'] == "enable" || $_POST['natreflection'] == "disable") + $natent['natreflection'] = $_POST['natreflection']; + else + unset($natent['natreflection']); + if (isset($id) && $a_1to1[$id]) $a_1to1[$id] = $natent; else @@ -156,7 +162,32 @@ include("head.inc"); + + + + + +   diff --git a/usr/local/www/firewall_nat_edit.php b/usr/local/www/firewall_nat_edit.php index 719e32f454..3f06928251 100755 --- a/usr/local/www/firewall_nat_edit.php +++ b/usr/local/www/firewall_nat_edit.php @@ -84,6 +84,7 @@ if (isset($id) && $a_nat[$id]) { $pconfig['interface'] = $a_nat[$id]['interface']; $pconfig['associated-rule-id'] = $a_nat[$id]['associated-rule-id']; $pconfig['nosync'] = isset($a_nat[$id]['nosync']); + $pconfig['natreflection'] = $a_nat[$id]['natreflection']; if (!$pconfig['interface']) $pconfig['interface'] = "wan"; @@ -315,6 +316,11 @@ if ($_POST) { else unset($natent['nosync']); + if ($_POST['natreflection'] == "enable" || $_POST['natreflection'] == "disable") + $natent['natreflection'] = $_POST['natreflection']; + else + unset($natent['natreflection']); + // If we used to have an associated filter rule, but no-longer should have one if (!empty($a_nat[$id]) && ( empty($natent['associated-rule-id']) || $natent['associated-rule-id'] != $a_nat[$id]['associated-rule-id'] ) ) { // Delete the previous rule @@ -456,6 +462,10 @@ include("fbegin.inc"); ?> if(have_ruleint_access($if)) $interfaces[$if] = $ifdesc; + if ($config['l2tp']['mode'] == "server") + if(have_ruleint_access("l2tp")) + $interfaces['l2tp'] = "L2TP VPN"; + if ($config['pptpd']['mode'] == "server") if(have_ruleint_access("pptp")) $interfaces['pptp'] = "PPTP VPN"; @@ -469,6 +479,10 @@ include("fbegin.inc"); ?> if(have_ruleint_access("enc0")) $interfaces["enc0"] = "IPsec"; + /* add openvpn/tun interfaces */ + if ($config['openvpn']["openvpn-server"] || $config['openvpn']["openvpn-client"]) + $interfaces["openvpn"] = "OpenVPN"; + foreach ($interfaces as $iface => $ifacename): ?>