Skip to contentSkip to conversation

pull_filer: ignore leading "spaces" in option names

PATCH Superseded [email protected]... 3 participants 9 messages Nov 29, 2022 – Nov 30, 2022

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 pull_filer: ignore leading "spaces" in option names

From: Selva Nair <[email protected]...>

It seems sometimes comma-separated pulled options have an offending leading space. Not sure whether that is an error, but the change here matches the behaviour of option parsing.

---
 src/openvpn/options.c | 6 ++++++
 1 file changed, 6 insertions(+)
src/openvpn/options.c +6 -0
index b7b34c9c..94cbd659 100644
@@ -5385,6 +5385,12 @@ apply_pull_filter(const struct options *o, char *line)
         return true;
     }
 
+    /* skip leading spaces matching the behaviour of parse_line */
+    while(*line && space(*line))
+    {
+        line++;
+    }
+
     for (f = o->pull_filter_list->head; f; f = f->next)
     {
         if (f->type == PUF_TYPE_ACCEPT && strncmp(line, f->pattern, f->size) == 0)
Signature · 1 line
2.34.1
#1 lore raw

PATCH v2 1/1 pull-filter: ignore leading "spaces" in option names

From: Selva Nair <[email protected]...>

It seems sometimes comma-separated pulled options have an offending leading space. Not sure whether that is an error, but the change here matches the behaviour of option parsing.

v2: fix typo in commit message.

---
 src/openvpn/options.c | 6 ++++++
 1 file changed, 6 insertions(+)
src/openvpn/options.c +6 -0
index b7b34c9c..94cbd659 100644
@@ -5385,6 +5385,12 @@ apply_pull_filter(const struct options *o, char *line)
         return true;
     }
 
+    /* skip leading spaces matching the behaviour of parse_line */
+    while(*line && space(*line))
+    {
+        line++;
+    }
+
     for (f = o->pull_filter_list->head; f; f = f->next)
     {
         if (f->type == PUF_TYPE_ACCEPT && strncmp(line, f->pattern, f->size) == 0)
Signature · 1 line
2.34.1
#2 lore raw

Re: [Openvpn-devel] [PATCH v2] pull-filter: ignore leading "spaces" in option names

Hi,

Quoted 7 lines · On Tue, Nov 29, 2022 at 01:37:56PM -0500, [email protected]... wrote:

From: Selva Nair <[email protected]...>

It seems sometimes comma-separated pulled options have an offending leading space. Not sure whether that is an error, but the change here matches the behaviour of option parsing.

v2: fix typo in commit message.

I have seen this, but I'd really prefer to fix the pushing side.

Which options have you seen this with? I only observed with with "auth-token", which grows an extra leading space when being sent unsolicited.

gert

Signature · 6 lines
"If was one thing all people took for granted, was conviction that if you 
 feed honest figures into a computer, honest figures come out. Never doubted 
 it myself till I met a computer with a sense of humor."
                             Robert A. Heinlein, The Moon is a Harsh Mistress

Gert Doering - Munich, Germany                             [email protected]...
author
#3 lore raw

Re: [Openvpn-devel] [PATCH v2] pull-filter: ignore leading "spaces" in option names

Hi,

Quoted 9 lines · Gert Doering

Hi,

Quoted 6 lines · On Tue, Nov 29, 2022 at 01:37:56PM -0500, [email protected]... wrote:

From: Selva Nair <[email protected]...>

It seems sometimes comma-separated pulled options have an offending leading space. Not sure whether that is an error, but the change here matches the behaviour of option parsing.

Quoted 8 lines
Quoted 1 line

v2: fix typo in commit message.

I have seen this, but I'd really prefer to fix the pushing side.

Which options have you seen this with? I only observed with with "auth-token", which grows an extra leading space when being sent unsolicited.

That's the only one I have seen too -- I made this on noticing that option parser
is happy with the leading space. While fixing this at the server side would be great, it's
arguable that this one too is needed to bring it line with option parsing. I'm fine either
way.

Selva

#4 lore raw

Re: [Openvpn-devel] [PATCH v2] pull-filter: ignore leading "spaces" in option names

In reply to Gert Doering

Am 29.11.2022 um 22:04 schrieb Gert Doering:

Quoted 9 lines

Hi,

Quoted 6 lines · On Tue, Nov 29, 2022 at 01:37:56PM -0500, [email protected]... wrote:

From: Selva Nair <[email protected]...>

It seems sometimes comma-separated pulled options have an offending leading space. Not sure whether that is an error, but the change here matches the behaviour of option parsing.

Quoted 6 lines
Quoted 1 line

v2: fix typo in commit message.

I have seen this, but I'd really prefer to fix the pushing side.

Which options have you seen this with? I only observed with with "auth-token", which grows an extra leading space when being sent unsolicited.

I think since the client wants to ignore these option, we should add this to the client as well as you can other abuse this to work around a client that uses pull filter.

Arne

#5 lore raw

Re: [Openvpn-devel] [PATCH v2] pull-filter: ignore leading "spaces" in option names

Hi,

Quoted 7 lines · Arne Schwabe
Quoted 3 lines

Which options have you seen this with? I only observed with with "auth-token", which grows an extra leading space when being sent unsolicited.

I think since the client wants to ignore these option, we should add this to the client as well as you can other abuse this to work around a client that uses pull filter.

Yeah, right. I was more thinking about this being another tool in my toolchest (if I push this with an extra space, I can use pull-filter to just ignore this special version).

But this is going to get more and more obscure, so I'll just merge Selva's patch and see if I can get the auth-token pushing fixed as well.

gert

Signature · 6 lines
"If was one thing all people took for granted, was conviction that if you 
 feed honest figures into a computer, honest figures come out. Never doubted 
 it myself till I met a computer with a sense of humor."
                             Robert A. Heinlein, The Moon is a Harsh Mistress

Gert Doering - Munich, Germany                             [email protected]...
#6 lore raw

Re: [Openvpn-devel] [PATCH v2] pull-filter: ignore leading "spaces" in option names

In reply to [email protected]...

Hi,

src/openvpn/options.c apply_pull_filter(const struct options *o, char *line) · line 5389

Quoted 2 lines · On Tue, Nov 29, 2022 at 01:37:56PM -0500, [email protected]... wrote:
src/openvpn/options.c +2 -0
+    /* skip leading spaces matching the behaviour of parse_line */
+    while(*line && space(*line))

I would actually prefer to use isspace(*line) here. space() is one of our special magic functions which returns true on 0-byte *or* isspace(), which won't have an effect (as *line checks for the 0 already), but will just confuse readers wrt "how is space() different from isspace()?".

Can you send a v3? ACK on that :-)

