From 5ead2472deae4303324048fef6252e9066df6eac Mon Sep 17 00:00:00 2001 From: Scott Ullrich Date: Thu, 1 Jul 2010 15:15:01 -0400 Subject: [PATCH 01/32] Do not allow dns rebinding --- etc/inc/services.inc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/etc/inc/services.inc b/etc/inc/services.inc index 4f2f167cee..fb28c32e9e 100644 --- a/etc/inc/services.inc +++ b/etc/inc/services.inc @@ -617,7 +617,7 @@ function services_dnsmasq_configure() { //} /* run dnsmasq */ - mwexec("/usr/local/sbin/dnsmasq --local-ttl 1 --all-servers --dns-forward-max=5000 --cache-size=10000 {$args}"); + mwexec("/usr/local/sbin/dnsmasq --stop-dns-rebind --local-ttl 1 --all-servers --dns-forward-max=5000 --cache-size=10000 {$args}"); if ($g['booting']) echo "done.\n"; From 88809d25da51ccd474f503681a5848a1a489d37c Mon Sep 17 00:00:00 2001 From: Scott Ullrich Date: Thu, 1 Jul 2010 16:48:13 -0400 Subject: [PATCH 02/32] Adding --rebind-localhost-ok Suggested-by: BillM --- etc/inc/services.inc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/etc/inc/services.inc b/etc/inc/services.inc index fb28c32e9e..b8fc92b774 100644 --- a/etc/inc/services.inc +++ b/etc/inc/services.inc @@ -617,7 +617,7 @@ function services_dnsmasq_configure() { //} /* run dnsmasq */ - mwexec("/usr/local/sbin/dnsmasq --stop-dns-rebind --local-ttl 1 --all-servers --dns-forward-max=5000 --cache-size=10000 {$args}"); + mwexec("/usr/local/sbin/dnsmasq --rebind-localhost-ok --stop-dns-rebind --local-ttl 1 --all-servers --dns-forward-max=5000 --cache-size=10000 {$args}"); if ($g['booting']) echo "done.\n"; From ce46b5da400edb5fcfb3f72afaa38a86459bf827 Mon Sep 17 00:00:00 2001 From: Scott Ullrich Date: Thu, 1 Jul 2010 17:12:56 -0400 Subject: [PATCH 03/32] More dns-rebind checks. Ticket #708 --- etc/inc/auth.inc | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/etc/inc/auth.inc b/etc/inc/auth.inc index 0af0594452..b2f3d91acd 100644 --- a/etc/inc/auth.inc +++ b/etc/inc/auth.inc @@ -49,6 +49,13 @@ require_once("config.gui.inc"); +if ($_SERVER['HTTP_HOST'] != $config['system']['hostname'] . "." . $config['system']['domain'] and + $_SERVER['HTTP_HOST'] != $_SERVER['SERVER_ADDR'] and + $_SERVER['HTTP_HOST'] != $config['system']['hostname']) { + display_error_form("501", "DNS Rebind attack detected, see http://en.wikipedia.org/wiki/DNS_rebinding"); + exit; +} + $groupindex = index_groups(); $userindex = index_users(); @@ -1181,4 +1188,4 @@ function session_auth() { return true; } -?> +?> \ No newline at end of file From 1ba06f4465d3bbc42e6c05f9ebf380bf22574c36 Mon Sep 17 00:00:00 2001 From: Scott Ullrich Date: Thu, 1 Jul 2010 17:25:17 -0400 Subject: [PATCH 04/32] Comment what we are doing here and add the ticket #. --- etc/inc/auth.inc | 1 + 1 file changed, 1 insertion(+) diff --git a/etc/inc/auth.inc b/etc/inc/auth.inc index b2f3d91acd..f295e8b3a3 100644 --- a/etc/inc/auth.inc +++ b/etc/inc/auth.inc @@ -49,6 +49,7 @@ require_once("config.gui.inc"); +/* DNS Binding attack prevention. http://redmine.pfsense.org/issues/708 */ if ($_SERVER['HTTP_HOST'] != $config['system']['hostname'] . "." . $config['system']['domain'] and $_SERVER['HTTP_HOST'] != $_SERVER['SERVER_ADDR'] and $_SERVER['HTTP_HOST'] != $config['system']['hostname']) { From 6266cf9949d7f722354382486a02401f3efbe1e1 Mon Sep 17 00:00:00 2001 From: Scott Ullrich Date: Thu, 1 Jul 2010 17:25:51 -0400 Subject: [PATCH 05/32] Binding -> Rebinding --- etc/inc/auth.inc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/etc/inc/auth.inc b/etc/inc/auth.inc index f295e8b3a3..e63316430d 100644 --- a/etc/inc/auth.inc +++ b/etc/inc/auth.inc @@ -49,7 +49,7 @@ require_once("config.gui.inc"); -/* DNS Binding attack prevention. http://redmine.pfsense.org/issues/708 */ +/* DNS ReBinding attack prevention. http://redmine.pfsense.org/issues/708 */ if ($_SERVER['HTTP_HOST'] != $config['system']['hostname'] . "." . $config['system']['domain'] and $_SERVER['HTTP_HOST'] != $_SERVER['SERVER_ADDR'] and $_SERVER['HTTP_HOST'] != $config['system']['hostname']) { From cc89c9e5b0c6257f6f6c0d4cafb3b74c9c3a0dbd Mon Sep 17 00:00:00 2001 From: Scott Ullrich Date: Thu, 1 Jul 2010 17:35:06 -0400 Subject: [PATCH 06/32] ^ Potential --- etc/inc/auth.inc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/etc/inc/auth.inc b/etc/inc/auth.inc index e63316430d..4793b3a3ad 100644 --- a/etc/inc/auth.inc +++ b/etc/inc/auth.inc @@ -53,7 +53,7 @@ require_once("config.gui.inc"); if ($_SERVER['HTTP_HOST'] != $config['system']['hostname'] . "." . $config['system']['domain'] and $_SERVER['HTTP_HOST'] != $_SERVER['SERVER_ADDR'] and $_SERVER['HTTP_HOST'] != $config['system']['hostname']) { - display_error_form("501", "DNS Rebind attack detected, see http://en.wikipedia.org/wiki/DNS_rebinding"); + display_error_form("501", "Potential DNS Rebind attack detected, see http://en.wikipedia.org/wiki/DNS_rebinding"); exit; } From d999ba6c3ffca4e04a9d04efecb90c3cd1eacc9f Mon Sep 17 00:00:00 2001 From: Erik Fonnesbeck Date: Thu, 1 Jul 2010 19:13:09 -0600 Subject: [PATCH 07/32] This code returned the size in kilobytes, while the part usually used returns megabytes. --- etc/inc/util.inc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/etc/inc/util.inc b/etc/inc/util.inc index 9d5872ebd7..da1b4963c1 100644 --- a/etc/inc/util.inc +++ b/etc/inc/util.inc @@ -1104,7 +1104,8 @@ function get_memory() { if(!$real && !$avail) { $real = trim(`sysctl hw.physmem | cut -d' ' -f2`); $avail = trim(`sysctl hw.realmem | cut -d' ' -f2`); - return array(($real/1024),($avail/1024)); + /* convert from bytes to megabytes */ + return array(($real/1048576),($avail/1048576)); } } From d39a0970eb8e542d276272c432211d6d405a614a Mon Sep 17 00:00:00 2001 From: Scott Ullrich Date: Thu, 1 Jul 2010 23:19:25 -0400 Subject: [PATCH 08/32] Do not include --rebind-localhost-ok it appears to not be in our version. Will re-add it once the binary is in place --- etc/inc/services.inc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/etc/inc/services.inc b/etc/inc/services.inc index b8fc92b774..2e4d6978ae 100644 --- a/etc/inc/services.inc +++ b/etc/inc/services.inc @@ -617,7 +617,8 @@ function services_dnsmasq_configure() { //} /* run dnsmasq */ - mwexec("/usr/local/sbin/dnsmasq --rebind-localhost-ok --stop-dns-rebind --local-ttl 1 --all-servers --dns-forward-max=5000 --cache-size=10000 {$args}"); + //--rebind-localhost-ok + mwexec("/usr/local/sbin/dnsmasq --stop-dns-rebind --local-ttl 1 --all-servers --dns-forward-max=5000 --cache-size=10000 {$args}"); if ($g['booting']) echo "done.\n"; From 8b7ae9a3712e146d55a7c6bc9f9bec2d3bac718c Mon Sep 17 00:00:00 2001 From: jim-p Date: Fri, 2 Jul 2010 10:08:06 -0400 Subject: [PATCH 09/32] Only unset if this is actually set. Ticket #710 --- usr/local/www/interfaces.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/usr/local/www/interfaces.php b/usr/local/www/interfaces.php index 4d6283b176..94fd82f8d1 100755 --- a/usr/local/www/interfaces.php +++ b/usr/local/www/interfaces.php @@ -492,7 +492,8 @@ if ($_POST) { unset($wancfg['provider']); unset($wancfg['ondemand']); unset($wancfg['timeout']); - unset($wancfg['pppoe']['pppoe-reset-type']); + if (isset($wancfg['pppoe']['pppoe-reset-type'])) + unset($wancfg['pppoe']['pppoe-reset-type']); unset($wancfg['local']); unset($wancfg['subnet']); unset($wancfg['remote']); From fc4d562bd390b1387574bb9bdb27ebdf1f933fd7 Mon Sep 17 00:00:00 2001 From: Scott Ullrich Date: Fri, 2 Jul 2010 11:11:09 -0400 Subject: [PATCH 10/32] Adding back --rebind-localhost-ok now that dnsmasq version is bumped. --- etc/inc/services.inc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/etc/inc/services.inc b/etc/inc/services.inc index 2e4d6978ae..e0092637ad 100644 --- a/etc/inc/services.inc +++ b/etc/inc/services.inc @@ -618,7 +618,7 @@ function services_dnsmasq_configure() { /* run dnsmasq */ //--rebind-localhost-ok - mwexec("/usr/local/sbin/dnsmasq --stop-dns-rebind --local-ttl 1 --all-servers --dns-forward-max=5000 --cache-size=10000 {$args}"); + mwexec("/usr/local/sbin/dnsmasq --rebind-localhost-ok --stop-dns-rebind --local-ttl 1 --all-servers --dns-forward-max=5000 --cache-size=10000 {$args}"); if ($g['booting']) echo "done.\n"; From 6775c54e2aa571d76d2fc6dea58f5c5a677997f4 Mon Sep 17 00:00:00 2001 From: Ermal Date: Mon, 5 Jul 2010 16:28:45 +0000 Subject: [PATCH 11/32] Fixes #698. Always check if we are dealing with an ip value to then store the subnet in the config. --- usr/local/www/firewall_aliases_edit.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/usr/local/www/firewall_aliases_edit.php b/usr/local/www/firewall_aliases_edit.php index dca3d1278f..5835bd2bf3 100755 --- a/usr/local/www/firewall_aliases_edit.php +++ b/usr/local/www/firewall_aliases_edit.php @@ -267,7 +267,7 @@ if ($_POST) { $address = array_merge($address, $rangesubnets); } else { $tmpaddress = $_POST["address{$x}"]; - if(($_POST['type'] == "network" || is_ipaddr($_POST["address{$x}"])) && $_POST["address_subnet{$x}"] <> "") + if(is_ipaddr($_POST["address{$x}"]) && $_POST["address_subnet{$x}"] <> "") $tmpaddress .= "/" . $_POST["address_subnet{$x}"]; $address[] = $tmpaddress; } From f60181150d6a64b9bcfaa246311e60a6a546b768 Mon Sep 17 00:00:00 2001 From: Erik Fonnesbeck Date: Mon, 5 Jul 2010 18:07:46 -0600 Subject: [PATCH 12/32] Add the missing VPN types to the interface list on port forwards and add the same VPNs to the list available on other types of NAT rules. --- usr/local/www/firewall_nat_1to1_edit.php | 27 +++++++++++++++++++++++- usr/local/www/firewall_nat_edit.php | 8 +++++++ usr/local/www/firewall_nat_out_edit.php | 27 +++++++++++++++++++++++- 3 files changed, 60 insertions(+), 2 deletions(-) diff --git a/usr/local/www/firewall_nat_1to1_edit.php b/usr/local/www/firewall_nat_1to1_edit.php index d7ed094d4a..ac009c889f 100755 --- a/usr/local/www/firewall_nat_1to1_edit.php +++ b/usr/local/www/firewall_nat_1to1_edit.php @@ -156,7 +156,32 @@ include("head.inc"); $ifdesc) + 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"; + + if ($config['pppoe']['mode'] == "server") + if(have_ruleint_access("pppoe")) + $interfaces['pppoe'] = "PPPoE VPN"; + + /* add ipsec interfaces */ + if (isset($config['ipsec']['enable']) || isset($config['ipsec']['mobileclients']['enable'])) + 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): ?>