pppoe-server: Check for valid network

Submitted by Stefan Schantl on Oct. 15, 2015, 1:49 p.m.

Details

Message ID 1444916992-7458-1-git-send-email-stefan.schantl@ipfire.org
State New
Headers show

Commit Message

Stefan Schantl Oct. 15, 2015, 1:49 p.m.
The pppoe-server did not proper check if a valid
IPv4 or IPv6 network has been specified.

Signed-off-by: Stefan Schantl <stefan.schantl@ipfire.org>
---
 src/hooks/configs/pppoe-server | 6 ++++++
 1 file changed, 6 insertions(+)

Patch hide | download patch | download mbox

diff --git a/src/hooks/configs/pppoe-server b/src/hooks/configs/pppoe-server
index 1ef3ba9..ac9b90a 100644
--- a/src/hooks/configs/pppoe-server
+++ b/src/hooks/configs/pppoe-server
@@ -42,6 +42,12 @@  hook_check_config_settings() {
 	assert isset SUBNET
 	assert isset MAX_SESSIONS
 
+	# Check input.
+	if ! ip_is_network "${SUBNET}"; then
+		log ERROR "Invalid subnet. Please provide a valid IPv6 or IPv4 network."
+		return ${EXIT_ERROR}
+	fi
+
 	local server
 	for server in ${DNS_SERVERS}; do
 		assert ipv4_is_valid "${server}"

Comments

Michael Tremer Oct. 15, 2015, 2:50 p.m.
Hi,

there are some issues with this patch.

On Thu, 2015-10-15 at 15:49 +0200, Stefan Schantl wrote:
> The pppoe-server did not proper check if a valid
> IPv4 or IPv6 network has been specified.
> 
> Signed-off-by: Stefan Schantl <stefan.schantl@ipfire.org>
> ---
>  src/hooks/configs/pppoe-server | 6 ++++++
>  1 file changed, 6 insertions(+)
> 
> diff --git a/src/hooks/configs/pppoe-server b/src/hooks/configs/pppoe
> -server
> index 1ef3ba9..ac9b90a 100644
> --- a/src/hooks/configs/pppoe-server
> +++ b/src/hooks/configs/pppoe-server
> @@ -42,6 +42,12 @@ hook_check_config_settings() {
>  	assert isset SUBNET
>  	assert isset MAX_SESSIONS
>  
> +	# Check input.
> +	if ! ip_is_network "${SUBNET}"; then
> +		log ERROR "Invalid subnet. Please provide a valid
> IPv6 or IPv4 network."
> +		return ${EXIT_ERROR}
> +	fi
> +

This will only validate the input when it is written to the
configuration file or read from the configuration file. I think this
should be as fast as possible and not clutter the log when something is
going wrong.

The user should get an error when the input is received from the
command line (that is a bit further down in the file).

The PPPoE server does NOT handle and IPv6 addresses here. It supports
IPv6, but IP addresses are not handed out in the same style as on an
IPv4 PPP link. You will have to check for IPv4 only. You should also
check if the subnet is big enough.

Please consider sending more patches that validate the rest of the
configuration.

>  	local server
>  	for server in ${DNS_SERVERS}; do
>  		assert ipv4_is_valid "${server}"

-Michael
Michael Tremer Nov. 6, 2015, 3 p.m.
Is there any update on this?

-Michael

On Thu, 2015-10-15 at 15:50 +0100, Michael Tremer wrote:
> Hi,
> 
> there are some issues with this patch.
> 
> On Thu, 2015-10-15 at 15:49 +0200, Stefan Schantl wrote:
> > The pppoe-server did not proper check if a valid
> > IPv4 or IPv6 network has been specified.
> > 
> > Signed-off-by: Stefan Schantl <stefan.schantl@ipfire.org>
> > ---
> >  src/hooks/configs/pppoe-server | 6 ++++++
> >  1 file changed, 6 insertions(+)
> > 
> > diff --git a/src/hooks/configs/pppoe-server
> > b/src/hooks/configs/pppoe
> > -server
> > index 1ef3ba9..ac9b90a 100644
> > --- a/src/hooks/configs/pppoe-server
> > +++ b/src/hooks/configs/pppoe-server
> > @@ -42,6 +42,12 @@ hook_check_config_settings() {
> >  	assert isset SUBNET
> >  	assert isset MAX_SESSIONS
> >  
> > +	# Check input.
> > +	if ! ip_is_network "${SUBNET}"; then
> > +		log ERROR "Invalid subnet. Please provide a valid
> > IPv6 or IPv4 network."
> > +		return ${EXIT_ERROR}
> > +	fi
> > +
> 
> This will only validate the input when it is written to the
> configuration file or read from the configuration file. I think this
> should be as fast as possible and not clutter the log when something
> is
> going wrong.
> 
> The user should get an error when the input is received from the
> command line (that is a bit further down in the file).
> 
> The PPPoE server does NOT handle and IPv6 addresses here. It supports
> IPv6, but IP addresses are not handed out in the same style as on an
> IPv4 PPP link. You will have to check for IPv4 only. You should also
> check if the subnet is big enough.
> 
> Please consider sending more patches that validate the rest of the
> configuration.
> 
> >  	local server
> >  	for server in ${DNS_SERVERS}; do
> >  		assert ipv4_is_valid "${server}"
> 
> -Michael