gert

Signature · 6 lines
"If was one thing all people took for granted, was conviction that if you 
 feed honest figures into a computer, honest figures come out. Never doubted 
 it myself till I met a computer with a sense of humor."
                             Robert A. Heinlein, The Moon is a Harsh Mistress

Gert Doering - Munich, Germany                             [email protected]...
#7 lore raw

PATCH v3 1/1 pull-filter: ignore leading "spaces" in option names

In reply to [email protected]...

From: Selva Nair <[email protected]...>

It seems sometimes comma-separated pulled options have an offending leading space. Not sure whether that is an error, but the change here matches the behaviour of option parsing.

v2: fix typo in commit message
v3: space() --> isspace()

---
 src/openvpn/options.c | 6 ++++++
 1 file changed, 6 insertions(+)
src/openvpn/options.c +6 -0
index b7b34c9c..cba99846 100644
@@ -5385,6 +5385,12 @@ apply_pull_filter(const struct options *o, char *line)
         return true;
     }
 
+    /* skip leading spaces matching the behaviour of parse_line */
+    while(isspace(*line))
+    {
+        line++;
+    }
+
     for (f = o->pull_filter_list->head; f; f = f->next)
     {
         if (f->type == PUF_TYPE_ACCEPT && strncmp(line, f->pattern, f->size) == 0)
Signature · 1 line
2.34.1
Acked-by on v3 1/1
#8 lore raw

[Openvpn-devel] [PATCH applied] Re: pull-filter: ignore leading spaces in option names

I thought we might not need it, but Arne says it's useful, and it's really trivial and not adding much code. *line is a local variable, so it can't have side effects, and isspace(*line) is "end of string"-safe as well.

Tested, of course, to a server that still had the extra blank

$ openvpn --pull-filter ignore auth-token ...

without the patch:

2022-11-30 13:10:41 PUSH: Received control message: 'PUSH_REPLY, auth-tokenSESS_ID'
2022-11-30 13:11:37 PUSH: Received control message: 'PUSH_REPLY, auth-tokenSESS_ID'

with the patch:

2022-11-30 13:21:02 PUSH: Received control message: 'PUSH_REPLY, auth-tokenSESS_ID'
2022-11-30 13:21:02 Pushed option removed by filter: 'auth-token SESS_ID_...
2022-11-30 13:21:59 PUSH: Received control message: 'PUSH_REPLY, auth-tokenSESS_ID'
2022-11-30 13:21:59 Pushed option removed by filter: 'auth-token SESS_ID_...

Your patch has been applied to the master and release/2.5 branch.

commit f02946ff9900a37dd36f61748173d53eca01adf9 (master) commit 00952a6184da0a77fbabe801d842a7546058f6c2 (release/2.5)

Author: Selva Nair
Date:   Wed Nov 30 05:55:02 2022 -0500
     pull-filter: ignore leading spaces in option names

     Signed-off-by: Selva Nair <[email protected]...>
     Acked-by: Gert Doering <[email protected]...>
     Message-Id: <[email protected]...>
     URL: https://www.mail-archive.com/search?l=mid&[email protected]...
     Signed-off-by: Gert Doering <[email protected]...>

--
kind regards,

Gert Doering