From 0512ffb7f70f85223a71ffd539b74459793178af Mon Sep 17 00:00:00 2001 From: Guillaume Mazoyer Date: Wed, 3 Sep 2014 11:19:56 +0200 Subject: Add config to disallow the use of private and reserved IP ranges. --- execute.php | 6 +-- includes/config.defaults.php | 13 +++++-- includes/utils.php | 88 ++++++++++++++++++++++++++++++++++++++++++++ routers/bird.php | 2 +- routers/cisco.php | 2 +- routers/juniper.php | 2 +- routers/quagga.php | 2 +- 7 files changed, 104 insertions(+), 11 deletions(-) diff --git a/execute.php b/execute.php index 330e070..26e91af 100644 --- a/execute.php +++ b/execute.php @@ -78,9 +78,9 @@ if (isset($_POST['doc']) && !empty($_POST['doc'])) { if (isset($_POST['query']) && !empty($_POST['query']) && isset($_POST['routers']) && !empty($_POST['routers']) && isset($_POST['parameters']) && !empty($_POST['parameters'])) { - $query = htmlspecialchars($_POST['query']); - $hostname = htmlspecialchars($_POST['routers']); - $parameters = htmlspecialchars($_POST['parameters']); + $query = trim($_POST['query']); + $hostname = trim($_POST['routers']); + $parameters = trim($_POST['parameters']); // Do the processing $router = Router::instance($hostname, $requester); diff --git a/includes/config.defaults.php b/includes/config.defaults.php index 06fac62..aca58ff 100644 --- a/includes/config.defaults.php +++ b/includes/config.defaults.php @@ -28,7 +28,12 @@ $config = array( // Logs file when commands will be written 'logs' => '/var/log/looking-glass.log', // Allow private ASN - 'allow_private_asn' => false + 'allow_private_asn' => false, + // Allow RFC1918 IPv4 and FD/FC IPv6 as parameters + 'allow_private_ip' => true, + // Allow reserved IPv4 addresses (0.0.0.0/8, 169.254.0.0/16, + // 192.0.2.0/24 and 224.0.0.0/4) + 'allow_reserved_ip' => true ), // Documentation (must be HTML) @@ -37,7 +42,7 @@ $config = array( 'bgp' => array( 'command' => 'show route IP_ADDRESS', 'description' => 'Show the best routes to a given destination.', - 'parameter' => 'The parameter must be a valid destination. Destination means an IPv4/IPv6 address or a subnet. Masks are also accepted as part of a valid IPv4/IPv6 address.
Please note that some routers always need a mask to be given when looking for an IPv6 address.

Example of valid arguments: